A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the show.

The rules are simple. The host thinks of an integer y and the participants guess it by asking questions to the host. There are four types of acceptable questions:  Is it true that y is strictly larger than number x?  Is it true that y is strictly smaller than number x?  Is it true that y is larger than or equal to number x?  Is it true that y is smaller than or equal to number x? 

On each question the host answers truthfully, "yes" or "no".

Given the sequence of questions and answers, find any integer value of y that meets the criteria of all answers. If there isn't such value, print "Impossible".


-----Input-----

The first line of the input contains a single integer n (1 ≤ n ≤ 10000) — the number of questions (and answers). Next n lines each contain one question and one answer to it. The format of each line is like that: "sign x answer", where the sign is:  ">" (for the first type queries),  "<" (for the second type queries),  ">=" (for the third type queries),  "<=" (for the fourth type queries). 

All values of x are integer and meet the inequation  - 10^9 ≤ x ≤ 10^9. The answer is an English letter "Y" (for "yes") or "N" (for "no").

Consequtive elements in lines are separated by a single space.


-----Output-----

Print any of such integers y, that the answers to all the queries are correct. The printed number y must meet the inequation  - 2·10^9 ≤ y ≤ 2·10^9. If there are many answers, print any of them. If such value doesn't exist, print word "Impossible" (without the quotes).


-----Examples-----
Input
4
>= 1 Y
< 3 N
<= -3 N
> 55 N

Output
17

Input
2
> 100 Y
< -100 Y

Output
Impossible

Difficulty: interview

Starter code:

Solutions:
"""
Codeforces Round 241 Div 1 Problem A

Author  : chaotic_iak
Language: Python 3.3.4
"""

class InputHandlerObject(object):
    inputs = []

    def getInput(self, n = 0):
        res = ""
        inputs = self.inputs
        if not inputs: inputs.extend(input().split(" "))
        if n == 0:
            res = inputs[:]
            inputs[:] = []
        while n > len(inputs):
            inputs.extend(input().split(" "))
        if n > 0:
            res = inputs[:n]
            inputs[:n] = []
        return res
InputHandler = InputHandlerObject()
g = InputHandler.getInput

############################## SOLUTION ##############################
n = int(input().strip())
mn = -2*10**9
mx = 2*10**9
repl = [(">", "<="), (">=", "<"), ("<=", ">"), ("<", ">=")]
for i in range(n):
    a = g()
    a[1] = int(a[1])
    if a[2] == "N":
        for qq,qqq in repl:
            if qq == a[0]:
                a[0] = qqq
                break
    if a[0] == ">": a[1] += 1
    if a[0] == "<": a[1] -= 1
    if a[0][0] == ">": mn = max(mn, a[1])
    if a[0][0] == "<": mx = min(mx, a[1])

if mn <= mx:
    print(mn)
else:
    print("Impossible")

n = int(input())
l, r = -1000000001, 1000000001
for i in range(n): 
    s = input().split()
    if s[2] == 'Y':
        if s[0] == '>':
            l = max(l, int(s[1]) + 1)
        elif s[0] == '>=':
            l = max(l, int(s[1]))
        elif s[0] == '<':
            r = min(r, int(s[1]) - 1)
        else:
            r = min(r, int(s[1]))
    else:
        if s[0] == '<=':
            l = max(l, int(s[1]) + 1)
        elif s[0] == '<':
            l = max(l, int(s[1]))
        elif s[0] == '>=':
            r = min(r, int(s[1]) - 1)
        else:
            r = min(r, int(s[1]))        
if r < l:
    print("Impossible")
elif r == 1000000001 and l == -1000000001:
    print(1)
elif r == 1000000001:
    print(l)
elif l == -1000000001:
    print(r)
else:
    print(r)

n = int(input())

lewo = -2*(10**9); prawo = 2*(10**9)

