#include #include using namespace std; using namespace atcoder; #ifndef ONLINE_JUDGE #define _GLIBCXX_DEBUG #endif using ull = unsigned long long; using ll = long long; using vi = vector; using vs = vector; using vc = vector; using vb = vector; using vd = vector; using vl = vector; using vvi = vector; using vvl = vector; using vvvl = vector; #define rep(i,n) for(ll i = 0; i< (int)n; i++) #define drep(i,n) for(ll i=n; i>=0; i--) #define REP(a,b,c) for(ll a = b; a=c; a--) const ll INF = 5e18; #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define pb push_back #define eb emplace_back #define em emplace #define pob pop_back #define Yes cout << "Yes" << endl #define No cout << "No" << endl #define YES cout << "YES" << endl #define NO cout << "NO" << endl #define fail cout << -1 << endl #define YN {cout<<"Yes"< inline void input(T&... a) { ((cin >> a), ...);} template inline void print(vector& a) {rep(i,a.size()) if(i) cout << " " << a[i]; else cout << a[i]; cout << endl;} template inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} else return false;} template inline bool chmax(T& a, T b) {if(a>a>>b; // a < b if(a==0) { cout << (b-1)%y+1 << endl; } else if(b-a <= y && ((b-1)/y == (a-1)/y)) cout << b-a << endl; else { cout << (b-1)%y+(a-1)%y+2 << endl; } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>x>>y>>n; while(n--) solve(); }