#include using namespace std; int main() { int L,R,C,A; long N; A = 1000; cin >> L >> R >> C; for (int x = L; x < R+1; x++){ N = x * C; if (A > ((N - 1) / 1000 + 1) * 1000 - N) { A = ((N - 1) / 1000 + 1) * 1000 - N; } cout << x << " " << (x * C - 1) << " " << ((x * C - 1) / 1000 + 1) << " " << ((N - 1) / 1000 + 1) * 1000 - N << endl; } cout << A << endl; return 0; }