Harryxun/stf_run huggingface dataset:
n, m = map(int, input().split())
x = [-1] * n

exist = True

if n == 1:
    sc_list = []
    for i in range(m):
        sc_list.append(list(map(int, input().split())))
    if m >= 2:
        for i in range(m-1):
            if sc_list[i][1] != sc_list[i+1][1]:
                exist = False
    if exist:
        x = str(sc_list[0][1])

elif n >= 2:
    for i in range(m):
        s, c = map(int, input().split())
        if s == 1:
            if c == 0:
                exist = False
            else:
                if x[0] != -1 and x[0] != c:
                    exist = False
                else:
                    x[0] = c
        else:
            if x[s-1] != -1 and x[s-1] != c:
                exist = False
            else:
                x[s-1] = c

    if x[0] == -1:
        exist = False
    if exist:
        x = [0 if j == -1 else j for j in x]
        x = "".join(map(str,x))
            
if exist:
    print(x)
else:
    print(-1)


### FIXED CODE ###

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

exist = True

if n == 1:
    sc_list = []
    for i in range(m):
        sc_list.append(list(map(int, input().split())))
    
    if m >= 2:
        for j in range(m-1):
            if sc_list[j][1] != sc_list[j+1][1]:
                exist = False
    
    if exist:
        if m >= 1:
            x = str(sc_list[0][1])
        elif m == 0:
            x = '0'

elif n >= 2:
    x = [-1] * n

    for i in range(m):
        s, c = map(int, input().split())
        if s == 1:
            if c == 0:
                exist = False
            else:
                if x[0] != -1 and x[0] != c:
                    exist = False
                else:
                    x[0] = c
        else:
            if x[s-1] != -1 and x[s-1] != c:
                exist = False
            else:
                x[s-1] = c

    if x[0] == -1 :
        x[0] = 1
    if exist:
        x = [0 if j == -1 else j for j in x]
        x = "".join(map(str,x))
            
if exist:
    print(x)
else:
    print('-1')
x,y = map(int,input().split())

y = x + y / 2
print(f"{y:.0f}")


### FIXED CODE ###

import math
x,y = map(int,input().split())

y = x + y / 2

print(math.floor(y))
N,M = map(int,input().split())
a = [int(input()) for i in range(M)]
for i in range(M):
  N = N - a[i]
print(N if N>0 else -1)


### FIXED CODE ###

N,M = map(int,input().split())
a = list(map(int, input().split()))
for i in range(M):
  N -= a[i]
print(N if N>=0 else '-1')
N = int(input())
if N%2==1:
  print(N-1)
else:
  ans = []
  for i in range(1,N):
    for j in range(1,N):
      cnt=0
      if i*j==N:
        cnt +=i-1
        cnt +=j-1
        ans.append(str(cnt))
  ans=min(ans)
  print(ans)


### FIXED CODE ###

A,B = map(int,input().split())
if A<10 and B<10:
  print(A*B)
else:
  print(-1)
n = input()
kakeru = input().split()
kakekake = kakeru[0]
    if n > 2:
        for i in range(2,n+1):
            kakekake = kakekake * kakeru[i-1]
    elif n==2:
    kakekake = kakeru[0] * kakeru[1]
if kakekake > 10**18:
    print(-1)
print(kakekake)

### FIXED CODE ###

n = int(input())
b = 1
a = list(map(int,input().split()))
if 0 in a:
    print(0)
else:
    for i in range(n):
        b *= a[i]
        if b > 10**18:
            print(-1)
            break
    if b <=10**18:
        print(b)
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = -10**18

for i in range(N):
    tmp_score = 0
    pos = i
    # ループになるまで移動
    for j in range(1, N+1):
        pos = P[pos]-1
        if K >= j:
            tmp_score += C[pos]
            ans = max(ans,tmp_score)
        if pos == i:
            break
    
    div = K // j
    mod = K % j

    if K >= j:
        tmp_score *= div
        ans = max(ans,tmp_score)
        # 端数ぶん移動
        # mod=0 のときは移動しない
        for _ in range(1, mod+1):
            pos = P[pos]-1
            tmp_score += C[pos]
            ans = max(ans,tmp_score)