for i in range(n):
    buf = input().split(" ")
    liczba = int(buf[1])
    wynik = buf[2]
    if (buf[0]==">=" and wynik=="Y") or (buf[0]=="<" and wynik=="N"):
        lewo = max(lewo, liczba)
    if (buf[0]=="<=" and wynik=="Y") or (buf[0]==">" and wynik=="N"):
        prawo = min(prawo, liczba)
    if (buf[0]=="<" and wynik=="Y") or (buf[0]==">=" and wynik=="N"):
        prawo = min(prawo, liczba-1)
    if (buf[0]==">" and wynik=="Y") or (buf[0]=="<=" and wynik=="N"):
        lewo = max(lewo, liczba+1)

#print(lewo, prawo)
if(lewo > prawo):
    print("Impossible")
else:
    print(lewo)

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import math

def reverse_sign(sign):
    if sign == '>=':
        return '<'
    elif sign == '<=':
        return '>'
    elif sign == '>':
        return '<='
    else:
        return '>='

N = int(input())
mn = int(-1.5 * math.pow(10,9))
mx = int(1.5 * math.pow(10,9))
for n in range(N):
    (sign, num, flag) = input().split()
    num = int(num)
    if flag == 'N':
        sign = reverse_sign(sign)

    if sign == '>':
        num += 1
        sign = '>='
    if sign == '<':
        num -= 1
        sign = '<='

    if sign == '>=':
        mn = max(mn, num)
    elif sign == '<=':
        mx = min(mx, num)
    # print("mn, mx = ", mn, mx)
        
if mn > mx:
    print ('Impossible')
else:
    print (mn)
        
        


n=int(input())
l=-2*10**9
r=2*10**9
for i in range(n):
    s=input().split()
    s[1]=int(s[1])
    if s[2]=='Y':
        if s[0]=='>=':
            l=max(l,s[1])
        elif s[0]=='>':
            l=max(l,s[1]+1)
        elif s[0]=='<=':
            r=min(r,s[1])
        else:
            r=min(r,s[1]-1)
    else:
        if s[0]=='>=':
            r=min(r,s[1]-1)
        elif s[0]=='>':
            r=min(r,s[1])
        elif s[0]=='<=':
            l=max(l,s[1]+1)
        else:
            l=max(l,s[1])
if l>r:
    print('Impossible')
else:
    print(l)

n = int(input())
questions = []

for _ in range(n):
    questions.append(input())

lower_bound, upper_bound = None, None

for q in questions:
    bound = int(q.split()[1])
    if (q.startswith('>') and q.endswith('Y')) or (q.startswith('<') and q.endswith('N')):
        if ('Y' in q and '=' not in q) or ('N' in q and '=' in q):
            bound += 1
        lower_bound = bound if lower_bound == None else max(bound, lower_bound)
    else:
        if ('Y' in q and '=' not in q) or ('N' in q and '=' in q):
            bound -= 1
        upper_bound = bound if upper_bound == None else min(bound, upper_bound)

if lower_bound != None and upper_bound != None and lower_bound > upper_bound:
    print('Impossible')
else:
    print(lower_bound if lower_bound != None else upper_bound)

n=int(input())
k=0
a=[]
r=[]
h=0
for i in range(n):
    a.append(list(map(str,input().split())))
for i in range(n):
    for j in range(1):
        if a[i][j]=='>=' and a[i][j+2]=='Y':
            if k<int(a[i][j+1]):
                k=int(a[i][j+1])
        if a[i][j]=='>=' and a[i][j+2]=='N':
            if k>=int(a[i][j+1]):
                k=int(a[i][j+1])-1
        if a[i][j]=='>' and a[i][j+2]=='Y':
            if k<=int(a[i][j+1]):
                k=int(a[i][j+1])+1
        if a[i][j]=='>' and a[i][j+2]=='N':
            if k>int(a[i][j+1]):
                k=int(a[i][j+1])
        if a[i][j]=='<=' and a[i][j+2]=='Y':
            if k>int(a[i][j+1]):
                k=int(a[i][j+1])
        if a[i][j]=='<=' and a[i][j+2]=='N':
            if k<=int(a[i][j+1]):
                k=int(a[i][j+1])+1
        if a[i][j]=='<' and a[i][j+2]=='Y':
            if k>=int(a[i][j+1]):
                k=int(a[i][j+1])-1
        if a[i][j]=='<' and a[i][j+2]=='N':
            if k<int(a[i][j+1]):
                k=int(a[i][j+1])

