#!/usr/bin/env python3


# Generated by 2.4.0 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    n = int(input())
    kukans = []
    for i in range(n):
        kukans.append(list(map(int,input().split())))
    print(kukans)

    l,u = 0,0

    for k in kukans:
        print(k)
        if k[0] == 1:
            l,u = k[1],k[2]
        if k[0] == 2:
            l,u = k[1],k[2]-1
        if k[0] == 3:
            l,u = k[1]+1,k[2]
        if k[0] == 4:
            l,u = k[1]+1,k[2]-1
    print(u-l)

if __name__ == '__main__':
    main()
