#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define ll long long int
#define ld long double
#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)

using namespace __gnu_pbds;
using namespace std;

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

//template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

#ifdef LOCAL
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif


std::mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int ri(int a, int b) {
    return uniform_int_distribution<int>(a, b)(rng);
}

ll power(ll x, ll y, ll p){
   ll res = 1;
   x = x % p;
   while (y > 0) {
      if (y & 1)
         res = (res * x) % p;
      y = y >> 1;
      x = (x * x) % p;
   }
   return res;
}

const ll INF = (ll)(8e18);
const ll MOD = (ll)(1e9 + 7);
const ll HMOD = (ll)4222234727;
const ll Hashprime = (ll)31;

const int maxn = 100100;

class segmentTree{
  public:
    vector<ll> segment;
    segmentTree(){}
    segmentTree(ll ssize){
       for(ll i = 0; i < 4LL * ssize + 1LL; i++){
           segment.push_back(0LL);
       }
    }

    ll query(ll l, ll r, ll start, ll end, ll node){
        if(r < start || l > end) return -INF;
        if(start <= l && end >= r) return segment[node];
        ll mid = (l + r) >> 1;
        ll left = query(l, mid, start, end, node + node);
        ll right = query(mid + 1, r, start, end, node + node + 1);
        return max(left, right);
    }

    void update(ll l, ll r, ll index, ll val, ll node){
        if(l == r){
            segment[node] = val;
            return;
        }
        ll mid = (l + r) >> 1;
        if(l <= index && index <= mid) update(l, mid, index, val, node + node);
        else update(mid + 1, r, index, val, node + node + 1);
        segment[node] = max(segment[node + node], segment[node + node + 1]);
    }
};


int32_t main(){
    IOS;
    #ifndef ONLINE_JUDGE
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    int t = 1; // cin >> t;
    while(t--){
       ll n,q; cin >> n >> q;
       segmentTree a(n + 1),b(n + 1);
       a.update(1, n, n, n, 1);
       b.update(1, n, n, n, 1);
       ll ans = (n - 2) * (n - 2);
       while(q--){
         ll type,x; cin >> type >> x;
         if(type == 1){
           ll l = 2, r = n;
           ll val = n;
           while(l <= r){
              ll mid = (l + r) / 2;
              if(b.query(1, n, l, mid, 1) >= x){
                 val = mid;
                 r = mid - 1;
              }else l = mid + 1;
           }
           ans -= (val - 2);
           a.update(1, n, x, val, 1);
         }else{
           ll l = 2, r = n;
           ll val = n;
           while(l <= r){
              ll mid = (l + r) / 2;
              if(a.query(1, n, l, mid, 1) >= x){
                 val = mid;
                 r = mid - 1;
              }else l = mid + 1;
           }
           ans -= (val - 2);
           b.update(1, n, x, val, 1);
         }
       }
       cout << ans << '\n';
    }
    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}
//g++ -DLOCAL -std=c++17 -Wshadow -Wall -o "c" "comp.cpp" -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g


Measured memory_bytes: 21888