Harryxun/stf_run huggingface dataset:
N, M = map(int, input().split())
s = [list(map(int,input().spllit()))[1:] for i in range(M)]
p = list(map(int,input().split()))
total = 0
j = 0
for i in range(2 ** N):
  lis = []
  for j in range(N):
    lis.append((i>>j) & 1)
  for k in range(M):
    tmp = 0
    for l in s[k]:
      tmp += lis[l-1]
      if tmp % 2 == p[k]:
        j += 1
  if j == M :
    total += 1
  j = 0
print(total)
        

### FIXED CODE ###

n, m = map(int, input().split())
switch = []
for i in range(m):
    switch.append(list(map(int, input().split())))
p = list(map(int, input().split()))

ans = 0
for i in range(2**n):
    i = format(i, "0{}b".format(n))
    flag = 1
    for j in range(m):
        count = 0
        for k in range(switch[j][0]):
            if i[switch[j][k+1]-1] == "1":
                count += 1
        if count % 2 == p[j]:
            continue
        else:
            flag = 0
            break
    if flag == 1:
        ans += 1
print(ans)
N = int(input())
es = [[] for i in range(N+1)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    es[u].append([v,w])
    es[v].append([u,w])
dfs_map = [1 for i in range(N+1)]
col = [None] * (N+1)
def dfs(v, c):
    col[v] = c
    for e in es[v]:
        if dfs_map[e[0]]:
            dfs_map[e[0]] = 0
            if e[1] % 2:
                dfs(e[0], c^1)
            else:
                dfs(e[0], c)
dfs_map[1] = 0
dfs(1, 0)
for i in range(1, N+1):
    print(col[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5+1)
N = int(input())
es = [[] for i in range(N+1)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    es[u].append([v,w])
    es[v].append([u,w])
dfs_map = [1 for i in range(N+1)]
col = [None] * (N+1)
def dfs(v, c):
    col[v] = c
    for e in es[v]:
        if dfs_map[e[0]]:
            dfs_map[e[0]] = 0
            if e[1] % 2:
                dfs(e[0], c^1)
            else:
                dfs(e[0], c)
dfs_map[1] = 0
dfs(1, 0)
for i in range(1, N+1):
    print(col[i])
s = input()

mod = 1000000007
length = len(s)
ans = list([0]*13 for i in range(length+1))
ans[0][0] = 1

for i in range(length):
    for j in range(13):
        x = j*10 % 13 - 1
        if s[i] == '?':
            for k in range(10):
                x = (x + 1) % 13
                ans[i+1][x] += ans[i][j]
        else:
            x = (x + int(s[i]) + 1) % 13
            ans[i+1][x] += ans[i][j]

print(ans[length][5] % mod)


### FIXED CODE ###

a,b = map(int,input().split())

if (a + b) % 2 == 0:
    print((a+b)//2)
else:
    print('IMPOSSIBLE')
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))
from collections import deque

MOD = pow(10, 9) + 7
ans = 1
n, k = map(int, input().split())
visited = [False for _ in range(n)]
edges = {}

def dfs(i, c1, c2):
  global ans
  if visited[i]:
    return
  visited[i] = True
  ans = ans * (k-c1-c2) % MOD
  c0 = 0
  for e in edges[i]:
    if not visited[e]:
      dfs(e, 1, c1+c0)
      c0 += 1


def main():
  for _ in range(n-1):
    a, b = map(int, input().split())
    if a-1 not in edges:
      edges[a-1] = [b-1]
    else:
      edges[a-1].append(b-1)
    if b-1 not in edges:
      edges[b-1] = [a-1]
    else:
      edges[b-1].append(a-1)
  # start
  for i in range(n):
    if len(edges[i]) == 1:
      dfs(i, 0, 0)
  print(ans)


if __name__ == '__main__':
  main()


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 7))

MOD = pow(10, 9) + 7
ans = 1
n, k = map(int, input().split())
visited = [False for _ in range(n)]
edges = {}

def dfs(i, c1, c2):
  global ans
  if visited[i]:
    return
  visited[i] = True
  ans = ans * (k-c1-c2) % MOD
  c0 = 0
  for e in edges[i]:
    if not visited[e]:
      dfs(e, 1, c1+c0)
      c0 += 1


def main():
  for _ in range(n-1):
    a, b = map(int, input().split())
    if a-1 not in edges:
      edges[a-1] = [b-1]
    else:
      edges[a-1].append(b-1)
    if b-1 not in edges:
      edges[b-1] = [a-1]
    else:
      edges[b-1].append(a-1)
  # start
  if n == 1:
    print(k)
  else:
    for i in range(n):
      if len(edges[i]) == 1:
        dfs(i, 0, 0)
    print(ans)


