#include "happy.h"
using namespace std;
const int MAXN = 3*1e5;
long long edges[MAXN];
unordered_set <long long> rest;

long long kkk (long long l, long long r)
{
    if (l > r)
    {
        swap(l, r);
    }
    long long sled = l;
    long long aa = 0;
    while(sled < r)
    {
        aa = (aa^rest[sled]);
        sled ++;
    }
        return aa;
}

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)
{
    vector <long long int> otg;
     for (int i = 0; i < n; i ++)
    {
        long long a=u[i], b=v[i], c=h[i];
        edges[i]=c;
    }

    for (long long i =0;i<q;i++)
    {
        long long a=t[i],b=l[i],c=r[i];
        if(a==1)
        {
            rest.insert(b);
        }
        else
        {
            auto it = rest.find(b);
            rest.erase(it);
        }
        long long ans = 0;
        for (auto it:rest)
        {
            for (auto it2 = it+1;it2<rest.end();it2++)
            {
                long long l = it*;
                long long r=it2*;
                ans += kkk(l,r);
                
            }
        }
        otg.push_back(ans);
    }
    return otg;
}