print(ans)

### FIXED CODE ###

S = input()
ans = 0
if "RRR" in S:
    ans = 3
elif "RR" in S:
    ans = 2
elif "R" in S:
    ans = 1
else:
    ans = 0
print(ans)
from scipy.sparse.csgraph import floyd_warshall
import itertools


def warshal_floyd(d):
    # d[i][j] := iからjへの最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    # "今現在求まっているiからjへの最短距離"と"今現在求まっているiからkへの最短距離 + 今現在求まっているkからjへの最短距離 の和"を比較する
    return d


N, M, R = map(int, input().split())  # N個の町, M本の道, R個の町を訪れることになった
town = list(map(lambda x: int(x)-1, input().split()))
distant = [[float('inf')]*N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    distant[a][b] = c
    distant[b][a] = c
for i in range(N):
    distant[i][i] = 0

warshal_floyd(distant)
# print(distant)  # Rは最大8だから全てを試しても大丈夫
ans = 10**9
for x in itertools.permutations(town):
    x = list(x)
    now = x[0]
    tmp = 0
    for i in range(1, len(x)):
        tmp += distant[now][x[i]]
        now = x[i]
    ans = min(ans, tmp)
print(ans)


### FIXED CODE ###

# from scipy.sparse.csgraph import floyd_warshall
import itertools


def warshal_floyd(d):
    # d[i][j] := iからjへの最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    # "今現在求まっているiからjへの最短距離"と"今現在求まっているiからkへの最短距離 + 今現在求まっているkからjへの最短距離 の和"を比較する
    return d


N, M, R = map(int, input().split())  # N個の町, M本の道, R個の町を訪れることになった
town = list(map(lambda x: int(x)-1, input().split()))
distant = [[float('inf')]*N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    distant[a][b] = c
    distant[b][a] = c
for i in range(N):
    distant[i][i] = 0

warshal_floyd(distant)
# print(distant)  # Rは最大8だから全てを試しても大丈夫
ans = 10**9
for x in itertools.permutations(town):
    x = list(x)
    now = x[0]
    tmp = 0
    for i in range(1, len(x)):
        tmp += distant[now][x[i]]
        now = x[i]
    ans = min(ans, tmp)
print(ans)
def main():
    n = input()
    D = []
    O = []
    for i in range(n):
        c, k = raw_input().split()
        if c == 'insert':
            D.append(k)
        else:
            O.append(search(D,k))

    for item in O:
        print item


def search(D,k):
    Dc = D[:]
    if D == []:
        return 'no'
    else:
        d = Dc.pop()
        if d == k:
            return 'yes'
        else:
            return search(Dc,k)

if __name__ == "__main__":
    main()

### FIXED CODE ###

m = 2000003

def MyHash(k,i):
    return (k%m+i*(1+(k%m)))%m

def main():
    n = input()
    T = ['']*2000003
    O = []
    for i in range(n):
        c, k = raw_input().split()
        i = 0
        if c == 'insert':
            k_hashed = hash(k)
            while True:
                j = MyHash(k_hashed,i)
                if T[j] == '':
                    T[j] = k
                    break
                else:
                    i += 1
        else:
            O.append(search(T,k))

    for item in O:
        print item

    return 0


def search(T,k):
    k_hashed = hash(k)
    i = 0
    while True:
        j = MyHash(k_hashed,i)
        if T[j] == k:
            o = 'yes'
            break
        elif T[j] == '':
            o = 'no'
            break
        else:
            i += 1

    return o


if __name__ == "__main__":
    main()
a,b=map(int,input().split())
ans=-1
for i in range(101):
    if int(i*/25)==a and int(i/10)==b:
        ans=i
        break
print(ans)

### FIXED CODE ###

a,b=map(int,input().split())
ans=-1
for i in range(1300):
    if int(i*2/25)==a and int(i/10)==b:
        ans=i
        break
print(ans)
S = input()
T = input()

if T.startwith('S'):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

S = input()
T = input()

if T.startswith(S):
    print("Yes")
else:
    print("No")
N = int(input())
# N < 10 ** 5
A = sorted([int(x) for x in input().split()])
# - 10 ** 9 < A < 10 ** 9

B = [-a for a in A if a < 0]
D = [a for a in A if a >= 0]

if len(B) % 2 == 1:
    B[-1] = -B[-1]
    if -B[-1] > D[0]:
        B[-1] = -B[-1]
        D[0] = -D[0]

print(sum(B)+sum(D))


### FIXED CODE ###

N = int(input())
# N < 10 ** 5
A = sorted([int(x) for x in input().split()])
# - 10 ** 9 < A < 10 ** 9

B = [-a for a in A if a < 0]
D = [a for a in A if a >= 0]

if len(B) % 2 == 1:
    B[-1] = -B[-1]
    if D and -B[-1] > D[0]:
        B[-1] = -B[-1]
        D[0] = -D[0]

print(sum(B)+sum(D))
from sys import stdin, stdout  

N,X,Y = [int(c) for c in input().split()]


res=[0]*N        
for x in range(0,N):
    for y in range(x,N):
        #print(x,y,abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1),min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1)))
        r=min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1))
        res[r]=res[r]+1
        if(x>y):
            res[r]=res[r]-1