for i in range(n):
    for j in range(1):
        if a[i][j]=='>=' and a[i][j+2]=='Y':
            if k>=int(a[i][j+1]):
                r.append('+')
            else:
                r.append('-')
        if a[i][j]=='>=' and a[i][j+2]=='N':
            if k<int(a[i][j+1]):
                r.append('+')
            else:
                r.append('-')
        if a[i][j]=='>' and a[i][j+2]=='Y':
            if k>int(a[i][j+1]):
                r.append('+')
            else:
                r.append('-')
        if a[i][j]=='>' and a[i][j+2]=='N':
            if k<=int(a[i][j+1]):
                r.append('+')
            else:
                r.append('-')
        if a[i][j]=='<=' and a[i][j+2]=='Y':
            if k<=int(a[i][j+1]):
                r.append('+')
            else:
                r.append('-')
        if a[i][j]=='<=' and a[i][j+2]=='N':
            if k>int(a[i][j+1]):
                r.append('+')
            else:
                r.append('-')
        if a[i][j]=='<' and a[i][j+2]=='Y':
            if k<int(a[i][j+1]):
                r.append('+')
            else:
                r.append('-')
        if a[i][j]=='<' and a[i][j+2]=='N':
            if k>=int(a[i][j+1]):
                r.append('+')
            else:
                r.append('-')
for i in range(len(r)):
    if r[i]=='-':
        print('Impossible')
        h=0
        break
    else:
        h+=1
if h!=0:
    print(k)


n=int(input(''))
z={}
ch={}
tf={}
for i in range(0,n):
    z[i],ch[i],tf[i]=list(map(str,input('').split()))
    ch[i]=int(ch[i])
    if z[i]=='<': z[i]=int(1)
    if z[i]=='<=': z[i]=int(2)
    if z[i]=='>': z[i]=int(3)
    if z[i]=='>=': z[i]=int(4)
    if tf[i]=='N':
        if z[i]==1:
            z[i]=4
        else:
            if z[i]==2: z[i]=3
            else:
                if z[i]==3: z[i]=2
                else:
                    if z[i]==4: z[i]=1
    if z[i]==1:
        tf[i]=ch[i]-1
    if z[i]==3:
        tf[i]=ch[i]+1
    if ((z[i]==2)or(z[i]==4)): tf[i]=ch[i]
    
def proverka(x,znak,oo):
    if znak==1:
        if x<oo: return 1
        else: return 0
    elif znak==2:
        if x<=oo: return 1
        else: return 0       
    elif znak==3:
        if x>oo: return 1
        else: return 0
    elif znak==4:
        if x>=oo: return 1
        else: return 0

for i in range(0,n):
    l=1
    for j in range(0,n):
        l*=proverka(tf[i],z[j],ch[j])
        if (l==0): break
    if l==1:
        print(tf[i])
        return
print("Impossible")



_ = int(input())

mini = - 10**9-1
maxi = 10**9+1

for i in range(_):
    s, n, a  = input().split()
    n = int(n)
#    print('\n---')
#    print(s, n, a)
#    print('----')
    if a == 'Y':
        if s == '>=':
            mini = max(mini,n)
        elif s == '>':
            mini = max(mini,n + 1)
        elif s == '<=':
            maxi = min(maxi, n)
        elif s == '<':
            maxi = min(maxi, n - 1)
    else:
        if s == '>=':
            maxi = min(maxi, n-1)
        elif s == '>':
            maxi = min(maxi, n)
        elif s == '<=':
            mini = max(mini, n+1)
        elif s == '<':
            mini = max(mini, n)

