# 文字列も <, <=, >, >= 演算子で比較できる。
f1, f2 = input().split()
if f1 < f2:
print("up")
else:
print("down")
e1, e2 = map(int, input().split())
S = e1 * e2
if S > 0:
print(S)
else:
print("invalid")
n = int(input())
bag = [] # 購入アイテムを記録するlist
S = 0# 購入アイテムの合計金額for _ in range(n):
c, p = input().split()
bag.append(c)
S += int(p)
if ("pants"in bag) and (S >=2000):
print(S - 500)
else:
print(S)