for i in range(1,N):
    print(res[i])


### FIXED CODE ###

import sys

for S in sys.stdin:
    if(S[2]==S[3] and S[4]==S[5]):
        print("Yes")
    else:
        print ("No")
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  float r, ans;
  cin >> r;
  ans = 2 * r * M_PI;
  cout << ans << '\n';
  return 0;
}

### FIXED CODE ###

# coding: utf-8
import sys
import math

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

R = ir()
answer = 2 * R * math.pi
print(answer)
l = list(map(int,input().split()))
p = list[0]
q = list[1]
r = list[2]
print(min(p+q,q+r,r+p))

### FIXED CODE ###

l = list(map(int,input().split()))
p = l[0]
q = l[1]
r = l[2]
print(min(p+q,q+r,r+p))
n,k=map(int,input().split())
l=[int(i) for i in input().split()]
right=[i for i in l if i>0]
left=[i for i in l if i<=0]
if not left: 
    sm=0 
    sm+=l[0]
    for i in range(1,k):
        sm+=l[i]-l[i-1]
    print(sm)
    exit()
if not left: 
    sm=0 
    l=[abs(i) for i in l]
    sm=l[0]
    for i in range(1,k):
        sm+=(l[i]-l[i-1])
    print(sm)
    exit()
le=len(left)
ri=len(right)
rl=[0]*le 
rr=[0]*ri 
left=[abs(i) for i in left]
#print(left)
left=left[::-1]
rl[0]=left[0]
for i in range(1,le):
    rl[i]=rl[i-1]+(left[i]-left[i-1])
rr[0]=right[0]
mini=10**9 
for i in range(1,ri) :
    rr[i]=rr[i-1]+(right[i]-right[i-1])
#print(rl)
#print(rr)
if k==n:
    print(sum(rl)+sum(rr))
    exit()
for a in range(1,len(left)):
    b=k-a 
    #print(a,b,rl[a],rr[b-1])
    mini=min(mini,2*rl[a-1]+rr[b-1],rl[a-1]+2*rr[b-1])
print(mini)

### FIXED CODE ###

n,k=map(int,input().split())
l=[int(i) for i in input().split()]
right=[i for i in l if i>0]
left=[i for i in l if i<=0]
if not left: 
    sm=0 
    sm+=l[0]
    for i in range(1,k):
        sm+=(l[i]-l[i-1])
    print(sm)
    exit()
if not right: 
    sm=0 
    l=[abs(i) for i in l]
    l.sort()
    sm=l[0]
    for i in range(1,k):
        sm+=(l[i]-l[i-1])
    print(sm)
    exit()
le=len(left)
ri=len(right)
rl=[0]*le 
rr=[0]*ri 
left=[abs(i) for i in left]
left=left[::-1]
rl[0]=left[0]
for i in range(1,le):
    rl[i]=rl[i-1]+(left[i]-left[i-1])
