#include using namespace std; using ll = long long; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); ll x, y, n; cin >> x >> y >> n; for (int i=0; i> u >> v; if (u == 0) { cout << (v - 1) % y + 1 << endl; } else { if ((u-1)/y == (v-1)/y) { cout << v - u << endl; } else { cout << (u-1)%y + 1 + (v-1)% y + 1 << endl; } } } }