Harryxun/stf_run huggingface dataset:
a,b,h,m = map(int,input().split())

ang = abs(h * 30 + m * 0.5- m * 6)
print(ang)
if ang > 180:
  ang = 360-ang
if ang==180:
  print(a+b)
elif(ang==0):
  print(abs(b-a))
else:
  ans=(a**2)+(b**2)-(2*a*b*math.cos(math.radians(ang)))
  print(math.sqrt(ans))

### FIXED CODE ###

import math

a, b, h, m = map(int, input().split())
h=h*60+m

ang=abs(h*0.5-m*6)
if ang > 180:
  ang = 360-ang
if ang==180:
  print(a+b)
elif(ang==0):
  print(abs(b-a))
else:
  ans=(a**2)+(b**2)-(2*a*b*math.cos(math.radians(ang)))
  print(math.sqrt(ans))
import sys


fin = sys.stdin.readline
N, x = [int(elem) for elem in fin().split()]
a_list = [int(elem) for elem in fin().split()]

min_cost_for = a_list.copy()
this_is_from = list(range(N))

max_num_magics = 0
for i, a in enumerate(a_list): 
    for j, other_a in enumerate(a_list):
        if i == j: continue
        num_magics = i - j if j < i else (N - j + i)
        cost = other_a + num_magics * x
        if cost < min_cost_for[i]:
            min_cost_for[i] = cost
            max_num_magics = max(num_magics, max_num_magics)
            this_is_from[i] = j


total_cost = sum(a_list[origin] for origin in this_is_from) + x * max_num_magics
print(total_cost)


### FIXED CODE ###

import sys
from copy import copy


fin = sys.stdin.readline
N, x = [int(elem) for elem in fin().split()]
a_list = [int(elem) for elem in fin().split()]

min_total_cost = float('inf')
min_so_far = a_list[:]
for num_magics in range(N):
    for i in range(N):
        min_so_far[i] = min(min_so_far[i], a_list[i - num_magics])
    total_cost = sum(min_so_far) + num_magics * x
    min_total_cost = min(min_total_cost, total_cost)
print(min_total_cost)
import sys
N,M=map(int,input().split())
SC=dict()
for n in range(1,N+1):
    SC[n]=[]

for _ in range(M):
    s,c=map(int,input().split())
    SC[s].append(c)
if(N == 1):
    print(0)
    sys.exit()
ans = [i*10**(N - 1) for i in SC[1] if i != 0]
SC.pop(1)
for item in SC.items():
    keta=item[0]
    for kazu in item[1]:
        number = kazu * 10 ** (N - keta)
        for i in range(len(ans)):
            a = ans.pop(0)
            ans.append(a + number)
print(min(ans))


### FIXED CODE ###

import sys
N,M=map(int,input().split())
SC=[]

for _ in range(M):
    s,c=map(int,input().split())
    SC.append([s,c])

ans=-1
for i in range(10**N):
    if(len(str(i)) == N):
        for j in range(M):
            s=SC[j][0] - 1
            c=SC[j][1]
            tmp=list(str(i))
            if(tmp[s] != str(c) ):
                break
        else:
            if(ans == -1):
                ans=i
            else:
                ans=min(ans,i)
print(ans)
n, k = map(int, input().split()) 
a_list = list(map(int, input().split())) 

rireki = [0] * (n+1)
curr_c = 1
rireki[1] = 0

no_loop_count = k
loop_cnt = 0

for i in range(n):
    next_c = a_list[curr_c-1]
    # print(i, curr_c, next_c)
    if next_c == 1:
        no_loop_count = 0
        loop_cnt = i + 1
        break
    elif rireki[next_c] == 0:
        rireki[next_c] = i+1
    else:
        # print(next_c)
        no_loop_count = rireki[next_c] -1
        loop_cnt = i - no_loop_count
        break
    curr_c = next_c


if k <= no_loop_count:
    ans = rireki.index(k)
else:
    # print('k',k)
    # print('no', no_loop_count)
    # print('lo', loop_cnt)
    ind = (k-1-no_loop_count)%loop_cnt +1
    rireki_fix = [i-no_loop_count for i in rireki]
    # print(ind, 'ind')
    ans = rireki_fix.index(ind)
    # print(rireki_fix)

print(ans)

### FIXED CODE ###