rr[0]=right[0]
mini=10**20 
for i in range(1,ri) :
    rr[i]=rr[i-1]+(right[i]-right[i-1])
if len(left)>=k:
    mini=min(mini,rl[k-1])
if len(right)>=k:
    mini=min(mini,rr[k-1])
#print(left,right,rl,rr)
for a in range(1,len(left)+1):
    b=k-a 
    #print(a,b)
    if b>len(rr):
        #print('hsef')
        continue 
    mini=min(mini,2*rl[a-1]+rr[b-1],rl[a-1]+2*rr[b-1])
print(mini)
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n = int(input())
l = make_divisors(n)
ans = 999999999999999999
for i in range(0,len(l), 2):
  a = l[i]
  b = l[i+1]
  ans = min(ans,(a+b-2))
  
print(ans)


### FIXED CODE ###

import math

n = int(input())
ans = n-1

for i in range(1, math.floor(math.sqrt(n))+1):
  if n % i == 0:
    ans = min(ans, (i+(n/i)-2))
      
print(int(ans))
#!/usr/bin/env python
#coding: UTF-8
import sys
import math

line = []
for l in sys.stdin:
    for i in l.split(' '):
    	line.append(float(i))
a = math.sqrt((line[0]-line[2])**2+(line[1]-line[3])**2)
print '%06.6f'%a

### FIXED CODE ###

import math

x1,y1,x2,y2 = map(float,raw_input().split())
a = math.sqrt((x1-x2)**2+(y1-y2)**2)
print '%f'%a
# -*- coding: utf-8 -*-
# D - katana Thrower
# モジュールのインポート
import math

# 標準入力の取得
N,H = list(map(int, input().split()))
a,b = [],[]
for n in range(N):
    a_n,b_n = list(map(int, input().split()))
    a.append(a_n)
    b.append(b_n)

# 求解処理
"""
    すでに投げてしまった刀も振ることはできるとしても答えは変わらない。
    以下の攻撃手順を行う：
    0. a_1, a_2, ・・・, a_Nのうち最大値をa_maxとし、攻撃力がa_max以上の投げ刀を「強い投げ刀」とする。
    1. 強い投げ刀を攻撃力が高い順に投げていく。
    2. 強い投げ刀を使い果たしたら、攻撃力a_maxの振り刀を振り続ける。
"""
max_a = max(a)
sorted_b = reversed(sorted(b))
min_count = 0
for b_n in sorted_b:
    if (b_n < max_a) or (H <= 0):
        break
    H -= b_n
    min_count += 1

if H > 0:
    min_count += math.ceil(H / max_a)

# 結果出力
print(min_count)

### FIXED CODE ###

# -*- coding: utf-8 -*-
# C - Otoshidama
# モジュールのインポート
import sys

# 定数の定義
YEN_10000 = 10000
YEN_5000 = 5000
YEN_1000 = 1000

# 標準入力の取得
N,Y = list(map(int, input().split()))

# 探索処理
is_correct = False
for n_10000 in range(N+1):
    for n_5000 in range(N+1-n_10000):
        n_1000 = N - n_10000 - n_5000
        amount = YEN_10000*n_10000 + YEN_5000*n_5000 + YEN_1000*n_1000
        if amount == Y:
            is_correct = True
            print(n_10000, n_5000, n_1000)
            sys.exit()

if not is_correct:
    print("-1 -1 -1")
l=list(map(int, input().split()))
if l[0] <= l[1]:
    sum = l[0] * l[2]
else:
    sum = l[1] * l[2] + (l[0]-l[1]) * l[3]
print(sum)

### FIXED CODE ###

l = [int(input()) for i in range(4)]
if l[0] <= l[1]:
    sum = l[0] * l[2]
else:
    sum = l[1] * l[2] + (l[0]-l[1]) * l[3]
print(sum)
N, M = map(int, input().split())
a = [int(input())for i in range(M)]
a.sort()
pattern = []
ans = 1

