Harryxun/stf_run huggingface dataset:
N = int(input())

for i in range(0, N):
    if int(input())% 2 == 0:
        cnt = cnt + 1
if cnt % 2 == 0:
    print('first')
else:
    print('second')

### FIXED CODE ###

N = int(input())
cnt = 0
for i in range(0, N):
    if int(input()) % 2 == 1:
        cnt = cnt + 1

if cnt > 0:
    print('first')
else:
    print('second')
n = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))

from itertools import permutations

lst = permutations(range(1,n+1))
lst.sort()
print(abs(lst.index(P) - lst.index(Q)))

### FIXED CODE ###

n = int(input())
p = ''.join(input().split())
q = ''.join(input().split())

from itertools import permutations

all = list(permutations(list(map(str,range(1,n+1))), n))
all = list(map(lambda x: ''.join(x), all))
all.sort()
print(abs(all.index(p) - all.index(q)))
N = int(input())
A = list(map(int, input().split()))
m1 = max(A)
m2 = m // 2 + int(m % 2 == 1)
ans = [m1, m2]
tmp = 10000000

for a in A:
    if tmp > abs(m2 - a):
        tmp = abs(m2 - a)
        ans[1] = a

print(*ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort()
m1 = A[-1]
m2 = m1 // 2 + int(m1 % 2 == 1)
ans = [m1, 0]
tmp = 10**9 + 1

for a in A[:len(A) - 1]:
    if tmp > abs(m2 - a):
        tmp = abs(m2 - a)
        ans[1] = a

print(*ans)
n = int(input())
a = list(map(int,input().split()))
b = sorted(a)
aj = [a[0]]
for i in range(1,n-1):
    if a.index(b[i]) < n/2:
        aj += [b[i]]
    else:
        aj = [b[i]]+aj
if aj[0] == b[n-1]:
    aj += [b[n]]
else:
    aj = [b[n]]+aj

ans = 0
for i in range(n):


print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = 0
place = [0]*n
active = sorted(a,reverse=True)
for i in range(n):
    place[i] = a.index(active[i])
    a[a.index(active[i])] = -1

#dp[x][y] x,y:0~n+1 (x[-1]=x[n+1]=0にすることで端の処理を楽にする)
dp = [[0 for i in range(n+2)]for j in range(n+2)]

for i in range(n):
    dp[0][i+1] = dp[0][i]+active[i]*abs(n-i-1-place[i])
    dp[i+1][0] = dp[i][0]+active[i]*abs(place[i]-i)



def check(mat):
    for i in range(len(mat)):
        print(mat[i])
    print("\n")


for i in range(n):
    for x in range(i+2):
        y = i+1 - x
        if x != 0 and y != 0:
            dp[x][y] = max(dp[x-1][y]+active[i]*abs(place[i]-x+1),dp[x][y-1]+active[i]*abs(n-y-place[i]))
            if i == n-1:
                ans = max(ans,dp[x][y])

print(ans)
n = int(input())
x = 0
for i in range(1, n):
  x = ((10 * x) + 7)%n
  if x == 0:
    print(i)
    return
  
print(-1)
  

### FIXED CODE ###

n = int(input())
x, found = 0, False
for i in range(1, n + 1):
  x = ((10 * x) + 7)%n
  if x == 0:
    print(i)
    found = True
    break

if not found:
  print(-1)
wakarimasendesitaaaaaaaaaaaa
AAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAA!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

### FIXED CODE ###

#  D -Lamp
h,w=map(int,input().split())
g=[input() for i in range(h)]
l=[[0]*w for i in range(h)]
r=[[0]*w for i in range(h)]
u=[[0]*w for i in range(h)]
o=[[0]*w for i in range(h)]

for i in range(h):
    if g[i][0]=='.':
        l[i][0]=1

for i in range(h):
    for j in range(w-1):
        if g[i][j+1]=='.':
            l[i][j+1]=l[i][j]+1
        elif g[i][j+1]=='#':
            l[i][j+1]=0

for i in range(h):
    if g[i][w-1]=='.':
        r[i][w-1]=1

for i in range(h):
    for j in range(w-1,0,-1):
        if g[i][j-1]=='.':
            r[i][j-1]=r[i][j]+1
        elif g[i][j-1]=='#':
            r[i][j-1]=0

for i in range(w):
    if g[0][i]=='.':
        u[0][i]=1

for i in range(w):
    for j in range(h-1):
        if g[j+1][i]=='.':
            u[j+1][i]=u[j][i]+1
        elif g[j+1][i]=='#':
            u[j+1][i]=0

for i in range(w):
    if g[h-1][i]=='.':
        o[h-1][i]=1

for i in range(w):
    for j in range(h-1,0,-1):
        if g[j-1][i]=='.':
            o[j-1][i]=o[j][i]+1
        elif g[j-1][i]=='#':
            o[j-1][i]=0

ans=0
for i in range(h):
    for j in range(w):
        ans=max(ans,l[i][j]+r[i][j]+u[i][j]+o[i][j]-3)

print(ans)
def main():
    N = int(input())
    H = [int(x) for x in input().split()]
    ans = []
    for i in range(N - 1):
        count = 0
        for k in range(i, N - 1):
            if H[k] >= H[k + 1]:
                count += 1
                if k + 1 == N - 1:
                    ans.append(count)
                    break
            else:
                ans.append(count)
                break
    print(max(ans))


if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    N = int(input())
    H = [int(x) for x in input().split()]
    ans = 0
    count = 0

    if N == 2:
        if H[0] >= H[1]:
            ans = 1
    elif N > 2:
        for i in range(1, N):
            j = i + 1
            if H[-i] <= H[-j]:
                count += 1
                if j == N:
                    if ans <= count:
                        ans = count
            else:
                if ans <= count:
                    ans = count
                count = 0
    print(ans)


if __name__ == "__main__":
    main()
N, Q = [int(x) for x in input().split()]
ab_list = [[int(x) for x in input().split()] for _ in range(N-1)]
px_list = [[int(x) for x in input().split()] for _ in range(Q)]
to = [[] for _ in range(N+1)]
for a, b in ab_list:
    a -= 1
    b -= 1
    to[b].append(a)
    to[a].append(b)
ans = [0] * N
for p, x in px_list:
    ans[p-1] += x

def dfs(v, p=-1):
    for u in to[v]:
        if (u == p): continue
        ans[u] += ans[v]
        dfs(u, v)        
dfs(0)
print(' '.join([str(i) for i in ans]))


### FIXED CODE ###

N, Q = [int(x) for x in input().split()]
to = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = [int(x)-1 for x in input().split()]
    to[b].append(a)
    to[a].append(b)
ans = [0] * N
for _ in range(Q):
    p, x = [int(x) for x in input().split()]
    p -= 1
    ans[p] += x

from collections import deque
q = deque()
q.append(0)
visited = [0] * N

while(q):
    v = q.pop()
    visited[v] = 1    
    for u in to[v]:
        if visited[u] == 1: continue
        ans[u] += ans[v]
        q.append(u)
print(' '.join([str(i) for i in ans]))
N = int(input())
S = str(input())
V = 'abcdefghijklmnopqrstuvwzyz'
Lavida = [1]*26
for i in range (0, N):
	Lavida[V.index(S[i])]+=1

count = 1
for i in range (0, 26):
	count*=Lavida[i]
	count=count%(10**9+7)

print((count-1)%(10**9+7))

### FIXED CODE ###

N = int(input())
S = str(input())
V = 'abcdefghijklmnopqrstuvwxyz'
Lavida = [1]*26
for i in range (0, N):
	Lavida[V.index(S[i])]+=1

count = 1
for i in range (0, 26):
	count*=Lavida[i]
	count=count%(10**9+7)

print((count-1)%(10**9+7))
n, m = map(int, input().split())
a = []
for _ in range(m):
    a.append(int(input()))


def count_steps(NN):

    steps = [0] * (NN + 3)
    steps[1] = 1
    steps[2] = 2
    for i in range(3, NN + 1):
        steps[i] = steps[i - 1] + steps[i - 2]
    return steps[NN]

if a[0] == 1:
    ans = 1
else:
    ans = count_steps(a[0]-1)

for i in range(1, len(a)):
    temp = a[i]-a[i-1]-2
    if temp < 0:
        ans = 0
    elif temp==0:
        ans *= 1
    else:
        ans *= count_steps(temp)

temp = n-a[-1]-1
if temp>0:
    ans *= count_steps(temp)
print(ans%1000000007)

### FIXED CODE ###

n, m = map(int, input().split())
a = []
for _ in range(m):
    a.append(int(input()))


def count_steps(NN):

    steps = [0] * (NN + 3)
    steps[1] = 1
    steps[2] = 2
    for i in range(3, NN + 1):
        steps[i] = steps[i - 1] + steps[i - 2]
    return steps[NN]

if m == 0:
    ans = count_steps(n)
else:
    if a[0] == 1:
        ans = 1
    else:
        ans = count_steps(a[0] - 1)

    for i in range(1, len(a)):
        temp = a[i] - a[i - 1] - 2
        if temp < 0:
            ans = 0
        elif temp == 0:
            ans *= 1
        else:
            ans *= count_steps(temp)

    temp = n - a[-1] - 1
    if temp > 0:
        ans *= count_steps(temp)
print(ans%1000000007)
N,T = map(int,input().split())
ans = [c for c,t in sorted([(input().split()) for i in range(N)],key=lambda x :x[1]) if int(t)<=T][-1]
if len(ans)!=0:
    print(ans)
else:
    print("TLE")

### FIXED CODE ###

N,T = map(int,input().split())
ans = [int(c) for c,t in [(input().split()) for i in range(N)] if int(t)<=T]
if len(ans)!=0:
    print(min(ans))
else:
    print("TLE")
#coding: utf-8

a, b = (int(i) for i in input().split())

print(int(a / b) , end = ' ')
print(a % b , end = ' ')
print("{: 0<7.5}".format(float(a) / float(b)))


### FIXED CODE ###

#coding: utf-8

a, b = (int(i) for i in input().split())

print(int(a / b) , end = ' ')
print(a % b , end = ' ')
print(format(float(a) / float(b), ".7f"))
N = int(input())
table = [[int(t) for i in input().split()] for n in range(N)]
can = True
for i in range(N):
    if(i != 0):
        dt = table[i][0] - table[i-1][0]
        dist = abs(table[i][1]-table[i-1][1]) +abs(table[i][2]-table[i-1][2])
    else:
        dt = table[i][0]
        dist = abs(table[0][1]) + abs(table[0][2])
    if(dist > dt):
        can = False
        break
    elif((dt-dist)%2 != 0):
        can = False
        break
if(can == True):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

N = int(input())
table = [[int(i) for i in input().split()] for n in range(N)]
can = True
for i in range(N):
    if(i != 0):
        dt = table[i][0] - table[i-1][0]
        dist = abs(table[i][1]-table[i-1][1]) +abs(table[i][2]-table[i-1][2])
    else:
        dt = table[i][0]
        dist = abs(table[0][1]) + abs(table[0][2])
    if(dist > dt):
        can = False
        break
    elif((dt-dist)%2 != 0):
        can = False
        break
if(can == True):
    print("Yes")
else:
    print("No")
A, op, B = map(int, input().split())
if op == '+':
    print(A + B)
else:
    print(A - B)

### FIXED CODE ###

A, op, B = input().split()
if op == '+':
    print(int(A) + int(B))
else:
    print(int(A) - int(B))
N = int(input())
for B in range(9) :
  for A in N :
  if A / B < 10 and A % B =0 :
    print("Yes")
    
else :
  print("No")
    

### FIXED CODE ###

N = int(input())
number = []
for a in range(1,10):
    for b in range(1,10):
        number.append(b*a)
if N in number :
    print("Yes")
else :
    print("No")
import numpy as np
N = int(input())
a_s = input().split()
for i in range(N):
    a_s[i] = int(a_s[i])
a_s = np.array(a_s)

a_unique = np.unique(a_s)
# a_counts = []
# for i,a in enumerate(a_unique):
#     a_counts.append(np.sum(a_s==a))
# a_counts = np.array(a_counts)

ans = 0
for i in range(len(a_unique)):
    val = np.sum(a_s==a_unique[i] #a_counts[i]
    if (i>0):
        if (a_unique[i-1]+1==a_unique[i]):
            val += np.sum(a_s==a_unique[i-1]) #a_counts[i-1]
            
    if (i<len(a_unique)-1):
        if (a_unique[i+1]-1==a_unique[i]):
            val += np.sum(a_s==a_unique[i+1]) #a_counts[i+1]
    
    if val > ans:
        ans = val
        
#     if ans >= sum(a_counts[i:]):
#         break
        
print(ans)

### FIXED CODE ###

from collections import Counter

N = int(input())
a_s = input().split()
a_s = [int(a_s[i]) for i in range(N)]

c = Counter(a_s)
c = sorted(c.items(), key=lambda x:x[0])
a_unique, a_counts = zip(*c)

ans = 0
for i,a in enumerate(a_unique):
    val = a_counts[i]
    if (i>0):
        if (a_unique[i-1]+1==a):
            val += a_counts[i-1]
            
    if (i<len(a_unique)-1):
        if (a_unique[i+1]-1==a):
            val += a_counts[i+1]
    
    if val > ans:
        ans = val
        
print(ans)
x1,y1,x2,y2 = map(int,input().split())
x3 = y1 - y2
y3 = abs(x1 - x2)
x4 = abs(y2 - y3)
y4 = abs(x2 - x3)
print(x3,y3,x4,y4)

### FIXED CODE ###

# -*- coding: utf-8 -*-
K = int(input())
if K % 2 == 0:
  print((K//2)*(K//2))
elif K % 2 == 1:
  print(((K+1)//2)*((K-1)//2))
if __name__ == '__main__':
    n, m = tuple([int(s) for s in input().split()])
    digits = [None] * m
    failed = False

    for i in range(m):
        si, ci = tuple([int(s) for s in input().split()])

        if si == 1 and ci == 0:
            print(-1)
            failed = True
            break

        if digits[si - 1] is not None and digits[si - 1] != ci:
            print(-1)
            failed = True
            break
        else:
            digits[si - 1] = ci

    if not failed:
        i = 0

        while digits[i] is None and len(digits[i:]) > n:
            i += 1

        if len(digits[i:]) > n:
            print(-1)
        else:
            digits = digits[i:]
            if digits[0] is None:
                digits[0] = 1
            for j in range(len(digits)):
                if digits[j] is None:
                    digits[j] = 0

            print("".join(["{}".format(d) for d in digits]))


### FIXED CODE ###

if __name__ == '__main__':
    n, m = tuple([int(s) for s in input().split()])
    digits = [None] * 3
    failed = False

    for i in range(m):
        si, ci = tuple([int(s) for s in input().split()])

        if si > n:
            print(-1)
            failed = True
            break
        elif digits[n - si] is not None and digits[n - si] != ci:
            print(-1)
            failed = True
            break
        else:
            digits[n - si] = ci

    if not failed:
        if digits[-1] == 0 and n > 1:
            print(-1)
        else:
            digits = digits[:n]
            digits.reverse()
            if digits[0] is None and n > 1:
                digits[0] = 1
            for j in range(len(digits)):
                if digits[j] is None:
                    digits[j] = 0

            print("".join(["{}".format(d) for d in digits]))
n,m=map(int,input().split())
a=[-1]
d=[]
for i in range(m):
 a.append(int(input()))
a.append(n+1)
for i in range(m+1):
 d.append(a[i+1]-a[i]-1)
ansk=1
for i in range(m+1):
 k=int(((1+5**(1/2)/2)**d[i]-(1-5**(1/2)/2)**d[i])/(5**1/2))
 ansk*=k
print(ansk%1000000007)


### FIXED CODE ###

def Fib(n):
    a=[0,1,1]
    if n<=2:
    	return a[n]
    else:
    	for i in range(n-2):
    		a.append(a[i+1]+a[i+2])
    	return a[n]
n,m=map(int,input().split())
if m==0:
	print(Fib(n+1)%(10**9+7))
	exit()
a=[]
for i in range(m):
	a.append(int(input()))
if a[0]!=1:
	a.insert(0,-1)
if a[-1]!=n-1:
	a.append(n+1)
b=[]
for i in range(len(a)-1):
	b.append(a[i+1]-a[i]-1)
	if a[i+1]-a[i]==1:
		print(0)
		exit()
ans=1
for i in range(len(b)):
	ans*=Fib(b[i])
	ans%=10**9+7
print(ans)
import math

str=input()
n,k=int(str.split()[0]),int(str.split()[1])

def place(n,x):
    if n==1:
        return 1
    ans=1
    if n-1 < x:
        for i in range(x+1,n+x):
            ans*=i
        ans//=math.factorial(n-1)
    else:
        for i in range(n, n+x):
            ans*=i
        ans//=math.factorial(x)
    return ans%1000000007


for i in range (1,k+1):
    if i > (n+1)//2:
        print(0)
    else:
        cb=place(  i,  k-i  )
        cr=place(i+1,n-k-i+1)
        cr=cr%1000000007
        print(cb*cr%1000000007)



### FIXED CODE ###

import math

str=input()
n,k=int(str.split()[0]),int(str.split()[1])

def place(n,x):
    if n==1:
        return 1
    ans=1
    if n-1 < x:
        for i in range(x+1,n+x):
            ans*=i
        ans//=math.factorial(n-1)
    else:
        for i in range(n, n+x):
            ans*=i
        ans//=math.factorial(x)
    return ans%1000000007


for i in range (1,k+1):
    if n-k < i-1:
        print(0)
    else:
        cb=place(  i,  k-i  )
        cr=place(i+1,n-k-i+1)
        cr=cr%1000000007
        print(cb*cr%1000000007)
#11
n = int(input())
a = list(map(int, input().split()))

import math

flag = [a.count(a[i])-1 for i in range(n+1) ]

cc = [ math.factorial(n+1)/math.factorial(i+1)/math.factorial(n-i) for i in range( n//2 )]
cc + list(reversed(cc)) +[1]

for i in range(n+1):
    p = flag.index(1) + list(reversed(flag)).index(1)
    
    if ( p>=i ):
        c = cc[i] - math.factorial(p)/math.factorial(i)/math.factorial(p-i)
    else:
        c = cc[i]
    print( int(c)%(10**9+7) )

### FIXED CODE ###


MOD = 10**9+7
n = int(input())
la = list(map(int,input().split()))
L = [-1]*(n+1)
l = 0
for i in range(n+1):
  a = la[i]
  if L[a] == -1:
    L[a] = i
  else:
    l = i - L[a] - 1
    break
 
MAX = n
factorial = [1, 1]
inverse = [0, 1]
inverse_factorial = [1, 1]
for i in range(2,MAX+1):
  factorial.append( (factorial[-1]*i)%MOD )
  inverse.append( (-inverse[MOD%i]*(MOD//i))%MOD )
  inverse_factorial.append( (inverse_factorial[-1]*inverse[-1])%MOD )
 
def C_MOD(n, k):
  if k < 0 or k > n:
    return 0
  k = min(k,n-k)
  return factorial[n] * inverse_factorial[k] * inverse_factorial[n-k] % MOD
 
print(n)
#print((2*C_MOD(n-1,1)-C_MOD(n-1-l,1)+C_MOD(n-1,2)+1)%MOD)
for i in range(2,n+1):
  if n > l+1:
    print((2*C_MOD(n-1,i-1)-C_MOD(n-1-l,i-1)+C_MOD(n-1,i)+C_MOD(n-1,i-2))%MOD)
  else:
    print((2*C_MOD(n-1,i-1)+C_MOD(n-1,i)+C_MOD(n-1,i-2))%MOD)
print(1)
S=input()
if S==SUN:
  print('7')
elif S==MON:
  print('6')
elif S==TUE:
  print('5')
elif S==WED:
  print('4')
elif S==THU:
  print('3')
elif S==FRI:
  print('2')
else:
  print('1')

### FIXED CODE ###

S=input()
if S=='SUN':
  print('7')
elif S=='MON':
  print('6')
elif S=='TUE':
  print('5')
elif S=='WED':
  print('4')
elif S=='THU':
  print('3')
elif S=='FRI':
  print('2')
else:
  print('1')
import heapq
n,m=map(int,input().split())
a=heapq.heapify(list(map(lambda x: int(x)*(-1),input().split())))
while m>0 and sum(a)>0:
  heapq.heappush(a,int(heapq.heappop(a)//2))
  m=m-1
a=list(map(lambda x: int(x)*(-1),a))
print(sum(a))


### FIXED CODE ###

import heapq
n,m=map(int,input().split())
a=list(map(lambda x: int(x)*(-1),input().split()))
heapq.heapify(a)
while m>0:
  heapq.heappush(a,(-1)*int((-1)*heapq.heappop(a)//2))
  m=m-1

print(-sum(a))
n=int(input())
a=[int(input()) for i in range(n)]
max1 = 0
max1_ind = 0
max2 = 0
max2_ind = 0
 
for i in range(n):
    if max2 =< a[i]:
        if max1 =< a[i]:
            max1 = a[i]
            max1_ind = i
            max2 = max1
            max2_ind = max1_ind
        else:
            max2 = a[i]
            max2_ind = i
    
for j in range(n):
    if j == max1_ind:
        print(max2)
    else:
        print(max1)

### FIXED CODE ###

n=int(input())
a=[int(input()) for i in range(n)]

max1 = 0
max1_ind = 0
max2 = 0
max2_ind = 0
 
for i in range(n):
    if max2 <= a[i]:
        if max1 <= a[i]:
            max2 = max1
            max2_ind = max1_ind
            max1 = a[i]
            max1_ind = i
            
        else:
            max2 = a[i]
            max2_ind = i
    
for j in range(n):
    if j == max1_ind:
        print(max2)
    else:
        print(max1)
a = list(map(int, input().split())
if sum(a)>=22:
    print(bust)
else:
    print(win)

### FIXED CODE ###

a = list(map(int, input().split()))
if sum(a)>=22:
    print("bust")
else:
    print("win")
n, m, c = map(int, input().split())
b = map(int, input().split())
count = 0
 
for i in range(n):
  a = map(int, input().split())
  for j in range(m):
    if 0 < a[j] * b[j] + c:
      count += 1
print(count)

### FIXED CODE ###

n, m, c = map(int, input().split())
b = list(map(int, input().split()))
count = 0
 
for i in range(n):
  a = list(map(int, input().split()))
  p = c
  for j in range(m):
  	p += a[j] * b[j]
  if 0 < p:
    count += 1
print(count)
def bitsum(bit,i):
    s = 0
    while i > 0:
        s += bit[i]
        i -= i&(-i)
    return s
    
def bitadd(bit,i,x):
    n = len(bit)
    while i <= n:
        bit[i] += x
        i += i&(-i)
    return bit

mod = 998244353

N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]
xy.sort(key=lambda x:x[1])
for i in range(N):
    xy[i][1] = i+1
xy.sort()
for i in range(N):
    xy[i][0] = i

# x<xi,y<yi
l1 = [0]*N
# x<xi,y>yi
l2 = [0]*N
# x>xi,y<yi
r1 = [0]*N
# x>xi,y>yi
r2 = [0]*N

bitl = [0]*(N+1)
for i in range(N):
    l1[i] = bitsum(bitl,xy[i][1])
    l2[i] = i-l1[i]
    bitadd(bitl,xy[i][1],1)

bitr = [0]*(N+1)
for i in range(N):
    r1[N-i-1] = bitsum(bitr,xy[N-i-1][1])
    r2[N-i-1] = i-r1[N-i-1]
    bitadd(bitr,xy[N-i-1][1],1)

ans = pow(2,N-1,mod)*N%mod
for i in range(N):
    L1 = pow(2,l1[i],mod)
    L2 = pow(2,l2[i],mod)
    R1 = pow(2,r1[i],mod)
    R2 = pow(2,r2[i],mod)
    ans += L1*L2%mod*R1%mod*R2%mod
    ans -= L1*R1%mod
    ans -= L2*R2%mod
    ans -= L1*L2%mod
    ans -= R1*R2%mod
    ans += L1+L2+R1+R2-1
    ans %= mod

print(ans)

### FIXED CODE ###

from operator import itemgetter

class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

mod = 998244353

N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]
xy.sort(key=itemgetter(1))
for i in range(N):
    xy[i][1] = i+1
xy.sort(key=itemgetter(0))

pow2 = [1]*(N+1)
for i in range(N):
    pow2[i+1] = 2*pow2[i]%mod

ans = pow2[N-1]*N%mod

bit = BIT(N)
for i in range(N):
    l1 = bit.sum(xy[i][1])
    l2 = i-l1
    r1 = xy[i][1]-l1-1
    r2 = N-xy[i][1]-l2
    bit.add(xy[i][1],1)
    ans += (pow2[l2]-1)*(pow2[r1]-1)*pow2[r2]*pow2[l1]
    ans += (pow2[r2]-1)*(pow2[l1]-1)*(pow2[l2]+pow2[r1]-1)
    ans %= mod

print(ans)
import copy

s = input()

def value(s, adding_list):
    insert_index = []
    for index in range(len(adding_list)):
        if adding_list[index]:
            insert_index.append(index)

    if len(insert_index) == 0:
        return int(s)

    value_list = []

    for index in range(len(insert_index)):
        if index == 0:
            value_list.append(s[0:insert_index[index]+1])
        if index < len(insert_index)-1:
            value_list.append(s[(insert_index[index]+1) : insert_index[index+1]+1])

        if index == len(insert_index)-1:
            value_list.append(s[insert_index[index]+1:])

    ret_val = 0
    for value in value_list:
        ret_val += int(value)

    return ret_val

def dfs(adding_list, changing_index):
    print(changing_index)
    sum = 0
    if changing_index == len(s)-2:
        return value(s, adding_list)
    else:
        changing_index += 1
        new_adding_list = copy.copy(adding_list)
        sum += dfs(new_adding_list, changing_index)

        new_adding_list = copy.copy(adding_list)
        new_adding_list[changing_index] = True
        sum += dfs(new_adding_list, changing_index)
        return sum

def main():
    ret_val = 0
    plus_list = [False for _ in range(len(s)-1)]
    ret_val += dfs(plus_list, 0)

    plus_list = [False for _ in range(len(s)-1)]
    plus_list[0] = True
    ret_val += dfs(plus_list, 0)
    print(ret_val)

main()

### FIXED CODE ###

import copy

s = input()

def value(s, adding_list):
    insert_index = []
    for index in range(len(adding_list)):
        if adding_list[index]:
            insert_index.append(index)

    if len(insert_index) == 0:
        return int(s)

    value_list = []

    for index in range(len(insert_index)):
        if index == 0:
            value_list.append(s[0:insert_index[index]+1])
        if index < len(insert_index)-1:
            value_list.append(s[(insert_index[index]+1) : insert_index[index+1]+1])

        if index == len(insert_index)-1:
            value_list.append(s[insert_index[index]+1:])

    ret_val = 0
    for value in value_list:
        ret_val += int(value)

    return ret_val

def dfs(adding_list, changing_index):
    sum = 0
    if changing_index == len(s)-2:
        return value(s, adding_list)
    else:
        changing_index += 1
        new_adding_list = copy.copy(adding_list)
        sum += dfs(new_adding_list, changing_index)

        new_adding_list = copy.copy(adding_list)
        new_adding_list[changing_index] = True
        sum += dfs(new_adding_list, changing_index)
        return sum

def main():
    if len(s) > 1:
        ret_val = 0
        plus_list = [False for _ in range(len(s)-1)]
        ret_val += dfs(plus_list, 0)

        plus_list = [False for _ in range(len(s)-1)]
        plus_list[0] = True
        ret_val += dfs(plus_list, 0)
        print(ret_val)
    else:
        print(s)

main()
N=int(input())
L=[int(i) for i in input().split()]
M=max(L)
del L[M]
if M>=sum(L):
  print('No')
else:
  print('Yes')

### FIXED CODE ###

N=int(input())
L=[int(i) for i in input().split()]
M=max(L)
L.remove(M)
if M>=sum(L):
  print('No')
else:
  print('Yes')