def main():
    n, k = map(int, input().split()) 
    al = list(map(int, input().split())) 
    city_l = [1]
    city_s = set([1])
    loop_city_l = []
    curr_city = 1
    cnt = 0
    for i in range(1,k+1):
        next_c = al[curr_city-1]
        if next_c in city_s:
            cnt = i
            first_city = city_l.index(next_c)
            loop_city_l = city_l[first_city:]
            break
        else:
            city_s.add(next_c)
            city_l.append(next_c)
        curr_city = next_c
    else:
        print(curr_city)
        return

    # print(loop_city_l)
    remained = k-cnt
    last_pos = remained%len(loop_city_l)
    print(loop_city_l[last_pos])

if __name__ == "__main__":
    main()
N = int(input())
a = []

for i in range(N):
  a.append(input())
  
b = set(a)
print(len(b))

### FIXED CODE ###

a = input().split(" ")
s = int(a[0])
w = int(a[1])

if w >= s:
  print("unsafe")
else:
  print("safe")
s = input()
t = input()
ans = 0
for i in range(3):
  if s[i] == t[i]:
    ans++
print(ans)

### FIXED CODE ###

s = input()
t = input()
ans = 0
for i in range(3):
  if s[i] == t[i]:
    ans+=1
print(ans)
a=int(100)
x=int(input())
for i in range(10000):
  if a < x:
    a*=101//100
    a=int(a)
    i+=1
  else:
    break
print(i)


### FIXED CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))
     
p = sorted(p)

ans=0
for i in range(k):
       ans+=p[i]
print(ans)
N, M = map(int, input().split())
q = [list(map(int, input().split())) for i in range(M)]
change = [0 for i in range(N)]

ans = list('0' * N)
for i in range(M):
  if change[q[i][0]-1] == 0:
  	ans[q[i][0] - 1] = q[i][1]
  	change[q[i][0]-1] = 1
  else:
    if ans[q[i][0] - 1] != q[i][1]:
      ans = -1
      break
      
res = ''
for i in range(len(ans)):
  res += str(ans[i])
  
if res[0] == '0':
  print(-1)
else:
  print(int(res))


### FIXED CODE ###

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

ans = -1
if N == 1:
  s = 0
else:
  s = 10 ** (N - 1)
for i in range(s, 10 ** N + 1):

  flag = True
  for j in range(M):
    try:
      if str(i)[q[j][0] - 1] != str(q[j][1]):
        flag = False
    except:
      flag = False
      break
      
  if flag:
    ans = i
    break
    
print(ans)
MOD = 10 ** 9 + 7

N = int(input())
X = list(input())

lst = [-1] * (N + 10)
lst[0] = 0
lst[1] = 1

def calc(x):
    if lst[x] != -1:
        return lst[x]
    count = 0
    y = x
    while y:
        if y % 2 == 1:
            count += 1
        y //= 2
    lst[x] = calc(x % count) + 1
    return lst[x]



count = X.count('1') #1の数
# print (count)
total = 0
for i in range(N):
    if X[N - 1 - i] == '1':
        total += pow(2, i, MOD)
        total %= MOD
# print ('total', total)

for i in range(N):
    if X[i] == '1':
        tmp_total = (total - pow(2, N - 1 - i, MOD)) % MOD
        amari = tmp_total % (count - 1)
        ans = calc(amari) + 1
        print (ans)
    else: # 0の時
        tmp_total = (total + pow(2, N - 1 - i, MOD)) % MOD
        amari = tmp_total % (count + 1)
        ans = calc(amari) + 1
        print (ans)






### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)

N = int(input())
X = list(input())

lst = [-1] * (4 * N + 10)
lst[0] = 0
lst[1] = 1

def calc(x):
    if lst[x] != -1:
        return lst[x]
    count = 0
    y = x
    while y:
        if y % 2 == 1:
            count += 1
        y //= 2
    lst[x] = calc(x % count) + 1
    return lst[x]



count = X.count('1') #1の数

count1 = count - 1
count2 = count + 1

# print (count)
total1 = 0
total2 = 0

for i in range(N):
    if X[N - 1 - i] == '1':
        if count1 >= 1:
            total1 += pow(2, i, count1)
            total1 %= (count1)

        total2 += pow(2, i, count2)
        total2 %= (count2)
# print ('total', total)

for i in range(N):
    if X[i] == '1':
        if count1 == 0:
            print (0)
            continue
        tmp_total = (total1 - pow(2, N - 1 - i, count1)) % count1
        amari = tmp_total % count1
        ans = calc(amari) + 1
        print (ans)
    else: # 0の時
        tmp_total = (total2 + pow(2, N - 1 - i, count2)) % count2
        amari = tmp_total % (count2)
        ans = calc(amari) + 1
        print (ans)