if __name__ == '__main__':
  main()
s=set(list(input()))
a=list('abcdefghijklmnopqrstuvwxyz')
b=set()
for i in range(26):
    b=b.append(str(a[i]))
if s==b:
    print('None')
else:
    print(b-s)


### FIXED CODE ###

s=set(list(input()))
a=set(list('abcdefghijklmnopqrstuvwxyz'))

if s==a:
    print('None')
else:
    b=sorted(list(a-s))
    print(str(b[0]))
def main()
  N=int(input())
  S=input()
  n=len(S)
  if n%2==0:
    if S[i]==S[n/2+i] for all(i in range(n/2)):
      print("Yes")
    else:
      print("No")
  else:
    print("No")
main()

### FIXED CODE ###

def main():
  N=int(input())
  S=input()
  n=len(S)
  T=S[0:n//2]
  if n%2==0:
    if S==T+T:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
main()
import sys
n,y = map(int, input().split())

for a in range(n+1):
	for b in range(n+1-a):
	  if a * 10000 + b * 5000 + (n-a-b) * 1000 == y:
		print(str(a) + ' ' + str(b) + ' ' + str(c))
		sys.exit()

print('-1 -1 -1')
sys.exit()

### FIXED CODE ###

import sys

n,y = map(int, input().split())

for a in range(n+1):
	for b in range(n+1-a):
		c = n - a - b
		if (a * 10000 + b * 5000 + c * 1000 == y):
				print(str(a) + ' ' + str(b) + ' ' + str(c))
				sys.exit()
	
print('-1 -1 -1')
sys.exit()
n,k = map(int, input())
lis = []
for i in range(1,N+1):
    count = 0
    while i < K:
        i *= 2
        count += 1
    lis.append(count)
result = 0
for i in lis:
    result += 1/n*0.5**i
print(result)

### FIXED CODE ###

n,k = map(int, input().split())
lis = []
for i in range(1,n+1):
    count = 0
    while i < k:
        i *= 2
        count += 1
    lis.append(count)
result = 0
for i in lis:
    result += 1 / n * 0.5 **i
print(result)
N,T=map(int,input().split())
List=[list(input().split()) for i in range(N)]
List2=[]
List3=[]
for i in List:
        List2.append([int(s) for s in i])
for i in List2:
        if i[1] <= T:
                List3.append(i[0])
print(min(List3))

### FIXED CODE ###

N,T=map(int,input().split())
List=[list(input().split()) for i in range(N)]
List2=[]
List3=[]
for i in List:
        List2.append([int(s) for s in i])
for i in List2:
        if i[1] <= T:
                List3.append(i[0])
if List3 == []:
        print("TLE")
else:
        print(min(List3))
from bisect import bisect_left,bisect_right
n,m,k=map(int,input().split())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
for i in range(1,n):
    arr1[i]=arr1[i]+arr1[i-1]
for i in range(1,m):
    arr2[i]=arr2[i]+arr2[i-1]
ma=0
for i in range(n):
    c=k-arr1[i]
    ind=bisect_right(arr2,c)
    if arr2[ind]<=c:
        ma=max(ma,ind+i+1)
print(ma)

### FIXED CODE ###

from bisect import bisect_left,bisect_right
n,m,k=map(int,input().split())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
for i in range(1,n):
    arr1[i]=arr1[i]+arr1[i-1]
for i in range(1,m):
    arr2[i]=arr2[i]+arr2[i-1]
ma=0
for i in range(n):
    if arr1[i]<=k:
        ma=max(ma,bisect_right(arr2,k-arr1[i])+i+1)
for i in range(m):
    if arr2[i]<=k:
        ma=max(ma,bisect_right(arr1,k-arr2[i])+i+1)
print(ma)
import math

a, b, x = map(int, input().split())

print(b // x - (a - 1) // x))


### FIXED CODE ###

a, b, x = map(int, input().split())

print(b // x - (a - 1) // x)
n=int(input())
a=list(map(int,input().split()))
b=[]
if len(a)%2==0:
  for i in range(n-1,0,-2):
    b.append(a[i])
  for i in range(0,n-2,2):
    b.append(a[i])
else:
  for i in range(n,-1,-2):
    b.append(a[i])
  for i in range(1,n-1,2):
    b.append(a[i])
print(' '.join(b))

### FIXED CODE ###

n=int(input())
a=list(input().split())
b=[]
if len(a)%2==0:
  for i in range(n-1,0,-2):
    b.append(a[i])
  for i in range(0,n-1,2):
    b.append(a[i])
else:
  for i in range(n-1,-1,-2):
    b.append(a[i])
  for i in range(1,n-1,2):
    b.append(a[i])
print(' '.join(b))
N = int(input())
cnt = 0
L = []
for i in range(N):
	L.append(list(map(int, input().split())))

for i in range(N):
	A, B = L[-i+1]
	cnt += -(A + cnt)%B
	print(cnt)

### FIXED CODE ###

N = int(input())
cnt = 0
L = []
for i in range(N):
	L.append(list(map(int, input().split())))

L = L[::-1]
 
for i in range(N):
	A, B = L[i]
	if A:
		cnt += -(A + cnt)%B

print(cnt)
N = int(input())
a = [int(input()) for i in range(N) ]
count = 0
for i in range(N):
	for j in range(len(a)):
 		if a[j] % 2 == 0:
    		count += 1
            a[j] /= 2
print(count)

### FIXED CODE ###

N = int(input())
a_list = list(map(int, input().split()))
count = 0
while True:
	odd = 0
	for i in range(N):
		if a_list[i] % 2 == 0:
			a_list[i] = int(a_list[i] / 2)
			count += 1
		else:
			odd += 1
	if odd == len(a_list):
		break
print(count)
N = int(input())
A = list(map(int,input().split()))
x = 0
count = 0
while True:
  for i in A:
    if i % 2 == 1:
      x = 1
  if x == 1:
    break
  else:
    A /= 2
    count += 1

print(count)

### FIXED CODE ###

import numpy as np
N = int(input())
A = list(map(int,input().split()))
A = np.array(A)
count = 0
while True:
  x = 0
  for i in A:
    if i % 2 == 1:
      x = 1
  if x == 1:
    break
  else:
    A = A / 2
    count += 1

print(count)
n=int(input())
T=[int(input()) for i in range(n)]
def gcd(a,b):
    if b==0:
        return(a)
    else:
        return(gcd(b,a%b))
def lgm(a,b):
    return(a*b//(gcd(a,b)))
if n==1:
    print(T[0])
else:
    ans=T[0]
    for i in range(1,n):
        ans=lgm(ans,T[i])
print(ans)

### FIXED CODE ###

n=int(input())
T=[int(input()) for i in range(n)]
def gcd(a,b):
    if b==0:
        return(a)
    else:
        return(gcd(b,a%b))
def lgm(a,b):
    return(a*b//(gcd(a,b)))
if n==1:
    print(T[0])
else:
    ans=T[0]
    for i in range(1,n):
        ans=lgm(ans,T[i])
    print(ans)
N = int(input())

ball_list = []

for i in range(N):
    ball_list.append(int(input()))

print(len(list(set(ball_list)))

### FIXED CODE ###

N = int(input())

ball_list = map(str, input().split())
type_num = len(list(set(ball_list)))

if type_num == 3:
    print('Three')
else:
    print('Four')
import math
n,k = map(int,input().split())
ans = 0
mod = 10**9+7
def combinations_count(n, r): #組み合わせ(nCr)
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
for i in range(1,k+1):
    cnt = combinations_count(n-k+1,i)* combinations_count(k-1, i-1)% mod
    print(cnt%mod)

### FIXED CODE ###

from operator import mul
from functools import reduce
n,k = map(int,input().split())
ans = 0
mod = 10**9+7
def cmb(n, r):
    if r > n:
        return 0
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under
for i in range(1,k+1):
    cnt = cmb(n-k+1,i)* cmb(k-1, i-1)
    print(cnt%mod)
dic = [['a', 0], ['b', 0], ['c', 0], ['d', 0], ['e', 0], ['f', 0], ['g', 0], ['h', 0], ['i', 0], ['j', 0], ['k', 0], ['l', 0], ['m', 0], ['n', 0], ['o', 0], ['p', 0], ['q', 0], ['r', 0], ['s', 0], ['t', 0], ['u', 0], ['v', 0], ['w', 0], ['x', 0], ['y', 0], ['z', 0]]  
while True:
	s = raw_input()
	if s == '':
		break
	for i in s:
		for j in range(0, 26):
			if dic[j][0] == i.lower():
				dic[j][1] += 1
				break
for i in range(0, 26):
	print dic[i][0], ':', dic[i][1]

### FIXED CODE ###

import sys
dic = [['a', 0], ['b', 0], ['c', 0], ['d', 0], ['e', 0], ['f', 0], ['g', 0], ['h', 0], ['i', 0], ['j', 0], ['k', 0], ['l', 0], ['m', 0], ['n', 0], ['o', 0], ['p', 0], ['q', 0], ['r', 0], ['s', 0], ['t', 0], ['u', 0], ['v', 0], ['w', 0], ['x', 0], ['y', 0], ['z', 0]]  
for s in sys.stdin.read().lower():
	if s == '':
		break
	for i in s:
		for j in range(0, 26):
			if dic[j][0] == i.lower():
				dic[j][1] += 1
				break
for i in range(0, 26):
	print dic[i][0], ':', dic[i][1]
N = int(input())
lis = [(input() + " " + str(i+1)).split() for i in range(N)]
 
lis = [k for k in lis]
 
lis.sort(key=lambda k: int(k[1]), reverse=True)
lis.sort(key=lambda k: k[0])
 
 
for j in lis:
    print(j[2])


### FIXED CODE ###

try:
    a,p=map(int, input().split())
    assert 0<=a,p<=100
    print(((a*3)+p)//2)
except AssertionError:
    print('')
import math
n,x=map(int,input().split())
print(4*(n-gcd(n,x)))


### FIXED CODE ###

from fractions import gcd
n,x=map(int,input().split())
print(3*(n-gcd(n,x)))
import numpy as np

k = int(input())

cnt = 0
for a in range(k):
  for b in range(k):
    for c in range(k):
      cnt += np.gcd.reduce([a+1, b+1, c+1])

print(cnt)

### FIXED CODE ###

import math

k = int(input())

cnt = 0
for a in range(1, k+1):
  for b in range(1, k+1):
    for c in range(1, k+1):
      cnt += math.gcd(math.gcd(a, b), c)

print(cnt)
print(len(set(map(int, input().split())))

### FIXED CODE ###

print(len(set(input().split())))
_=int(input())
s=input()
mod=7+10**9
def dp(t,l):
    if len(t)==1:
        if t[0] in l:
            return 1
        else:
            return 2
    if t[0] in l:
        return dp(t[1:],l)
    else:
        return (dp(t[1:],l+[t[0]])+dp(t[1:],l))%mod
print(dp(s,[])-1)

### FIXED CODE ###

_=input()
s=input()
mod=7+10**9
ans=1
for i in range(26):
    ans*=1+s.count(chr(ord('a') + i))
    ans%=mod
print(ans-1)
import sys
import math
input = sys.stdin.readline
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


A, B, C, D = map(int, input().split())
lcm=lcm(C,D)
ans = B-A+1 - (B//C-A//C) - (B//D-A//D) + (B//(lcm)-A//(lcm)) 


print(ans)

### FIXED CODE ###

import sys
import fractions
input = sys.stdin.readline
def lcm(x, y):
  return (x * y) // fractions.gcd(x, y)


A, B, C, D = map(int, input().split())
lcm=lcm(C,D)
ans = B-A+1 - (B//C-(A-1)//C) - (B//D-(A-1)//D) + (B//(lcm)-(A-1)//(lcm)) 


print(ans)
n = input()
h = input()
w = input()
print((n-h+1)*(n-w+1))

### FIXED CODE ###

n = int(input())
h = int(input())
w = int(input())
print((n-h+1)*(n-w+1))
n = int(input())
a = int(input())
if a >=　(n % 500):
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n=int(input())%500
a=int(input())
print('Yes' if a>=n else 'No')
print(["Yes","No"][len(set(input())<3])

### FIXED CODE ###

print(["Yes","No"][len(set(input()))<3])
a, b, c, d = list(input())
a, b, c, d = int(a), int(b), int(c), int(d)
if a+b+c+d == 7:
  print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a+b+c-d == 7:
  print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a+b-c+d == 7:
  print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a+b-c-d == 7:
  print(str(a)+'+'+str(b)+'-'+str(c)+'-'-str(d)+'=7')
elif a-b+c+d == 7:
  print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a-b+c-d == 7:
  print(str(a)+'-'+str(b)+'+'+str(c)+'-'-str(d)+'=7')
elif a-b-c+d == 7:
  print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a-b-c-d == 7:
  print(str(a)+'-'+str(b)+'-'+str(c)+'-'-str(d)+'=7')


### FIXED CODE ###

s = input()
a, b, c, d = int(s[0]), int(s[1]), int(s[2]), int(s[3])
if a+b+c+d == 7:
  print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a+b+c-d == 7:
  print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a+b-c+d == 7:
  print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a+b-c-d == 7:
  print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
elif a-b+c+d == 7:
  print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a-b+c-d == 7:
  print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a-b-c+d == 7:
  print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a-b-c-d == 7:
  print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
N = int(input())
c = input()
W = c.count('W')
print(c[:R].count('W'))

### FIXED CODE ###

N = int(input())
c = input()
W = c.count('W')
R = c.count('R')
print(c[:R].count('W'))
N = input()
A = input()
print(N**2 - A)

### FIXED CODE ###

def get_colored_cells():
    N = int(input())
    A = int(input())
    print(N ** 2 - A)

get_colored_cells()
def pow2(n, mod):
    p = 2
    r = 1
    while n:
        if n % 2:
            r = r * p % mod
        p = (p * p) % mod
        n //= 2
    return r

g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

def nCr(n, r, mod):
    t = 1
    r = min(r, n - r)
    for i in range(n - r + 1, n + 1):
        t = t * i % mod
    return t * g2[r] % mod



def prep(n, mod):
    for i in range(2, n):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod // i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)

def main():
    n, a, b = list(map(int, input().split()))
    aod = 10 ** 9 + 7
    prep(2 * (10 ** 5), mod)
    print((pow2(n, mod) - 1 - nCr(n, a, mod) - nCr(n, b, mod))% mod)


main()


### FIXED CODE ###

def pow2(n, mod):
    p = 2
    r = 1
    while n:
        if n % 2:
            r = r * p % mod
        p = (p * p) % mod
        n //= 2
    return r

g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

def nCr(n, r, mod):
    t = 1
    r = min(r, n - r)
    for i in range(n - r + 1, n + 1):
        t = t * i % mod
    return t * g2[r] % mod



def prep(n, mod):
    for i in range(2, n):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod // i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)

def main():
    n, a, b = list(map(int, input().split()))
    mod = 10 ** 9 + 7
    prep(2 * (10 ** 5) + 1, mod)
    print((pow2(n, mod) - 1 - nCr(n, a, mod) - nCr(n, b, mod))% mod)


main()
num = int(input())
index = list(map(int, input().split()))
point = list(map(int, input().split()))
add = list(map(int, input().split()))

total = 0
for i in range(num):
  total += point[index[i]-1]

for j in range(num-1):
  if index[j+1] == index[j]+ 1:
    total += add[index[i]-1]


print(total)

### FIXED CODE ###

num = int(input())

print(num ** 3)
N=int(input())
a=[int(x) for x in input().split()]
b=a
t=-1
s=0
while s==0:
  for i in range(N):
    if b[i]%2!=0:
      s=1
    b[i]=b[i]/2
  t=t+1
print(t)

### FIXED CODE ###

x=input()
X=list('{}'.format(x))
a=[]
for i in range(len(X)):
    a.append(int(X[i]))
A=sum(a)
print(A)
s,t = map(str,input.split())
a,b = map(int,input.split())
u = str(input())
if s == u:
    a -= 1
else :
    b -= 1
print("{0} {1}".format(a,b))

### FIXED CODE ###

S, T = map(str,input().split())
A, B = map(int,input().split())
U = input()
 
if S == U: A -= 1
if T == U: B -= 1
print("{0} {1}".format(A,B))
a=list(map(int,input()));print("YNeos"[sum(a)!=max(a)*2])


### FIXED CODE ###

a=list(map(int,input().split()));print("YNeos"[sum(a)!=max(a)*2::2])
N = input()
A = list(map(int, input().split()))
odd, four = 0, 0, 0
for i in range(N):
  if A[i] % 4 == 0:
    four += 1
  else:
    if A[i] % 2 == 1:
      odd += 1
if four < odd and four + odd < N:
  print('No')
else:
  print('Yes')


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
odd, four = 0, 0
for i in range(N):
  if A[i] % 4 == 0:
    four += 1
  else:
    if A[i] % 2 == 1:
      odd += 1
if four < odd and four + odd < N:
  print('No')
elif odd - four > 1 and four + odd == N:
  print('No')
else:
  print('Yes')
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    for a in range(1, 3501):
        for b in range(1, 3501):
            numerator = a * b * n
            denominator = 4 * a * b - a * n - b * n
            if denominator == 0:
                continue
            c = numerator // denominator
            if n / 4 == 1 / a + 1 / b + 1 / c:
                print(a, b, c)
                return
    return


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    for a in range(1, 3501):
        for b in range(1, 3501):
            if 4 * a * b - n * b - n * a == 0:
                continue
            c = (n * a * b) // (4 * a * b - n * b - n * a)
            if c < 1:
                continue
            if 4 * a * b * c == n * (a * b + b * c + c * a):
                print(a, b, c)
                return
    return


if __name__ == "__main__":
    main()
n=int(input())
l=list(map(int,input()))
s=set(l)
ans=0
for i in s:
  a=l.count(i)
  ans+=a*(a-1)//2
print(ans)

### FIXED CODE ###

n=int(input())
l=[0]+list(map(int,input().split()))
for i in range(1,n+1):
  l[i]+=l[i-1]
d={}
for i in l:
  if i not in d:
    d[i]=1
  else:
    d[i]+=1
ans=0
for a in d.values():
  ans+=a*(a-1)//2
print(ans)
def main(){
 

    n = input()
    for i in n-1:
        R[i] = input()
 
    max = R[1] - R[0]
    min = R[0]
 
    for i+1 in n-1:
        if R[i]-min>max:
            max = R[i] - min
        if R[i]<min
            min = R[i]
 
    print max
 
    return 0

}
 

### FIXED CODE ###

n = input()

R = [input() for i in range(n)]
  
max = R[1] - R[0]
min = R[0]
  
for i in range(1,n):
    if R[i] - min > max:
        max = R[i] - min
    if R[i] < min:
        min = R[i]
  
print max
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
aa=sorted(a,reverse=True)
bb=sorted(b,reverse=True)
cc=sorted(c,reverse=True)
n=0
l=[]
while n<=k:
    for i in range(100):
        for j in range(100):
            for x in range(100):
                ll=l.append(aa[i]+bb[j]+cc[x])
ll.sort(reverse=True)
for i in range(k):
    print(ll[i])


### FIXED CODE ###

x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=sorted(list(map(int,input().split())),reverse=True)
ab=[]
for i in a:
    for j in b:
        ab.append(i+j)
ab.sort(reverse=True)
ans=[]
for i in range(min(k,len(ab))):
    for j in range(min(k,len(c))):
        ans.append(ab[i]+c[j])
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])
a = map(int, raw_input().split())

a[0] = (a[0] + 12) % 13
a[1] = (a[1] + 12) % 13

if a[0] == a[1]  :


### FIXED CODE ###

a = map(int, raw_input().split())

if a[0] == 1 :
    a[0] = 14
if a[1] == 1 :
    a[1] = 14

if a[0] == a[1] :
    print 'Draw'
elif a[0] > a[1] :
    print 'Alice'
else :
    print 'Bob'
from collections import Counter
n, k = map(int, input().split())
a_list = list(map(int, input().split()))
b = Counter(a_list)
key, values = zip(*b.most_common())
sum=0
for i in values.range(k):
    d = sum + i
print(n-i)

### FIXED CODE ###

import collections
n, k = map(int, input().split())
a_list = list(map(int, input().split()))
b = collections.Counter(a_list)
d = b.most_common()[k:]
sum = 0
for i in d:
    sum += i[1]
print(sum)
n = int(input())

nums = list(range(1,n+1))
print(sum(nums)-n)

### FIXED CODE ###

n = int(input())
print(n*(n-1)//2)
total_tenb,total_load=map(int,input().split())
hight=[]
good_tenb=[]
for i in range(total_tenb):
  a=int(input())
  hight.append(a)
  good_tenb.append(a)
  
def kuraberu(A,B):
  if hight[A]>hight[B]:
    good_tenb.append(height[A])
    good_tenb.del(height[B])
  elif hight[A]<hight[B]:
    good_tenb.append(hight[B])
    good_tenb.del(hight[A])
    
  
for h in range(total_load):
  A[h]=int(input())
  B[h]=int(input())
  kuraberu(A[h],B[h])
  
  
print(len(set(good_tenb)))  
  
  
  

### FIXED CODE ###

N,M=map(int,input().split())
H=list(map(int,input().split()))
check=[0]*N
for i in range(M):
  A,B=map(int,input().split())
  if H[A-1]>H[B-1]:
    check[B-1]=check[B-1]+1
  elif H[A-1]<H[B-1]:
    check[A-1]=check[A-1]+1
  else:
      check[A-1]+=1
      check[B-1]+=1
    
    
ans=check.count(0)

print(ans)