#    print(mini, maxi, '\n--------')

if maxi >= mini:
    print(mini)
else:
    print('Impossible')


l, r = -2000000000, 2000000000
for x in range(int(input())):
    t, n, a = input().split()
    if t[0] == '>':
        n = int(n) + (len(t) == 1)
        if a == 'Y':
            l = max(l, n)
        else:
            r = min(r, n - 1)
    else:
        n = int(n) - (len(t) == 1)
        if a == 'Y':
            r = min(r, n)
        else:
            l = max(l, n + 1)
   ## print(l, r)
if l <= r:
    print((l + r) // 2)
else:
    print('Impossible')


n = int(input())
mn = -2000000000
mx = 2000000000
for i in range(n):
  (sign, ber, ans) = input().split()
  num = int(ber)
  if ans == 'N':
    if sign == '<':
      sign = '>='
    elif sign == '<=':
      sign = '>'
    elif sign == '>':
      sign = '<='
    elif sign == '>=':
      sign = '<'
  if sign == '<':
    sign = '<='
    num -= 1
  if sign == '>':
    sign = '>='
    num += 1
  if sign == '<=':
    mx = min(mx, num)
  else:
    mn = max(mn, num)
if mx < mn:
  print('Impossible')
else:
  print(mn)

n = int(input())
left = None
right = None
for i in range(n):
    st = input()
    op, num, ans = st.split(' ')
    num = int(num)
    if ans == 'N':
        if op == '>=':
            op = '<'
        elif op == '>':
            op = '<='
        elif op == '<=':
            op = '>'
        else:
            op = '>='
    if op == '>=':
        if left == None:
            left = num
        else:
            left = max(left, num)
    elif op == '>':
        if left == None:
            left = num+1
        else:
            left = max(left, num+1)
    elif op == '<=':
        if right == None:
            right = num
        else:
            right = min(right, num)
    else: # op == '<'
        if right == None:
            right = num-1
        else:
            right = min(right, num-1)
if left == None and right == None:
    print(0)
elif left == None:
    print(right)
elif right == None:
    print(left)
elif left > right:
    print('Impossible')
else:
    print(left)
    


n=int(input())
a=-2*10**9
b=2*10**9
for i in range(n):
    s=input().split()
    x=int(s[1])
    ans=str(s[2])
    s=s[0]
    if(s==">="):
        if(ans=="Y"):
            a=max(a,x)
        else:
            b=min(b,x-1)
    elif(s=="<="):
        if(ans=="Y"):
            b=min(b,x)
        else:
            a=max(a,x+1)
    elif(s=="<"):
        if(ans=="Y"):
            b=min(b,x-1)
        else:
            a=max(x,a)
    elif(s==">"):
        if(ans=="Y"):
            a=max(a,x+1)
        else:
            b=min(x,b)
if(b<a):
    print("Impossible")
else:
        
    print(b)


__author__ = 'Lipen'

def ModeReverse(mode):
    if mode=='>':
        return '<='
    elif mode=='<':
        return '>='
    elif mode=='>=':
        return '<'
    elif mode=='<=':
        return '>'

def main():
    n = int(input())
    ymin = -2000000000
    ymax = 2000000000

    for i in range(n):
        mode, x, ans = input().split()
        x = int(x)

        if ans=='N':
            mode = ModeReverse(mode)

        if mode=='>':
            ymin = max(ymin, x+1)
        elif mode=='<':
            ymax = min(ymax, x-1)
        elif mode=='>=':
            ymin = max(ymin, x)
        elif mode=='<=':
            ymax = min(ymax, x)

    if ymin>ymax:
        print('Impossible')
    else:
        print(ymin)

main()

u, v = -2000000000, 2000000000
for i in range(int(input())):
    a, b, c = input().split()
    k = int(b)
    if a == '>=':
        if c == 'Y': u = max(u, k)
        else: v = min(v, k - 1)
    elif a == '>':
        if c == 'Y': u = max(u, k + 1)
        else: v = min(v, k)
    elif a == '<=':
        if c == 'Y': v = min(v, k)
        else: u = max(u, k + 1)
    else:
        if c == 'Y': v = min(v, k - 1)
        else: u = max(u, k)
print('Impossible' if u > v else u)

import sys

queries = int( sys.stdin.readline() )

opp = { '>': '<=', 
        '>=': '<',
        '<': '>=',
        '<=': '>' }

lower = -2000000000
upper = 2000000000

for i in range(queries):
  oper, num, judge = sys.stdin.readline().rstrip().split(' ')
  if judge == 'N':
    oper = opp[oper]
    
  if oper == '>':
    lower = max(int(num) + 1, lower)
  elif oper == '>=':
    lower = max(int(num), lower)
  elif oper == '<':
    upper = min(int(num) - 1, upper)
  elif oper == '<=':
    upper = min(int(num), upper)
  #print(str(lower) + " " + str(upper))
  if(lower > upper):
    break
    
if(lower > upper):
  print ("Impossible")
else:
  print(lower)

n = int(input())
l = -2*10**9
r = 2*10**9
for i in range(n):
    s = input().split()
    x = int(s[1])
    if s[-1] == 'N':
        if s[0] == '<':
            s[0] = '>='
        elif s[0] == '<=':
            s[0] = '>'
        elif s[0] == '>':
            s[0] = '<='
        elif s[0] == '>=':
            s[0] = '<'
    if s[0] == '<':
        r = min(r, x - 1)
    elif s[0] == '<=':
        r = min(r, x)
    elif s[0] == '>':
        l = max(l, x + 1)
    elif s[0] == '>=':
        l = max(l, x)
if l > r:
    print('Impossible')
else:
    print(l)
        


def inverse( str ):
   val = ""
   if(str == ">"):
      val =  "<="
   elif(str == "<"):
      val = ">="
   elif(str == ">="):
      val = "<"
   else:
      val = ">"
   return val 


min_ = -2000000000
max_ = 2000000000
n = int(input())#tipo por defecto es cadena
for i in range(n):  
   sign, num, yn = input().split() 
   num = int(num) 
   if (yn == "N"):          
     sign = inverse(sign)  
   if(sign == "<="):   
      max_ = min(max_, num)   
   elif(sign == "<"):
      max_ = min(max_, num - 1)   
   elif(sign == ">="):
      min_ = max(min_, num)   
   else:
      min_ = max(min_, num + 1)  
if(min_ <= max_):
   print(min_)
else:
   print("Impossible")


def inverse( str ):
   val = ""
   if(str == ">"):
      val =  "<="
   elif(str == "<"):
      val = ">="
   elif(str == ">="):
      val = "<"
   else:
      val = ">"
   return val 


min_ = -2000000000
max_ = 2000000000
n = int(input())#tipo por defecto es cadena
for i in range(n):  
   sign, num, yn = input().split() 
   num = int(num) #se puede modificar o es inmutable
   if (yn == "N"):          
     sign = inverse(sign)  
   if(sign == "<="):   
      max_ = min(max_, num)   
   elif(sign == "<"):
      max_ = min(max_, num - 1)   
   elif(sign == ">="):
      min_ = max(min_, num)   
   else:
      min_ = max(min_, num + 1)  
if(min_ <= max_):
   print(min_)
else:
   print("Impossible")


def inverse( str ): #funciones que no sono clase no son miembros de clase no usan self
   val = ""
   if(str == ">"):
      val =  "<="
   elif(str == "<"):
      val = ">="
   elif(str == ">="):
      val = "<"
   else:
      val = ">"
   return val 


min_ = -2000000000
max_ = 2000000000
n = int(input())#tipo por defecto es cadena
for i in range(n):  
   sign, num, yn = input().split() 
   num = int(num) #se puede modificar o es inmutable
   if (yn == "N"):          
     sign = inverse(sign)  
   if(sign == "<="):   
      max_ = min(max_, num)   
   elif(sign == "<"):
      max_ = min(max_, num - 1)   
   elif(sign == ">="):
      min_ = max(min_, num)   
   else:
      min_ = max(min_, num + 1)  
if(min_ <= max_):
   print(min_)
else:
   print("Impossible")


n = int(input())
mn = -2000000000
mx = 2000000000
for i in range(n):
    znak, m, ans = list(map(str, input().split()))
    if znak == '>':
        if ans == 'Y':
            mn = max(mn, int(m) + 1)
        else:
            mx = min(mx, int(m))
    if znak == '<':
        if ans == 'Y':
            mx = min(mx, int(m) - 1)
        else:
            mn = max(mn, int(m))
    if znak == '>=':
        if ans == 'Y':
            mn = max(mn, int(m))
        else:
            mx = min(mx, int(m) - 1)
    if znak == '<=':
        if ans == 'Y':
            mx = min(mx, int(m))
        else:
            mn = max(mn, int(m) + 1)
if mx < mn:
    print("Impossible")
else:
    print((mx + mn) // 2)
            


d = {
     '> Y':  (0,  1, max),
     '>= Y': (0,  0, max),
     '< N':  (0,  0, max),
     '<= N': (0,  1, max),
     '< Y':  (1, -1, min),
     '<= Y': (1,  0, min),
     '> N':  (1,  0, min),
     '>= N': (1, -1, min),
}
ran = [-2000000000, 2000000000]

def analyse(s):
    ls = s.split(' ')
    op = d.get(' '.join((ls[0], ls[2])))
    ran[op[0]] = op[2](int(ls[1]) + op[1], ran[op[0]])


n = int(input())
for i in range(n):
    s = input()
    if ran[0] <= ran[1]:
        analyse(s)

if ran[0] <= ran[1]:
    print(ran[0])
else:
    print('Impossible')


d = {
     '> Y':  (0,  1, max),
     '>= Y': (0,  0, max),
     '< N':  (0,  0, max),
     '<= N': (0,  1, max),
     '< Y':  (1, -1, min),
     '<= Y': (1,  0, min),
     '> N':  (1,  0, min),
     '>= N': (1, -1, min),
}
ran = [-2000000000, 2000000000]
possible = True
def analyse(s):
    ls = s.split(' ')
    op = d.get(' '.join((ls[0], ls[2])))
    ran[op[0]] = op[2](int(ls[1]) + op[1], ran[op[0]])


n = int(input())
for i in range(n):
    s = input()
    if possible:
        analyse(s)
        if ran[0] > ran[1]:
            possible = False

if possible:
    print(ran[0])
else:
    print('Impossible')


n=int(input())
left = - 10**9 - 5
right = 10**9 + 5
for i in range(n):
    op,x,ans = input().split()
    x=int(x)
    if op == '>' and ans == 'Y':
        left = max(x+1,left)
    elif op == '>':
        right = min(x,right)
        
    if op == '<' and ans == 'Y':
        right = min(x-1,right)
    elif op == '<':
        left = max(x,left)
        
    if op == '>=' and ans == 'Y':
        left = max(x,left)
    elif op == '>=':
        right = min(x-1,right)
        
    if op == '<=' and ans == 'Y':
        right = min(x,right)
    elif op == '<=':
        left = max(x+1,left)
if right<left:
    print('Impossible')
else:
    print(left)

T=int(input())
l=-2000000001
r=2000000001
while T>0:
    T-=1
    A,B,C=input().split()
    b=int(B)
    if C=='N':
        if A=='>=':
            A='<'
        elif A=='<=':
            A='>'
        elif A=='>':
            A='<='
        else:
            A='>='
    if A=='>=':
        b-=1
    if A=='<=':
        b+=1
    if A[0]=='>':
        l=max(l,b)
    else:
        r=min(r,b)
if l+1>=r:
    print('Impossible')
else:
    print(l+1)