# フィボナッチ数列の関数
def fibonacci(n):
    f = ((1 + 5**0.5) / 2)**n / 5**0.5 + 0.5
    return int(f)

# 段の切れ目ごとの場合の数を算出
R = len(a) - 1
for i in range(R):
    x = a[i + 1] - a[i] -1
    pattern.append(fibonacci(x))

# 段の切れ目ごとの場合の数の積
for i in range(len(pattern)):
    ans = ans * pattern[i] % 1000000007

# 1段目まで、最終弾までの数
s1 = fibonacci(a[0])
s2 = fibonacci(N - a[-1])

# かける
ans = ans * s1 * s2 % 1000000007

# 2弾続けて壊れている場合はNG
for i in range(M - 1):
    if a[i] + 1 == a[i + 1]:
        ans = 0

print(ans)


### FIXED CODE ###

N, M = map(int, input().split())
a = [int(input())for i in range(M)]
MOD = 10 ** 9 + 7
ans = []
dp = [1] * (N + 1)

for i in a:
    dp[i] = 0

for i in range(2, N + 1):
    if dp[i] != 0:
        dp[i] = (dp[i - 1] + dp[i - 2])

print(dp[N] % MOD)
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M = map(int,input().split())
AB= [list(map(int,input().split())) for _ in range(M)]

uf = UnionFind(N)
for ab in AB:
    uf.union(ab[0]-1,ab[1]-1)
print(uf.group_count()-1)

### FIXED CODE ###

K = int(input())
print("ACL" * K)
cell_num = int(input())
height = list(map(int, input().split()))
flag = True

if cell_num != 1:
    for i in range(cell_num):
        if height[i+1] - height[i] == 1: height[i+1] -= 1
        elif height[i+1] - height[i] > 1:
            flag = False
            break

if flag: print("Yes")
else: print("No")

### FIXED CODE ###

cell_num = int(input())
height = list(map(int, input().split()))
flag = True

if cell_num != 1:
    if height[0] - height[1] <= 1:
        height[0] -= 1
    elif height[0] - height[1] > 1:
        flag = False
    
    for i in range(1,cell_num-1):
        if height[i] - height[i+1] > 1:
            flag = False
            break
        elif height[i] -  height[i+1] <= 1 and height[i-1] < height[i]:
            height[i] -= 1
        elif height[i] -  height[i+1] == 1 and height[i-1] == height[i]:
            flag = False
            break
            
if flag: print("Yes")
else: print("No")
a, b = map(int, input().split())

if (a*b)%2 = 0:
  print("Even")
else:
  print("Odds")

### FIXED CODE ###

x, y = map(int, input().split())
if x * y % 2:
  print('Odd')
else:
  print('Even')
w,a,b=map(int,input().split())

if a=b:
  print(int(0))
elif a>b:
  if b+w>=a:
    print(int(0))
  else:
    print(int(a-b-w))
else:
   if a+w>=b:
    print(int(0))
   else:
    print(int(b-a-w))

### FIXED CODE ###

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

if a==b:
  print(int(0))
elif a>b:
  if b+w>=a:
    print(int(0))
  else:
    print(int(a-b-w))
else:
   if a+w>=b:
    print(int(0))
   else:
    print(int(b-a-w))
n,m = map(int, input().split())
h=list(map(int,input().split()))
li=[0]*n
 
for i in range(m):
        a,b=map(int, input().split())
        if h[a-1]>h[b-1]:
                li[b-1]+=1
        elif h[b-1]>h[a-1]:
                li[a-1]+=1
        else:
          		li[a-1]+=1
            	li[b-1]+=1
 
cnt=0
for i in range(n):
        if li[i]==0:
                cnt+=1

### FIXED CODE ###

n,m = map(int, input().split())
h=list(map(int,input().split()))
li=[0]*n
 
for i in range(m):
        a,b=map(int, input().split())
        if h[a-1]>h[b-1]:
                li[b-1]+=1
        elif h[b-1]>h[a-1]:
                li[a-1]+=1
        else:
                li[a-1]+=1
                li[b-1]+=1

 
cnt=0
for i in range(n):
        if li[i]==0:
                cnt+=1

