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