n, p = map(int,input().split())
D = input()
count = [0] * p
out = 0

if 10 % p == 0:
    for i, d in enumerate(D):
        if int(d) % p == 0:
            out += i + 1
else:
    ten = 1
    count[0] = 1
    for i in range(n):
        mod = (mod + int(D[n-i-1]) * ten) % p
        count[mod] += 1
        ten *= 10
    for c in count:
        out += (c * (c - 1)) // 2
print(out)

### FIXED CODE ###

n, p = map(int,input().split())
D = input()
out = 0


if 10 % p == 0:
    for i in range(n):
        if int(D[i]) % p == 0:
            out += i + 1
else:
    mod = 0
    count = [0] * p
    ten = 1
    count[mod] += 1
    for i in range(n):
        mod = (mod + int(D[n-i-1]) * ten) % p
        ten = ten * 10 % p
        count[mod] += 1
    for c in count:
        out += (c * (c - 1)) // 2
print(out)
r = int(input())
import math
print(2*r * math.pi)

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
         
t = sum(A)
if N < t:
  print(-1)
  exit(0)
else:
  print(N-t)
n,c,k=map(int,input().split())
ans=1
l=[]
for i in range(n):
  l.append(int(input()))
l.sort()
ride=[]
while l:
  a=l.pop(0)
  rode=a
  ride.append(a)
  while len(ride)<c:
    if l==[]:
      break
    b=l[0]
    if b>ride[0]+k:
      ride.clear()
      ans+=1
      break
    l.pop(0)
    ride.append(b)
    if len(ride)==c:
      ans+=1
      ride.clear()
      break
print(ans)

### FIXED CODE ###

n,c,k=map(int,input().split())
ans=0
if c==1:
  print(n)
  exit()
l=[]
for i in range(n):
  l.append(int(input()))
l.sort()
ride=[]
while l:
  a=l.pop(0)
  rode=a
  ride.append(a)
  while len(ride)<c:
    if l==[]:
      ans+=1
      break
    b=l[0]
    if b>ride[0]+k:
      ride.clear()
      ans+=1
      break
    l.pop(0)
    ride.append(b)
    if len(ride)==c:
      ans+=1
      ride.clear()
      break
print(ans)
N=int(input())
A=list(map(int,input().split()))
B=A.copy()
counter=0
for num in range(N):
  if A[num] in B:
    counter+=1
    while A[num] in B:
      B.remove(A[num])
  else:
    continue
print(counter)

### FIXED CODE ###

N=int(input())
z=[]
for num in range(101):
  z.append(0)
counter=0
while counter < N:
  d=int(input())
  z[d]=1
  counter+=1
result=sum(z)
print(result)
S = list(input())
T = list(input())
count = 0

for i in range(len(S)):
  if S[i] != T[i]:
	count += 1

print(count)


### FIXED CODE ###

S = list(input())
T = list(input())
count = 0

for i in range(len(S)):
  if S[i] != T[i]:
    count += 1

print(count)
x = input().split()
W = x[0]
H = x[1]
x = x[2]
y = x[3]
r = x[4]

if W >= x + r and H >= y + r:
   print("Yes")
else:
   print("No")

### FIXED CODE ###

xmas = input().split()
W = int(xmas[0])
H = int(xmas[1])
x = int(xmas[2])
y = int(xmas[3])
r = int(xmas[4])

if W >= (x + r) and H >= (y + r) and (x - r) >= 0 and (y - r) >= 0:
   print("Yes")
else:
   print("No")
N, M, K = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
s = 0
for i, a in enumerate(A):
    if s + a > K:
        break
    s += a
else:
    i += 1
for j, b in enumerate(B):
    if s + b > K:
        break
    s += b
else:
    j += 1

ans = i + j
while i:
    i -= 1
    s -= A[i]
    while j < M and s + B[j] <= K:
        j += 1
        s += B[j]
    ans = max(ans, i + j)

print(ans)

### FIXED CODE ###

N, M, K = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
s = 0
for i, a in enumerate(A):
    if s + a > K:
        break
    s += a
else:
    i += 1
for j, b in enumerate(B):
    if s + b > K:
        break
    s += b
else:
    j += 1

ans = i + j
while i:
    i -= 1
    s -= A[i]
    while j < M and s + B[j] <= K:
        s += B[j]
        j += 1
    ans = max(ans, i + j)