print(cnt)
N = int(input())
S = [int(input()) for _ in N]
print(len(set(s)))

### FIXED CODE ###

N = int(input())
S = [input() for _ in range(N)]
print(len(set(S)))
n=int(input())
xu=dict(map(str,input().split()) for i in range(n) )
s=[]
b=[]
for key,val in xu.items():
    if val=="JPY":
        s.append(float(key))
    else:
        b.append(float(key))
print(sum(s)+(sum(b)*380000))n=int(input())
xu=dict(map(str,input().split()) for i in range(n) )
s=[]
b=[]
for key,val in xu.items():
    if val=="JPY":
        s.append(int(key))
    else:
        b.append(float(key))
print(sum(s)+(sum(b)*380000.0))

### FIXED CODE ###

n=int(input())
ans=0
rate=380000.0
for i in range(n):
    x,u=input().split()
    x=float(x)
    ans+=x*rate if u=="BTC" else x
print(ans)
N,M=map(int,input().split())
A = [int(x) for x in input().split()]
length = len(A)
for i in range(M):
    b,c = map(int,input().split())
    A.extend(b*[c])
	A.sort(reverse = True)
    A = A[:length]
print(sum(A))

### FIXED CODE ###

read = input 
rn = lambda :map(int, read().split())
n,m = rn()
A = list(rn())
l = len(A)
d = {}
for x in A:
    if x not in d:
        d[x]=0
    d[x] += 1
for i in range(m):
    b, c = rn()
    if c not in d:
        d[c]=0
    d[c] += b
A = list(d.items())
A.sort(reverse=True)
ans = 0
cnt = l
# print(A)
for v, c in A:
    tmp = min(cnt, c)
    ans += tmp * v
    cnt -= tmp
print(ans)
N,H = map(int,input().split())
AB = [[map(int,input().split())] for _ in range(N)]
A,B = zip(*AB)

a = max(A)
B = [b for b in B if b > a] #投げる
B.sort(reverse = True)

answer = 0
hp = H
attack_cnt = 0

for b in B:
  if hp <= 0:
    break
  attack_cnt += 1
  hp -= b

if hp > 0:
  attack_cnt += (hp-1)//a + 1

print(attack_cnt)


### FIXED CODE ###

N,H = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
A,B = zip(*AB)

a = max(A) #振る
B = [b for b in B if b > a] #投げる
B.sort(reverse = True)

answer = 0
hp = H
attack_cnt = 0

for b in B:
  if hp <= 0:
    break
  attack_cnt += 1
  hp -= b

if hp > 0:
  attack_cnt += (hp-1)//a + 1

print(attack_cnt)
X,Y = map(str,input().split())
XY = ["A","B","C","D","E","F"]
for i in range(5):
    if X == XY[i]:
        XX = i
    if Y == XY[i]:
        YY = i
if XX == YY:
    print("=")
elif XX > YY:
    print(">")
else:
    print("<")
    

### FIXED CODE ###

X,Y = map(str,input().split())
XY = ["A","B","C","D","E","F"]
for i in range(6):
    if X == XY[i]:
        XX = i
    if Y == XY[i]:
        YY = i
if XX == YY:
    print("=")
elif XX > YY:
    print(">")
else:
    print("<")
class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n

    def root(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.par[x] = y
            else:
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def samegrp(self, x, y):
        return self.root(x) == self.root(y)

from mymodules.somedatastrs import UnionFind

n, m = [int(x) for x in input().split()]
A = UnionFind(n)
ans = n
for i in range(m):
    x, y, _ = [int(z) - 1 for z in input().split()]
    if not A.samegrp(x, y):
        ans -=1
    A.union(x, y)

print(ans)

### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n

    def root(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.par[x] = y
            else:
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def samegrp(self, x, y):
        return self.root(x) == self.root(y)

n, m = [int(x) for x in input().split()]
A = UnionFind(n)
ans = n
for i in range(m):
    x, y, _ = [int(z) - 1 for z in input().split()]
    if not A.samegrp(x, y):
        ans -=1
    A.union(x, y)

print(ans)