#include "happy.h"
std::vector <long long int> happy (int N, int Q, std::vector <int> u, std::vector <int> v, std::vector <int> h, std::vector <int> t, std::vector <int> l, std::vector <int> r) {
    int n=N,q=Q;
    std::vector<long long int>ans;
    bool deschis[300005]={0};
    int nr=0;
    for(int k=0;k<q;k++){
        if(t[k]==1&&deschis[l[k]]==0){
            deschis[l[k]]=1;
            nr++;
        }
        if(t[k]==2&&deschis[l[k]]==1){
            deschis[l[k]]=0;
            nr--;
        }
        long long int r=nr*(nr-1)/2;
        ans.push_back(r);
    }
    return ans;
}
/**
6 5
0 1 1
1 2 2
2 3 3
2 4 4
4 5 2
1 1 2
1 2 3
2 2 2
2 4 5
1 0 5

2
6
1
1
56

6 5
0 1 1
1 2 1
2 3 1
2 4 1
4 5 1
1 1 1
1 2 2
2 2 2
2 4 4
1 0 0
**/