print(ans)
n, k = map(int, input().split())
h = [int(i) for i in input().split()]

def chmin(a, b):
    if a > b:
        return b
    else:
        return a
f_inf = pow(10,9)+99

dp = [f_inf] * (n+1)
dp[0] = 0
for i in range(1, n):
    for j in range(1, k+1):
        if i - j >= 0:
            dp[i] = chmin(dp[i], dp[i-j]+ abs(h[i] - h[i - j]))
print(dp[n-1])


### FIXED CODE ###

import math

N = int(input())
data = list(map(int,input().split()))


BIG = pow(10,9)+7

dp = [BIG]*(N+1)

dp[0] = 0

for i in range(N):
    for j in range(i+1,i+3):
        if j<N:
            dp[j] = min(dp[j], dp[i] + abs(data[i]-data[j]))
            
print(dp[N-1])
n = int(input())
B = list(map(int, input().split()))
A = [0] * (n)
A[0] = B[0]
for i in range(n - 2):
    if B[i] > B[i + 1]:
        A[i + 1] = B[i + i]
    else:
        A[i + 1] = B[i]
A[-1] = B[-1]
print(sum(A))


### FIXED CODE ###

n = int(input())
B = list(map(int, input().split()))
ans = 0
ans += B[0]
for i in range(n - 2):
    if B[i] > B[i + 1]:
        ans += B[i + 1]
    else:
        ans += B[i]
ans += B[-1]
print(ans)
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')

a=input()
b=input()

a=sorted(a)
b=sorted(b)

if a==b:
	print("No")
	sys.exit()

for i in range(min(len(a),len(b))):
	if a[i]<b[-(i+1)]:
		print("Yes")
		break
	
	elif a[i]==b[-(i+1)]:
		continue
		
	else:
		print("No")
		break
		
if len(a)<len(b)):
	print("Yes")
	
else:
	print("No")

### FIXED CODE ###

import sys
 
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
 
a=input()
b=input()
 
a=sorted(a)
b=sorted(b)
cnt=0
 
if a==b:
	print("No")
	sys.exit()
 
for i in range(min(len(a),len(b))):
	if a[i]<b[-(i+1)]:
		print("Yes")
		break
	
	elif a[i]==b[-(i+1)]:
		cnt+=1
		continue
		
	else:
		print("No")
		break
		
if cnt==min(len(a),len(b)) and len(a)<len(b):
	print("Yes")
	
elif cnt==min(len(a),len(b)) and len(a)>len(b):
	print("No")
def main():
    n = int(input())

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

    for cx in range(0, 101):
        for cy in range(0, 101):
            H = -1
            ll = []
            for i, xyh in enumerate(l):
                x,y,h = xyh
                if H == -1 and h == 0:
                    ll.append(list(x,y,h))
                    continue
                if H == -1:
                    H = h + abs(x-cx) + abs(y-cy)
                    if H < 1 or H != int(H):
                        break
                    continue
                if h != max((H - abs(x-cx) - abs(y-cy)), 0):
                    break
                if i == len(l) - 1:
                    for xx,yy,hh, in ll:
                        if hh != max((H - abs(xx-cx) - abs(yy-cy)), 0):
                            break
                    print(cx,cy,H)
                    return

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    n = int(input())

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

    l.sort(key = lambda x:-x[2])

    for cx in range(0, 101):
        for cy in range(0, 101):
            for i, xyh in enumerate(l):
                x,y,h = xyh
                if i == 0:
                    H = h + abs(x-cx) + abs(y-cy)
                    if H < 1 or H != int(H):
                        break
                    continue
                if h != max((H - abs(x-cx) - abs(y-cy)), 0):
                    break
                if i == n-1:
                    print(cx,cy,H)
                    return

if __name__ == "__main__":
    main()
n = int(input())
a=list(map(int, input().split()))
ans = 1
for i in a:
    ans = ans * i
    if ans == 0:
        print(0)
        exit()
if ans > 10**18:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

a,b = map(int, input().split())
print(a*b)
a,b,k = map(int, input().split())
nums = list(range(a,b+1))
ans = nums[:k] + nums[len(nums)-k:]
for a in sorted(list(set(ans))):
    print(a)


### FIXED CODE ###

a,b,k = map(int, input().split())
tmp = []
for i in range(k):
    if a + i <= b:
        tmp.append(a+i)
    if b - i >= a:
        tmp.append(b-i)

for i in sorted(set(tmp)):
    print(i)
