// mc3.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <set>
#include <stack>
using namespace std;

int vec[100005], vec2[100005];
int ans_start[100005], ans_prob[100005], ans_finish[100005];
int nr, start;
stack<int> to_put;
int n, m, i, op, x, y;
int main()
{
    cin >> n >> m;
    for (i = 1; i <= m; i++)
    {
        cin >> op;
        if (op == 1)
        {
            cin >> x >> y;
            vec[x]++;
            vec[y+1]--;
        }
        if (op == 2)
        {
            cin >> x;
            vec2[x] = i;
        }

    }
    nr = 0;
    for (i = 1; i <= n; i++)
    {
        if (nr+vec[i] != 0)
        {
            while (nr+vec[i] != 0)
            {
                nr = nr + vec[i];
                vec[i] = (nr % 2);
                i++;
            }
            //int old = vec[i];
            //vec[i] = nr % 2;
            nr = nr + vec[i];
            vec[i] = 0;
        }
    }
    for (i = 1; i <= n;)
    {
        if (vec[i] == 0)
        {
            start = i;
            while (vec[i] == 0 && i<=n)
            {
                if (vec2[i])
                {
                    ans_start[vec2[i]] = start;
                    to_put.push(vec2[i]);
                }
                i++;
            }
            while (!to_put.empty())
            {
                int top = to_put.top();
                to_put.pop();
                ans_finish[top] = i - 1;
                ans_prob[top] = 0;
            }
            
        }
        if (vec[i] == 1)
        {
            start = i;
            while (vec[i] == 1 && i <= n)
            {
                if (vec2[i])
                {
                    ans_start[vec2[i]] = start;
                    to_put.push(vec2[i]);
                }
                i++;
            }
            while (!to_put.empty())
            {
                int top = to_put.top();
                to_put.pop();
                ans_finish[top] = i - 1;
                ans_prob[top] = 1;
            }

        }
    }
    for (i = 1; i <= m; i++)
    {
        if (ans_start[i])
        {
            cout << ans_prob[i] << " " << ans_start[i] << " " << ans_finish[i] << "\n";
        }
    }
}