#include using namespace std; int main() { int L, R, C, A; A = 999; cin >> L >> R >> C; int l = L - L / 10001000; int r = R - R / 10001000; int c = C - C / 10001000; 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; }