#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
using namespace std;
using ll = long long;
struct Edge
{
    ll to;
    ll cost;
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, ll>;
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), v.end()
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = LLONG_MAX;
const int MAX = 510000;
bool graph[nmax][nmax];
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;

    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, long long M)
{
    if(N==1 && M == 0){
        cout << "1 2" << endl;
        return;
    }
    ll r_max = 1000000000;
    // Mが正の時を考える
    if (M < 0 || N - 1 <= M)
    {
        cout << -1 << endl;
        return;
    }
    vector<pair<ll, ll>> ans;

    ll l = 1, r = r_max / 2;
    // 青木くんの個数を1とする
    ll cnt = 0;
    ans.push_back(P(l, r));
    cnt++;
    // 高橋くんがM+1個選べるように選択する
    ll tmp_l = (l+r)/2;
    ll tmp_r = tmp_l+1;
    while (cnt <= M + 1)
    {
        ans.push_back(P(tmp_l, tmp_r));
        cnt++;
        tmp_l += 2;
        tmp_r += 2;
    }

    tmp_r += r;
    tmp_l -=(l+r)/2;
    while (cnt < N)
    {
        ans.push_back(P(tmp_l, tmp_r));
        cnt++;
        tmp_l++;
        tmp_r++;
    }

    for (auto &&i : ans)
    {
        cout << i.first << " " << i.second << endl;
    }
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    solve(N, M);
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (ll i=(ll)N-1; i>=0; i--)
#define popcount __builtin_popcount

const ll LLINF = pow(2,61)-1;
const ll INF = pow(2,30)-1;

ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

struct num {
  ll n, i;
  num operator+ (const num &x) const { return (num){n+x.n, i+x.i}; }
  num operator- (const num &x) const { return (num){n-x.n, i-x.i}; }
};

struct SegTree {
  ll size;
  vector<num> pos;
  SegTree(ll N) { size = 1; while(size<N) size<<=1; pos.resize(2*size,(num){0,0}); }
  num operator[](const ll &x) const { return pos[x+size]; }

  void set(ll x, const num v) { pos[x+size] = v; }
  void update(ll x, const num v) { set(x,v); x+=size; while (x>>=1) operate(x); }
  num query(ll a, ll b) {
    num L = {0,0}, R = {0,0};
    for (a+=size, b+=size; a<b; a>>=1, b>>=1) {
      if (a&1) { L = q(L,pos[a]); a++; }
      if (b&1) { b--; R = q(pos[b],R); }
    }
    return q(L,R);
  }
  void operate(ll i) { pos[i] = q(pos[i*2], pos[i*2+1]); }
  num q(num x, num y) { return x + y; }
};

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

int main() {
  ll N, M, Q; cin >> N >> M >> Q;
  ll T[Q], X[Q], Y[Q]; rep(i,Q) { cin >> T[i] >> X[i] >> Y[i]; X[i]--; }
  set<ll> nset; rep(i,Q) nset.insert(Y[i]); nset.insert(0);
  vector<ll> nv; for (auto x: nset) nv.push_back(x);
  map<ll, ll> nv_idx; rep(i,nv.size()) nv_idx[nv[i]] = i;
  // debug(all(nv));

  ll now_row[N] = {}, now_col[M] = {};
  ll nvs = nv.size();
  SegTree st_row(nvs); st_row.update(0,{0,N});
  SegTree st_col(nvs); st_col.update(0,{0,M});
  ll result = 0;
  rep(i,Q) {
    if (T[i]==1) {
      ll fp = nv_idx[now_row[X[i]]], tp = nv_idx[Y[i]];
      ll sum_from = st_col.query(0,fp).i * now_row[X[i]] + st_col.query(fp,nvs).n;
      ll sum_to   = st_col.query(0,tp).i * Y[i]          + st_col.query(tp,nvs).n;
      result += sum_to - sum_from;
      st_row.update(fp, st_row[fp] - (num){now_row[X[i]],1});
      st_row.update(tp, st_row[tp] + (num){Y[i],1});
      now_row[X[i]] = Y[i];
    }
    else {
      ll fp = nv_idx[now_col[X[i]]], tp = nv_idx[Y[i]];
      ll sum_from = st_row.query(0,fp).i * now_col[X[i]] + st_row.query(fp,nvs).n;
      ll sum_to   = st_row.query(0,tp).i * Y[i]          + st_row.query(tp,nvs).n;
      result += sum_to - sum_from;
      st_col.update(fp, st_col[fp] - (num){now_col[X[i]],1});
      st_col.update(tp, st_col[tp] + (num){Y[i],1});
      now_col[X[i]] = Y[i];
    }
    cout << result << endl;
  }
  return 0;
}