l = []
l2 = []

def Add(a):
    done = False
    for i in range(0, len(l)):
        if l[i] >= a:
            done = True
            break
    if not done:
        l.append(a)
    else:
        if l[i] == a:
            del l[i]
        else:
            l.insert(i, a)

def testAdd():
    for i in l:
        print(i)

def getPosition(x, i, j):
    if i == j:
        return i
    p = (i + j) / 2
    if x < l[p]:
        return getPosition(x, i, p)
    else:
        if x > l[p]:
            return getPosition(x, p + 1, j)
        else:
            return p
    
def writeSolution():
    for i in range(0, len(l2), 3):
        print l2[i], l2[i+1], l2[i+2]


if __name__ == '__main__':
    s = raw_input("")
    ch = s.split(' ')
    n = long(ch[0])
    m = long(ch[1])
    for i in range(m):
        s = raw_input("")
        ch = s.split(' ')
        if (ch[0] == '1'):
            a, b = long(ch[1]), long(ch[2]) + 1
            if a > b:
                a, b = b, a
            Add(a)
            if b <= n:
                Add(b)
##            testAdd()
        if (ch[0] == '2'):
            a = long(ch[1])
            if len(l) > 0:
                done = False
                for pos in range(0, len(l)):
                    if l[pos] >= a:
                        done = True
                        break
                if not done:
                    pos = len(l)
                if pos < len(l):
                    if l[pos] == a:
                        l2.append(1 - pos % 2)
                        l2.append(l[pos])
                        if pos == len(l) - 1:
                            l2.append(n)
                        else:
                            l2.append(l[pos+1] - 1)
                    else:
                        l2.append(pos % 2)
                        if pos == 0:
                            l2.append(1)
                        else:
                            l2.append(l[pos - 1])
                        l2.append(l[pos] - 1)
                else:
                    l2.append(pos % 2)
                    l2.append(l[pos - 1])
                    l2.append(n)
            else:
                l2.append(0)
                l2.append(1)
                l2.append(n)
    
    writeSolution()