a, p=map(int, input().split())
b=(a/3)+p
if b%2==0:
    print(b/2)
if else:
    print((b-1)/2)

### FIXED CODE ###

a, p=map(int, input().split())
print((a*3+p)//2)
import scipy.special
import math

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

M = m
lst, count = [],[]
for i in range(2,int(math.sqrt(m))+1):
    while M % i == 0:
        M = M // i
        if i not in lst:
            count.append(1)
            lst.append(i)
        else:
            count[-1] += 1
if M > 1:
    lst.append(M)
    count.append(1)       

ans = 1
for i in count:
    ans = ans * scipy.special.comb(i+n-1,i)
    ans = ans % (10**9+7) 

print(int(ans))

### FIXED CODE ###

import scipy.misc
import math

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

M = m
lst, count = [],[]
if M == 1:
    print(1)
else:
    for i in range(2,int(math.sqrt(m))+1):
        while M % i == 0:
            M = M // i
            if i not in lst:
                count.append(1)
                lst.append(i)
            else:
                count[-1] += 1
    if M > 1:
        lst.append(M)
        count.append(1)       

    ans = 1
    for i in count:
        ans = ans * scipy.misc.comb(i+n-1,i, exact=1)
        ans = ans % (10**9+7) 

    print(int(ans))
N = int( input())
T = [ int( input()) for _ in range(N)]
def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a
def lcm(a,b):
    return (a*b)/gcd(a,b)
ans = T[0]
for i in range(1,N):
    ans = int(lcm(ans,T[i]))
print(ans)

### FIXED CODE ###

def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

def lcm(a,b):
    return (a*b)//gcd(a, b)

N = int( input())
T = [ int( input()) for _ in range(N)]
ans = T[0]
for i in range(1,N):
    ans = lcm(ans,T[i])
print(ans)
a = input()
a = a.split(" ")
for num in range(3):
    a[num] = int(a[num])
sum = sum(a)
if sum >= 22:
    print("bust")
else:
    print(win)

### FIXED CODE ###

a = input()
a = a.split(" ")
sum = 0
for num in a:
    sum += int(num)
if sum >= 22:
    print("bust")
else:
    print("win")
N = list(input())
for i in range(2):
  if N[i]=7:
    print("Yes")
  break
else:
  print("No")

### FIXED CODE ###

N = list(input())
for i in range(3):
  if N[i] == "7":
    print("Yes")
    break
else:
  print("No")
s=input()

gu=0
pa=0
win=0

fot t in s:
  if t=='g':
    if gu>pa:
      pa+=1
      win+=1
    else:
      gu+=1
  else:
    if gu>pa:
      pa+=1
    else:
      win-=1
      gu+=1
print(win)
      
    

### FIXED CODE ###

s=input()

gu=0
pa=0
win=0

for t in s:
  if t=='g':
    if gu>pa:
      pa+=1
      win+=1
    else:
      gu+=1
  else:
    if gu>pa:
      pa+=1
    else:
      win-=1
      gu+=1
print(win)
S = input()
chars = set(S)
ans = len(S)

for c in chas :
    m = max(len(_) for _ in S.split(c))
    ans = min(ans, m)

print(ans)

### FIXED CODE ###

S = input()
chars = set(S)
ans = len(S)

for c in chars :
    m = max(len(_) for _ in S.split(c))
    ans = min(ans, m)

print(ans)
from math import gcd

def main():
    A, B = [int(i) for i in input().split()]

    G = gcd(A, B)
    factor = set()
    for i in range(2, G + 1):
        while G % i == 0:
            factor.add(i)
            G = G // i
    print(len(list(factor))+1)


if __name__ == "__main__":
    main()

### FIXED CODE ###

from fractions import gcd
import copy


def coprime2(a, b):
    return gcd(a, b) == 1


def main():
    A, B = [int(i) for i in input().split()]

    A_l = divisor(A)
    B_l = divisor(B)
    AB_l = set()
    for a in A_l:
        if a in B_l:
            AB_l.add(a)
    AB_l = sorted(list(AB_l))
    tmp = set(AB_l)
    ans = []
    for i, a in enumerate(AB_l):
        if a not in tmp:
            continue
        try:
            tmp.remove(a)
        except:
            pass
        for b in list(tmp):
            if gcd(a, b) != 1:
                try:
                    tmp.remove(b)
                except:
                    pass
        else:
            ans.append(a)

    print(len(ans))


def divisor(n):
    i = 1
    table = set()
    while i * i <= n:
        if n % i == 0:
            table.add(i)
            table.add(n//i)
        i += 1
    return table


if __name__ == "__main__":
    main()
print((int(input)-1)*(int(input)-1))

### FIXED CODE ###

a,b=map(int,input().split())
print((a-1)*(b-1))
#
a=int(input())
b=int(input())

p=(a+b)*2
Area=a*b

print(Area,p)



### FIXED CODE ###

a,b=map(int,input().split())
p=(a+b)*2
Area=a*b
print(Area,p)
n=list(input())
for i in range(3):
  if n[i]==1:
    n[i]=9
  else:
    n[i]=1
s=""
for i in range(3):
  s+="n[i]"
print(int(s))

### FIXED CODE ###

n=input()
ans=""
for i in range(3):
  if n[i]=="1":
    ans+="9"
  else:
    ans+="1"
print(ans)
def get_area(a, b):
  return a*b

def get_length(a, b):
  return a*2+b*2

def main(l):
  a = l[0]
  b = l[1]
  area = get_area(a, b)
  length = get_length(a, b)
  print str(a)+' '+str(b)


l = raw_input().split(' ')
main(l)

### FIXED CODE ###

def get_area(a, b):
  return a*b

def get_length(a, b):
  return a*2+b*2

def main(l):
  a = int(l[0])
  b = int(l[1])
  area = get_area(a, b)
  length = get_length(a, b)
  print str(area)+' '+str(length)


l = raw_input().split(' ')
main(l)
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 21 12:22:32 2019

@author: ctiuser
"""
import sys

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

if M & 1:
    print(-1)
    sys.exit()    

T = [[] for _ in range(N+1)]
for a,b in AB:
    T[a].append(b)
    T[b].append(a)

visited = [False] * (N+1)
tree = [set([]) for _ in range(N+1)]
def dfs(x=1):
    for c in T[x]:
        if visited[c]:
            continue
        tree[x].add(c)
        tree[c].add(x)
        visited[c] = True
        dfs(c)
dfs()

counta = [0] * (N+1)
ans = []
for a,b in AB:
    if b in tree[a]:
        continue
    ans.append('{} {}'.format(a,b))
    counta[a] += 1

def dfs2(x=1, parent = None):
    for y in tree[x]:
        if y == parent:
            continue
#        print(x,y)
        dfs2(y,x)
        if counta[y]&1:
            ans.append('{} {}'.format(y,x))
            counta[y] += 1
        else:
            ans.append('{} {}'.format(x,y))
            counta[x] += 1
#        print(x,y,counta)
dfs2()
for i in range(M):
    print(ans[i])

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Thu Jul 18 12:05:59 2019

@author: ctiuser
"""
import sys
sys.setrecursionlimit(10**6)

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

if M % 2 == 1:
    print(-1)
    sys.exit()

class UnionFind():
    def __init__(self,size):
        self.table = [-1 for i in range(size+1)]
    def find(self,x):
        if self.table[x] < 0:
            return x
        else:
            return self.find(self.table[x])
    def union(self,x,y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 == s2:
            return False
        if self.table[s1] < self.table[s2]:
            self.table[s1] = self.table[s1] + self.table[s2]
            self.table[s2] = self.find(x)
        else:
            self.table[s2] = self.table[s1] + self.table[s2]
            self.table[s1] = self.find(y)
        return True

UF = UnionFind(N)
ans = []
T = [[-1] for i in range(N+1)]
color = [-1 for i in range(N+1)]
counta = [0 for i in range(N+1)]
B = []
C = [[] for i in range(N+1)]
for c in A:
    if UF.union(c[0],c[1]):
        B.append(c)
        C[c[0]].append(c[1])
        C[c[1]].append(c[0])
    else:
        ans.append(c)
        counta[c[0]] += 1

def b(x):
    color[x] = 1
    for c in C[x]:
        if color[c] == -1:
            T[c][0] = x
            T[x].append(c)
            b(c)
b(1)

edge_leaf = []
for i in range(1,N+1):
    if len(T[i]) == 1:
        edge_leaf.append(i)

def a(x):
    p = T[x][0]
    if p == -1:
        return 0
    if counta[x] % 2 == 0:
        ans.append([p,x])
        counta[p] += 1
    else:
        ans.append([x,p])
    return p

for c in edge_leaf:
    point = c
    while color[point] == len(T[point]):
        point = a(point)
        color[point] += 1


for c in ans:
    print(' '.join(map(str,c)))