# Arup Guha
# 1/25/2025
# Solution to Kattis Problem: Equal Shots
# https://open.kattis.com/problems/equalshots

# Get basic input.
toks = input().split()
n = int(toks[0])
m = int(toks[1])

# Get total alcohol in first group
tot1 = 0
for i in range(n):
    vals = [int(x) for x in input().split()]
    tot1 += vals[0]*vals[1]

# Get total alcohol in second group
tot2 = 0
for i in range(m):
    vals = [int(x) for x in input().split()]
    tot2 += vals[0]*vals[1]

# Ta da!
if tot1 == tot2:
    print("same")
else:
    print("different")
