#include using namespace std; int main() { int L,R,C,A,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*C-1) << " " << ((x * C-1) / 1000 + 1) << " " << A << endl; } cout << A << endl; return 0; }