[Image] 

Walking through the streets of Marshmallow City, Slastyona have spotted some merchants selling a kind of useless toy which is very popular nowadays – caramel spinner! Wanting to join the craze, she has immediately bought the strange contraption.

Spinners in Sweetland have the form of V-shaped pieces of caramel. Each spinner can, well, spin around an invisible magic axis. At a specific point in time, a spinner can take 4 positions shown below (each one rotated 90 degrees relative to the previous, with the fourth one followed by the first one):

 [Image] 

After the spinner was spun, it starts its rotation, which is described by a following algorithm: the spinner maintains its position for a second then majestically switches to the next position in clockwise or counter-clockwise order, depending on the direction the spinner was spun in.

Slastyona managed to have spinner rotating for exactly n seconds. Being fascinated by elegance of the process, she completely forgot the direction the spinner was spun in! Lucky for her, she managed to recall the starting position, and wants to deduct the direction given the information she knows. Help her do this.


-----Input-----

There are two characters in the first string – the starting and the ending position of a spinner. The position is encoded with one of the following characters: v (ASCII code 118, lowercase v), < (ASCII code 60), ^ (ASCII code 94) or > (ASCII code 62) (see the picture above for reference). Characters are separated by a single space.

In the second strings, a single number n is given (0 ≤ n ≤ 10^9) – the duration of the rotation.

It is guaranteed that the ending position of a spinner is a result of a n second spin in any of the directions, assuming the given starting position.


-----Output-----

Output cw, if the direction is clockwise, ccw – if counter-clockwise, and undefined otherwise.


-----Examples-----
Input
^ >
1

Output
cw

Input
< ^
3

Output
ccw

Input
^ v
6

Output
undefined

Source: codeforces | Difficulty: EASY
Tags: Implementation


Solutions:
(s, e) = map(ord, input().split())
n = int(input())
c = [94, 62, 118, 60]
if n % 2 == 0:
	print('undefined')
else:
	si = c.index(s)
	ei = c.index(e)
	d = ei - si
	if d == -3 or d == 1:
		if n == 1:
			print('cw')
		elif int((n - 1) / 2) % 2 == 1:
			print('ccw')
		else:
			print('cw')
	elif d == 3 or d == -1:
		if n == 1:
			print('ccw')
		elif int((n - 1) / 2) % 2 == 1:
			print('cw')
		else:
			print('ccw')


(a, b) = input().split()
n = int(input())
d = {'^': 0, '>': 1, 'v': 2, '<': 3}
e = {'^': 0, '>': 3, 'v': 2, '<': 1}
f1 = f2 = 0
if (d[a] + n) % 4 == d[b]:
	f1 = 1
if (e[a] + n) % 4 == e[b]:
	f2 = 1
if f1 and f2:
	print('undefined')
else:
	print('cw' if f1 else 'ccw')


def NextR(c):
	if c == 'v':
		return '<'
	if c == '<':
		return '^'
	if c == '^':
		return '>'
	if c == '>':
		return 'v'

def NextL(c):
	if c == 'v':
		return '>'
	if c == '>':
		return '^'
	if c == '^':
		return '<'
	if c == '<':
		return 'v'
(c1, c2) = input().split()
n = int(input())
nn = n % 4
cr = cl = c1
for i in range(nn):
	cl = NextR(cl)
for i in range(nn):
	cr = NextL(cr)
if cl == cr:
	print('undefined')
	raise SystemExit
if cl != c2 and cr != c2:
	print('undefined')
	raise SystemExit
if cl == c2:
	print('cw')
else:
	print('ccw')


[start, end] = [x for x in input().split()]
duration = int(input())
cw = ['v', '<', '^', '>']
ccw = ['v', '>', '^', '<']
cw_bool = end == cw[(cw.index(start) + duration) % 4]
ccw_bool = end == ccw[(ccw.index(start) + duration) % 4]
if cw_bool and ccw_bool:
	print('undefined')
elif cw_bool:
	print('cw')
else:
	print('ccw')


(s, e) = input().split()
d = dict()
d['^'] = 0
d['<'] = 1
d['v'] = 2
d['>'] = 3
n = int(input()) % 4
s = d[s]
e = d[e]
l = 0
r = 0
if (n + s) % 4 == e:
	l = 1
if (s - n) % 4 == e:
	r = 1
if l + r == 2:
	print('undefined')
elif r == 1:
	print('cw')
else:
	print('ccw')


(first, last) = input().split()
n = int(input())
directions = {'^': 0, '>': 1, 'v': 2, '<': 3}
first = directions[first]
last = directions[last]
cw = False
ccw = False
if (last - first) % 4 == n % 4:
	cw = True
if (first - last) % 4 == n % 4:
	ccw = True
if ccw and (not cw):
	print('ccw')
elif cw and (not ccw):
	print('cw')
else:
	print('undefined')


(d, s, n) = ('^>v<', input(), int(input()))
if n % 2 == 0:
	print('undefined')
elif (d.find(s[0]) + n) % 4 == d.find(s[2]):
	print('cw')
else:
	print('ccw')


(start, end) = input().split()
n = int(input())
arr = ['^', '>', 'v', '<']
ind1 = 0
ind2 = 0
for i in range(4):
	if arr[i] == start:
		ind1 = i
	if arr[i] == end:
		ind2 = i
if ind2 >= ind1:
	diff1 = ind2 - ind1
else:
	diff1 = 4 + (ind2 - ind1)
if ind1 >= ind2:
	diff2 = ind1 - ind2
else:
	diff2 = 4 + (ind1 - ind2)
flag1 = 0
flag2 = 0
if n % 4 == diff1:
	flag1 = 1
if n % 4 == diff2:
	flag2 = 1
if flag1 == 1 and flag2 == 1:
	print('undefined')
elif flag1 == 1:
	print('cw')
elif flag2 == 1:
	print('ccw')
else:
	print('undefined')


s = input().split()
k = int(input()) % 4
pos = ['^', '>', 'v', '<']
if s[0] == '^':
	st = 1
elif s[0] == '>':
	st = 2
elif s[0] == 'v':
	st = 3
else:
	st = 4
if s[1] == '^':
	fin = 1
elif s[1] == '>':
	fin = 2
elif s[1] == 'v':
	fin = 3
else:
	fin = 4
if abs(st - fin) == 2 or st - fin == 0:
	print('undefined')
elif (st - fin) % 4 == k:
	print('ccw')
else:
	print('cw')


(initial, final) = input().split()
(cw_res, ccw_res) = (initial, initial)
n = int(input())
n = n % 4
ccw = {'<': 'v', '>': '^', 'v': '>', '^': '<'}
cc = {'<': '^', '>': 'v', '^': '>', 'v': '<'}
for i in range(n):
	cw_res = cc[cw_res]
	ccw_res = ccw[ccw_res]
if cw_res == ccw_res:
	print('undefined')
elif cw_res == final:
	print('cw')
else:
	print('ccw')


def read(is_int, split_by):
	if is_int:
		return [int(x) for x in input().split(split_by)]
	else:
		return [x for x in input().split(split_by)]
(s, f) = read(False, ' ')
n = int(input())
seq = ['<', '^', '>', 'v']
k = n % 4
spin = 'undefined'
ind_s = seq.index(s)
ind_f = seq.index(f)
if not s == f:
	if not k % 2 == 0:
		remind = (ind_s + k) % 4
		if f == seq[remind]:
			spin = 'cw'
		remind = (ind_s - k) % 4
		if f == seq[remind]:
			spin = 'ccw'
print(spin)


(s, f) = input().split(' ')
n = int(input())
cw = {'^': 1, '>': 2, 'v': 3, '<': 0}
ccw = {'^': 1, '>': 0, 'v': 3, '<': 2}
a = (cw[s] + n) % 4
b = (ccw[s] + n) % 4
if a == cw[f] and b == ccw[f]:
	print('undefined')
elif a == cw[f]:
	print('cw')
elif b == ccw[f]:
	print('ccw')
else:
	print('undefined')


(s, e) = map(str, input().split())
n = int(input())

def clk(st, n, lis):
	sti = lis.index(st)
	n = n % 4
	p = 3 - sti
	if n <= p:
		return lis[sti + n]
	else:
		n = n - p
		return lis[n - 1]

def aclk(st, n, lis):
	sti = lis.index(st)
	n = n % 4
	if n <= sti:
		return lis[sti - n]
	else:
		n = n - sti
		return lis[-n]
lis = ['v', '<', '^', '>']
ck = clk(s, n, lis)
ack = aclk(s, n, lis)
if ck == e and ack != e:
	print('cw')
elif ack == e and ck != e:
	print('ccw')
else:
	print('undefined')


a = input()
a = a.split()
b = a[1]
a = a[0]
n = int(input())
d = ['v', '<', '^', '>']
z = d.index(a) + 1 - 1
c = d.index(b) + 1 - 1
h = n % 4
u = d[z - h]
result = []
if u == d[c]:
	result.append('ccw')
p = d[(h + z) % 4]
if p == d[c]:
	result.append('cw')
if len(result) != 1:
	print('undefined')
else:
	print(result[0])


def main():
	(a, b) = ('v<^>'.index(c) for c in input()[::2])
	n = int(input())
	print(('cw', 'ccw')[not (n - a + b) % 4] if n % 2 else 'undefined')
main()


(a, b) = map(str, input().split())
c = int(input())
toy = 'v<^>'
if c % 2 == 0:
	print('undefined')
elif (toy.find(a) + c) % 4 == toy.find(b):
	print('cw')
else:
	print('ccw')


arrows_dir = {'v': 0, '<': 1, '^': 2, '>': 3}
(st, en) = input().strip().split()
arrows = ['v', '<', '^', '>']
st_pos = arrows_dir[st]
en_pos = int(input()) % 4
if arrows[(st_pos + en_pos) % 4] == en and arrows[st_pos - en_pos] == en:
	print('undefined')
elif arrows[(st_pos + en_pos) % 4] == en:
	print('cw')
elif arrows[st_pos - en_pos] == en:
	print('ccw')
else:
	print('undefined')


s = input()
n = int(input()) % 4
if n == 0 or n == 2:
	print('undefined')
elif n == 1:
	if s in ('^ >', '> v', 'v <', '< ^'):
		print('cw')
	else:
		print('ccw')
elif s in ('^ >', '> v', 'v <', '< ^'):
	print('ccw')
else:
	print('cw')


(first, final) = input().split()
n = int(input()) % 4
cw = first
cww = first
if n == 0:
	print('undefined')
else:
	for _ in range(n):
		if cw == '^':
			cw = '>'
		elif cw == '>':
			cw = 'v'
		elif cw == 'v':
			cw = '<'
		else:
			cw = '^'
		if cww == '^':
			cww = '<'
		elif cww == '<':
			cww = 'v'
		elif cww == 'v':
			cww = '>'
		else:
			cww = '^'
	if cw == cww:
		print('undefined')
	elif final == cw:
		print('cw')
	elif final == cww:
		print('ccw')
	else:
		print('undefined')


(st, en) = map(str, input().split())
n = int(input())
n %= 4
m = {'^': 1, '>': 2, 'v': 3, '<': 4}
if (m[st] + m[en]) % 4 == 2 or (m[st] + m[en]) % 4 == 0:
	print('undefined')
elif (m[st] + n) % 4 == m[en] or m[st] + n == m[en]:
	print('cw')
else:
	print('ccw')


l = list(map(str, input().strip().split(' ')))
x = int(input()) % 4
a = l[0]
b = l[1]
l1 = ['<', '^', '>', 'v']
l2 = ['<', 'v', '>', '^']
i1 = l1.index(a)
i2 = l2.index(a)
if l1[(i1 + x) % 4] == b and l2[(i2 + x) % 4] != b:
	print('cw')
elif l2[(i2 + x) % 4] == b and l1[(i1 + x) % 4] != b:
	print('ccw')
else:
	print('undefined')


(s, t) = ['v<^>'.index(x) for x in input().split()]
n = int(input())
cw = (n + s - t) % 4 == 0
ccw = (n + t - s) % 4 == 0
if cw and (not ccw):
	print('cw')
elif not cw and ccw:
	print('ccw')
else:
	print('undefined')


s = input()
n = int(input())
if n % 2 == 0:
	print('undefined')
else:
	a = {'118': 0, '60': 1, '94': 2, '62': 3}
	(x, y) = ((a[str(ord(s[0]))] + n) % 4, a[str(ord(s[2]))])
	if x == y:
		print('cw')
	else:
		print('ccw')


(a, b) = input().split()
n = int(input())
if a == '^':
	a1 = 1
elif a == '<':
	a1 = 2
elif a == 'v':
	a1 = 3
elif a == '>':
	a1 = 4
if b == '^':
	b1 = 1
elif b == '<':
	b1 = 2
elif b == 'v':
	b1 = 3
elif b == '>':
	b1 = 4
n = n % 4
a2 = a1 - n
a3 = a1 + n
if a2 <= 0:
	a2 = a2 + 4
if a3 > 4:
	a3 = a3 - 4
if (b1 == a2) & (b1 != a3):
	print('cw')
elif (b1 != a2) & (b1 == a3):
	print('ccw')
else:
	print('undefined')


arr = list(input().strip().split())
n = int(input())
d = {'^': 0, '<': 1, 'v': 2, '>': 3}
if arr[0] == arr[1] or ((d[arr[0]] + n) % 4 == d[arr[1]] and (d[arr[1]] + n) % 4 == d[arr[0]]):
	print('undefined')
elif (d[arr[0]] + n) % 4 == d[arr[1]]:
	print('ccw')
elif (d[arr[1]] + n) % 4 == d[arr[0]]:
	print('cw')
else:
	print('undefined')


s = input()
n = int(input())
d = {}
d['^'] = 0
d['>'] = 1
d['v'] = 2
d['<'] = 3
if n % 4 == 2 or n % 4 == 0:
	print('undefined')
else:
	sum = (d[s[2]] - d[s[0]] + 4) % 4
	if sum == n % 4:
		print('cw')
	else:
		print('ccw')


t = input()
ccwpos = ['> ^', '< v', '^ <', 'v >']
cwpos = ['< ^', '^ >', '> v', 'v <']
n = int(input())
if t in ccwpos:
	if (n - 1) % 4 == 0:
		print('ccw')
	else:
		print('cw')
elif t in cwpos:
	if (n - 1) % 4 == 0:
		print('cw')
	else:
		print('ccw')
else:
	print('undefined')


import array
import bisect
import collections
import copy
import fractions
import functools
import heapq
import itertools
import math
import operator
import os
import re
import random
import string
import subprocess
import sys
import time
import unittest
from io import StringIO
from pprint import pprint

def main():
	iterator = iter(sys.stdin.read().split())
	a = next(iterator)
	b = next(iterator)
	n = int(next(iterator))
	n %= 4
	s = 'v<^>'
	p1 = s.find(a)
	p2 = s.find(b)
	if (p2 - p1) % 4 == n and (p1 - p2) % 4 == n:
		print('undefined')
	elif (p2 - p1) % 4 == n:
		print('cw')
	elif (p1 - p2) % 4 == n:
		print('ccw')
	else:
		print('undefined')
main()


ordem = 'v<^>'
entrada = input()
c = entrada[0]
f = entrada[2]
n = int(input()) % 4
for i in range(len(ordem)):
	if ordem[i] == c:
		posComeco = i
		break
cw = (posComeco + n) % 4
ccw = (posComeco - n) % 4
if n % 2 == 0:
	print('undefined')
elif f == ordem[cw]:
	print('cw')
elif f == ordem[ccw]:
	print('ccw')


s = list(map(str, input().split()))
n = int(input())
re = n % 4
if s[0] == '^':
	if re == 1:
		if s[1] == '>':
			print('cw')
		else:
			print('ccw')
	elif re == 3:
		if s[1] == '<':
			print('cw')
		else:
			print('ccw')
	else:
		print('undefined')
elif s[0] == '>':
	if re == 1:
		if s[1] == 'v':
			print('cw')
		else:
			print('ccw')
	elif re == 3:
		if s[1] == '^':
			print('cw')
		else:
			print('ccw')
	else:
		print('undefined')
elif s[0] == 'v':
	if re == 1:
		if s[1] == '<':
			print('cw')
		else:
			print('ccw')
	elif re == 3:
		if s[1] == '>':
			print('cw')
		else:
			print('ccw')
	else:
		print('undefined')
elif s[0] == '<':
	if re == 1:
		if s[1] == '^':
			print('cw')
		else:
			print('ccw')
	elif re == 3:
		if s[1] == 'v':
			print('cw')
		else:
			print('ccw')
	else:
		print('undefined')


(b, e) = input().split()
n = int(input()) % 4
l = ['v', '>', '^', '<']
b = l.index(b)
e = l.index(e)
bccw = b
bcw = b
for _ in range(n):
	bccw = (bccw + 1) % 4
	bcw = (bcw - 1 + 4) % 4
if bccw == bcw or (bccw != e and bcw != e):
	print('undefined')
elif bccw == e:
	print('ccw')
else:
	print('cw')


import sys

def main():
	iterator = iter(sys.stdin.read().split())
	a = next(iterator)
	b = next(iterator)
	n = int(next(iterator))
	n %= 4
	s = 'v<^>'
	p1 = s.find(a)
	p2 = s.find(b)
	if (p2 - p1) % 4 == n and (p1 - p2) % 4 == n:
		print('undefined')
	elif (p2 - p1) % 4 == n:
		print('cw')
	elif (p1 - p2) % 4 == n:
		print('ccw')
	else:
		print('undefined')
main()


spinner_cw = ['^', '>', 'v', '<']
spinner_ccw = ['^', '<', 'v', '>']
ip = input().split()
start = ip[0]
end = ip[1]
n = int(input())
ix_cw = spinner_cw.index(start)
ix_ccw = spinner_ccw.index(start)
if spinner_cw[(ix_cw + n) % 4] == end and spinner_ccw[(ix_ccw + n) % 4] == end:
	print('undefined')
elif spinner_cw[(ix_cw + n) % 4] == end:
	print('cw')
else:
	print('ccw')


(a, b) = input().split()
n = int(input())
s = '^>v<^>v'
if n & 1:
	if b == s[s.find(a) + (n & 3)]:
		print('cw')
	else:
		print('ccw')
else:
	print('undefined')


(s1, s2) = input().split()
n = int(input()) % 4
i1 = '^>v<'.index(s1)
i2 = '^>v<'.index(s2)
delta = (i2 - i1) % 4
if n & 1 == 0:
	print('undefined')
elif delta == n:
	print('cw')
else:
	print('ccw')


dirs = ['v', '<', '^', '>']
(a, b) = map(dirs.index, input().split())
k = (b - a + 4) % 4
n = int(input())
if k == 0 or k == 2:
	print('undefined')
elif k == n % 4:
	print('cw')
else:
	print('ccw')


a = input().split(' ')
n = int(input())
(st, end) = (a[0], a[1])
cw = ['^', '>', 'v', '<']
ccw = ['^', '<', 'v', '>']
(i, j) = (cw.index(st), ccw.index(st))
if cw[(i + n % 4) % 4] == end and ccw[(j + n % 4) % 4] == end:
	print('undefined')
elif cw[(i + n % 4) % 4] == end:
	print('cw')
elif ccw[(j + n % 4) % 4] == end:
	print('ccw')
else:
	print('undefined')


cw = [60, 94, 62, 118]
ccw = [60, 118, 62, 94]
(i, f) = map(ord, input().split())
n = int(input())
ans = 'undefined'
index_i = cw.index(i)
index_f = cw.index(f)
if (index_i + n) % 4 == index_f:
	ans = 'cw'
index_i = ccw.index(i)
index_f = ccw.index(f)
if (index_i + n) % 4 == index_f:
	if ans == 'undefined':
		ans = 'ccw'
	else:
		ans = 'undefined'
print(ans)


(s, e) = input().split()
n = int(input()) % 4
directions = ['^', '>', 'v', '<']

def find(x):
	for (idx, i) in enumerate(directions):
		if i == x:
			return idx
if n % 2 == 0:
	print('undefined')
else:
	start_idx = find(s)
	if directions[(start_idx + n) % 4] == e:
		print('cw')
	else:
		print('ccw')


def solve(s, n, seq):
	x = seq.find(s[0])
	y = seq[x + n]
	return y == s[2]

def main():
	cw = '^>v<' * 10
	ccw = '^<v>' * 10
	s = input()
	n = int(input())
	x = solve(s, n % 4, cw)
	y = solve(s, n % 4, ccw)
	if x and y:
		print('undefined')
	elif x:
		print('cw')
	elif y:
		print('ccw')
	else:
		print('undefined')
main()


(a, b) = input().split()
n = int(input())
n %= 4
if n % 2 == 0:
	print('undefined')
	exit()
(a, b) = (ord(a), ord(b))
d = {118: 60, 60: 94, 94: 62, 62: 118}
if n == 1:
	if d[a] == b:
		print('cw')
	else:
		print('ccw')
elif d[a] == b:
	print('ccw')
else:
	print('cw')


arr = [chr(118), chr(60), chr(94), chr(62)]
(a, b) = input().split()
n = int(input())
n = n % 4
x = arr.index(a)
o = arr[(x + n) % 4]
p = arr[(x + 4 - n) % 4]
if o == p:
	print('undefined')
elif o == b:
	print('cw')
else:
	print('ccw')


(s, f) = input().split()
n = int(input())
spinner = ['v', '<', '^', '>']
if spinner[(spinner.index(s) + n) % 4] == spinner[(spinner.index(s) - n) % 4] == f:
	print('undefined')
elif spinner[(spinner.index(s) + n) % 4] == f:
	print('cw')
else:
	print('ccw')


poss = {'^': 0, '>': 1, 'v': 2, '<': 3}
(sp, ep) = input().split()
ss = int(input())
sp = poss[sp]
ep = poss[ep]
ss = ss % 4
if ss % 2 == 0:
	print('undefined')
elif (sp + ss) % 4 == ep:
	print('cw')
else:
	print('ccw')


string = input()
s = string[0]
a = string[2]
n = int(input())
b = n % 4
if s == '>':
	if a == '^':
		if b == 1:
			print('ccw')
		else:
			print('cw')
	elif a == 'v':
		if b == 3:
			print('ccw')
		else:
			print('cw')
	else:
		print('undefined')
elif s == '<':
	if a == '^':
		if b == 1:
			print('cw')
		else:
			print('ccw')
	elif a == 'v':
		if b == 3:
			print('cw')
		else:
			print('ccw')
	else:
		print('undefined')
elif s == '^':
	if a == '>':
		if b == 1:
			print('cw')
		else:
			print('ccw')
	elif a == '<':
		if b == 3:
			print('cw')
		else:
			print('ccw')
	else:
		print('undefined')
elif a == '>':
	if b == 1:
		print('ccw')
	else:
		print('cw')
elif a == '<':
	if b == 3:
		print('ccw')
	else:
		print('cw')
else:
	print('undefined')


(M, A) = map(str, input().split())
N = int(input())
Dee = ['v', '<', '^', '>']
P = Dee.index(M)
Q = Dee.index(A)
if N % 4 == 2 or N % 4 == 0:
	print('undefined')
	exit()
elif (Q - P) % 4 == N % 4:
	print('cw')
	exit()
else:
	print('ccw')
	exit()


s = ['^', '>', 'v', '<']
fe = input()
(f, e) = fe.split()
n = int(input())
b = s.index(f)
e = s.index(e)
if n % 2 == 0:
	print('undefined')
else:
	n = n % 4
	if (b + n) % 4 == e:
		print('cw')
	else:
		print('ccw')


(start, stop) = input().split()
n = int(input())
d = {'v': 2, '<': 3, '^': 0, '>': 1}
if (d[start] + n) % 4 == d[stop]:
	clockwise = True
else:
	clockwise = False
if (d[start] - n) % 4 == d[stop]:
	counter_clockwise = True
else:
	counter_clockwise = False
if counter_clockwise and clockwise:
	print('undefined')
elif clockwise:
	print('cw')
else:
	print('ccw')


(k, m) = input().split()
n = int(input())
n %= 4
a = ['v', '<', '^', '>', 'v', '<', '^', '>']
if n == 2 or n == 0:
	print('undefined')
if n == 1:
	if m == a[a.index(k) + 1]:
		print('cw')
	else:
		print('ccw')
if n == 3:
	if m == a[a.index(k) + 3]:
		print('cw')
	else:
		print('ccw')


positions = {'v': 0, '<': 1, '^': 2, '>': 3}
q = input().split()
n = int(input())
start = positions.get(q[0])
finish = positions.get(q[1])
if n % 2 == 0:
	print('undefined')
elif (start + n) % 4 == finish:
	print('cw')
else:
	print('ccw')


posiciones = input()
tiempo = int(input())
posiciones = posiciones.split(' ')
inicio = posiciones[0]
final = posiciones[1]
dict = ['^', '>', 'v', '<']
if tiempo > 4:
	tiempo = tiempo % 4
contador_izq = dict.index(inicio)
for n in range(tiempo):
	if contador_izq - 1 < 0:
		contador_izq = 3
	else:
		contador_izq -= 1
contador_der = dict.index(inicio)
for n in range(tiempo):
	if contador_der + 1 > 3:
		contador_der = 0
	else:
		contador_der += 1
if posiciones[1] == dict[contador_izq] and posiciones[1] != dict[contador_der]:
	print('ccw')
elif posiciones[1] != dict[contador_izq] and posiciones[1] == dict[contador_der]:
	print('cw')
else:
	print('undefined')


a = str(input())
t = int(input())
t1 = t % 4
if t1 == 0:
	print('undefined')
if t1 == 1:
	if a == '^ >' or a == '> v' or a == 'v <' or (a == '< ^'):
		print('cw')
	else:
		print('ccw')
if t1 == 2:
	print('undefined')
if t1 == 3:
	if a == '^ >' or a == '> v' or a == 'v <' or (a == '< ^'):
		print('ccw')
	else:
		print('cw')


s = input()
n = int(input()) % 4
p = {'^': 0, '>': 1, 'v': 2, '<': 3}
if n % 2 == 0:
	print('undefined')
elif (p[s[0]] + n) % 4 == p[s[2]]:
	print('cw')
else:
	print('ccw')


def main():
	(start, end) = input().split()
	time = int(input())
	clock = 'v<^>'
	if not time % 2:
		print('undefined')
	elif clock[(clock.index(start) + time) % 4] == end:
		print('cw')
	else:
		print('ccw')
main()


d = {}
d[chr(118)] = 0
d[chr(60)] = 1
d[chr(94)] = 2
d[chr(62)] = 3
s = input()
i = d[s[0]]
f = d[s[2]]
delta = int(input()) % 4
if (i + 1) % 4 == f or (i - 1) % 4 == f:
	if (i + delta) % 4 == f:
		print('cw')
	else:
		print('ccw')
else:
	print('undefined')


(x, y) = input().split()
n = int(input())
if n % 2 == 0:
	print('undefined')
else:
	k = ord(x) - ord(y)
	if n % 4 == 1:
		if k == 58 or k == -34 or k == 32 or (k == -56):
			print('cw')
		else:
			print('ccw')
	elif k == -58 or k == 34 or k == -32 or (k == 56):
		print('cw')
	else:
		print('ccw')


import sys
a = list(input().split(' '))
t = int(input())
x = t % 4
if x == 1:
	if ord(a[0]) == 94 and ord(a[1]) == 62:
		print('cw')
		sys.exit(0)
	elif ord(a[0]) == 62 and ord(a[1]) == 118:
		print('cw')
		sys.exit(0)
	elif ord(a[0]) == 118 and ord(a[1]) == 60:
		print('cw')
		sys.exit(0)
	elif ord(a[0]) == 60 and ord(a[1]) == 94:
		print('cw')
	else:
		print('ccw')
elif x == 3:
	if ord(a[0]) == 94 and ord(a[1]) == 60:
		print('cw')
		sys.exit(0)
	elif ord(a[0]) == 62 and ord(a[1]) == 94:
		print('cw')
		sys.exit(0)
	elif ord(a[0]) == 118 and ord(a[1]) == 62:
		print('cw')
		sys.exit(0)
	elif ord(a[0]) == 60 and ord(a[1]) == 118:
		print('cw')
		sys.exit(0)
	else:
		print('ccw')
		sys.exit(0)
else:
	print('undefined')


li = input().split()
n = int(input())
j = n % 4
flag = 0
anti_clockwise = '^<v>^<v>'
clockwise = '^>v<^>v<'
dict1 = {'^': 'v', 'v': '^', '>': '<', '<': '>'}
if j == 0 or li[-1] == dict1[li[0]]:
	print('undefined')
else:
	k = anti_clockwise.index(li[0])
	if anti_clockwise[k + j] == li[-1]:
		print('ccw')
	else:
		print('cw')


def ri():
	return int(input())

def rli():
	return list(map(int, input().split()))

def ris():
	return list(input())

def pli(a):
	return ''.join(list(map(str, a)))

def plis(a):
	return ' '.join(list(map(str, a)))
di = ['v', '<', '^', '>']
(s, e) = input().split()
n = ri() % 4
s = di.index(s)
e = di.index(e)
iscw = True
if n == 0 or n == 2:
	print('undefined')
elif n == 1:
	if s - e == 1 or s - e == -3:
		iscw = False
	print('cw' if iscw else 'ccw')
else:
	if e - s == 1 or e - s == -3:
		iscw = False
	print('cw' if iscw else 'ccw')


def str_to_int(s):
	if s == '^':
		return 0
	if s == '>':
		return 1
	if s == 'v':
		return 2
	if s == '<':
		return 3
inputlist = list(map(str_to_int, input().strip().split(' ')))
start = inputlist[0]
end = inputlist[1]
duration = int(input())
if (start + duration) % 4 == end and (start - duration) % 4 != end:
	print('cw')
elif (start - duration) % 4 == end and (start + duration) % 4 != end:
	print('ccw')
else:
	print('undefined')


start_end = input().strip()
time = int(input().strip())
start = start_end.split()[0]
end = start_end.split()[1]
start_dir = -1
end_dir = -1
if start == '<':
	start_dir = 0
elif start == '^':
	start_dir = 1
elif start == '>':
	start_dir = 2
elif start == 'v':
	start_dir = 3
if end == '<':
	end_dir = 0
elif end == '^':
	end_dir = 1
elif end == '>':
	end_dir = 2
elif end == 'v':
	end_dir = 3
turns = time
ccw = False
cw = False
if start_dir == end_dir or start_dir % 2 == end_dir % 2:
	print('undefined')
elif (start_dir + turns) % 4 == end_dir:
	print('cw')
else:
	print('ccw')


(start, end) = [str(x) for x in input().split()]
n = int(input())
spinner_sides = ['^', '>', 'v', '<']

def get_side(spinner):
	if spinner == '^':
		return 0
	elif spinner == '>':
		return 1
	elif spinner == 'v':
		return 2
	else:
		return 3
n = n % 4
if n % 2 == 0:
	print('undefined')
	exit()
else:
	curr_side = get_side(start)
	while n:
		curr_side = (curr_side + 1) % 4
		n -= 1
	if spinner_sides[curr_side] == end:
		print('cw')
	else:
		print('ccw')


rotations = {'ccw': {'<': '<v>^', 'v': 'v>^<', '>': '>^<v', '^': '^<v>'}, 'cw': {'<': '<^>v', '^': '^>v<', '>': '>v<^', 'v': 'v<^>'}}
(start, end) = list(input().split(' '))
seconds = int(input())
isCCW = rotations['ccw'][start][seconds % 4] == end
isCW = rotations['cw'][start][seconds % 4] == end
if isCCW and (not isCW):
	print('ccw')
elif isCW and (not isCCW):
	print('cw')
else:
	print('undefined')


from collections import deque

def main():
	(START, END) = input().split()
	N = int(input())
	cw = deque('v<^>')
	while True:
		if cw[0] == START:
			break
		else:
			cw.rotate(1)
	ccw = deque(cw)
	n = N % 4
	for i in range(n):
		cw.rotate(-1)
		ccw.rotate(1)
	if cw[0] == ccw[0]:
		print('undefined')
	elif cw[0] == END:
		print('cw')
	else:
		print('ccw')
main()


while True:
	try:
		(a, b) = input().split()
		c = int(input())
		c %= 4
		s = n = 0
		if a == '>':
			if c == 3:
				a = '^'
			elif c == 1:
				a = 'v'
			elif c == 2:
				a = '<'
			if a == b:
				s = 1
			a = '>'
			if c == 3:
				a = 'v'
			elif c == 1:
				a = '^'
			elif c == 2:
				a = '<'
			if a == b:
				n = 1
		elif a == 'v':
			if c == 3:
				a = '>'
			elif c == 1:
				a = '<'
			elif c == 2:
				a = '^'
			if a == b:
				s = 1
			a = 'v'
			if c == 3:
				a = '<'
			elif c == 1:
				a = '>'
			elif c == 2:
				a = '^'
			if a == b:
				n = 1
		elif a == '<':
			if c == 3:
				a = 'v'
			elif c == 1:
				a = '^'
			elif c == 2:
				a = '>'
			if a == b:
				s = 1
			a = '<'
			if c == 3:
				a = '^'
			elif c == 1:
				a = 'v'
			elif c == 2:
				a = '>'
			if a == b:
				n = 1
		elif a == '^':
			if c == 3:
				a = '<'
			elif c == 1:
				a = '>'
			elif c == 2:
				a = 'v'
			if a == b:
				s = 1
			a = '^'
			if c == 3:
				a = '>'
			elif c == 1:
				a = '<'
			elif c == 2:
				a = 'v'
			if a == b:
				n = 1
		if s == 1 and n != 1:
			print('cw')
		if s != 1 and n == 1:
			print('ccw')
		if s == 1 and n == 1:
			print('undefined')
	except EOFError:
		break


read = lambda : map(int, input().split())
(a, b) = input().split()
n = int(input()) % 4
s = 'v<^>'
k1 = (s.index(b) - s.index(a)) % 4
k2 = (s.index(a) - s.index(b)) % 4
print('cw' if k1 == n and k2 != n else 'ccw' if k1 != n and k2 == n else 'undefined')


def rotate_cw(n, pos):
	n = n % 4
	if n == 0:
		return pos
	if n == 1:
		return (pos + 1) % 4
	if n == 2:
		return (pos + 2) % 4
	if n == 3:
		return (pos + 3) % 4

def rotate_ccw(n, pos):
	n = n % 4
	if n == 0:
		return pos
	if n == 1:
		return (pos - 1) % 4
	if n == 2:
		return (pos - 2) % 4
	if n == 3:
		return (pos - 3) % 4

def change(c):
	if ord(c) == 118:
		return 2
	elif ord(c) == 60:
		return 3
	elif ord(c) == 94:
		return 0
	elif ord(c) == 62:
		return 1
(initial, final) = input().split()
n = int(input())
i = change(initial)
f = change(final)
if f == rotate_cw(n, i) and f == rotate_ccw(n, i):
	print('undefined')
elif f == rotate_ccw(n, i):
	print('ccw')
elif f == rotate_cw(n, i):
	print('cw')
else:
	print('undefined')


from sys import maxsize, stdout, stdin, stderr
mod = int(1000000000.0 + 7)
import re

def tup():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())

def lint():
	return [int(x) for x in stdin.readline().split()]

def S():
	return input().strip()

def grid(r, c):
	return [lint() for i in range(r)]

def debug(*args, c=6):
	print('\x1b[3{}m'.format(c), *args, '\x1b[0m', file=stderr)
from math import log2, sqrt
from collections import defaultdict
s = S().split()
n = I()
d = '^>v<'
if n % 2 == 0:
	print('undefined')
else:
	st = d.find(s[0]).__index__()
	en = d[(st + n) % 4]
	if en == s[1]:
		print('cw')
	elif d[(st - n) % 4] == s[1]:
		print('ccw')
	else:
		print('undefined')


sym = list(map(str, input().split()))
n = int(input())
if n % 2 == 0:
	print('undefined')
else:
	dict = {'<': 0, '^': 1, '>': 2, 'v': 3}
	print('cw') if dict[sym[len(sym) - 1]] == (dict[sym[0]] + n) % 4 else print('ccw')


def cw(d, n):
	f = ['^', '>', 'v', '<']
	if d == f[0]:
		if n % 4 == 1:
			return f[1]
		elif n % 4 == 2:
			return f[2]
		elif n % 4 == 3:
			return f[3]
		else:
			return f[0]
	elif d == f[1]:
		if n % 4 == 1:
			return f[2]
		elif n % 4 == 2:
			return f[3]
		elif n % 4 == 3:
			return f[0]
		else:
			return f[1]
	elif d == f[2]:
		if n % 4 == 1:
			return f[3]
		elif n % 4 == 2:
			return f[0]
		elif n % 4 == 3:
			return f[1]
		else:
			return f[2]
	elif d == f[3]:
		if n % 4 == 1:
			return f[0]
		elif n % 4 == 2:
			return f[1]
		elif n % 4 == 3:
			return f[2]
		else:
			return f[3]

def ccw(d, e):
	f = ['^', '<', 'v', '>']
	if d == f[0]:
		if n % 4 == 1:
			return f[1]
		elif n % 4 == 2:
			return f[2]
		elif n % 4 == 3:
			return f[3]
		else:
			return f[0]
	elif d == f[1]:
		if n % 4 == 1:
			return f[2]
		elif n % 4 == 2:
			return f[3]
		elif n % 4 == 3:
			return f[0]
		else:
			return f[1]
	elif d == f[2]:
		if n % 4 == 1:
			return f[3]
		elif n % 4 == 2:
			return f[0]
		elif n % 4 == 3:
			return f[1]
		else:
			return f[2]
	elif d == f[3]:
		if n % 4 == 1:
			return f[0]
		elif n % 4 == 2:
			return f[1]
		elif n % 4 == 3:
			return f[2]
		else:
			return f[3]
s = list(map(str, input().split()))
n = int(input())
a = cw(s[0], n)
b = ccw(s[0], n)
if a == b:
	print('undefined')
elif a == s[1]:
	print('cw')
elif b == s[1]:
	print('ccw')
else:
	print('undefined')


(a, b) = input().split()
n = int(input())
n = n % 4
V = ['^', '>', 'v', '<']
i = 0
while a != V[i]:
	i += 1
ti = (i + 4 - n) % 4
i = (i + n) % 4
if b == V[i] and b == V[ti]:
	print('undefined')
elif b == V[i]:
	print('cw')
elif b == V[ti]:
	print('ccw')
else:
	print('undefined')


def convert(spinner_state):
	if spinner_state == 'v':
		return 0
	elif spinner_state == '<':
		return 1
	elif spinner_state == '^':
		return 2
	else:
		return 3
(start, finish) = list(map(convert, input().split()))
n = int(input())
if n % 2 == 0:
	print('undefined')
elif finish == (start + n % 4) % 4:
	print('cw')
else:
	print('ccw')


l = 'v<^>'
(start, end) = input().split()
s_i = l.index(start)
e_i = l.index(end)
steps = int(input())
if steps % 4 == (s_i - e_i) % 4 and steps % 4 == (e_i - s_i) % 4:
	print('undefined')
elif steps % 4 == (e_i - s_i) % 4:
	print('cw')
elif steps % 4 == (s_i - e_i) % 4:
	print('ccw')
else:
	print('undefined')


(a, b) = input().split(' ')
n = int(input())
if a == b or (a == '<' and b == '>') or (a == '<' and b == '<') or (a == '^' and b == 'v') or (a == 'v' and b == '^'):
	print('undefined')
if a == '^' and b == '>':
	if (n - 1) % 4 == 0 or n == 0:
		print('cw')
	if (n - 3) % 4 == 0 or n == 0:
		print('ccw')
if a == '^' and b == '<':
	if (n - 1) % 4 == 0 or n == 0:
		print('ccw')
	if (n - 3) % 4 == 0 or n == 0:
		print('cw')
if a == '>' and b == '^':
	if (n - 1) % 4 == 0 or n == 0:
		print('ccw')
	if (n - 3) % 4 == 0 or n == 0:
		print('cw')
if a == '<' and b == '^':
	if (n - 1) % 4 == 0 or n == 0:
		print('cw')
	if (n - 3) % 4 == 0 or n == 0:
		print('ccw')
if a == 'v' and b == '>':
	if (n - 1) % 4 == 0 or n == 0:
		print('ccw')
	if (n - 3) % 4 == 0 or n == 0:
		print('cw')
if a == 'v' and b == '<':
	if (n - 1) % 4 == 0 or n == 0:
		print('cw')
	if (n - 3) % 4 == 0 or n == 0:
		print('ccw')
if a == '>' and b == 'v':
	if (n - 1) % 4 == 0 or n == 0:
		print('cw')
	if (n - 3) % 4 == 0 or n == 0:
		print('ccw')
if a == '<' and b == 'v':
	if (n - 1) % 4 == 0 or n == 0:
		print('ccw')
	if (n - 3) % 4 == 0 or n == 0:
		print('cw')


s = input().split()
num = int(input()) % 4
if num == 2 or num == 0:
	print('undefined')
else:
	mapping = ['v', '<', '^', '>', 'v', '<', '^', '>']
	if num == 1:
		ind1 = mapping.index(s[0])
		ind2 = mapping[ind1:].index(s[1])
		if 1 == ind2:
			print('cw')
		else:
			print('ccw')
	else:
		ind1 = mapping.index(s[0])
		ind2 = mapping[ind1:].index(s[1])
		if 3 == ind2:
			print('cw')
		else:
			print('ccw')


from sys import stdin, stdout
arr = ['v', '<', '^', '>']
string = [c for c in stdin.readline().strip().split()]
s = string[0]
e = string[1]
n = int(stdin.readline().strip())
pos = 0
for i in range(4):
	if s == arr[i]:
		pos = i
		break
clock = (pos + n) % 4
anti = (pos - n) % 4
if e == arr[clock] and e != arr[anti]:
	stdout.write('cw')
elif e == arr[anti] and e != arr[clock]:
	stdout.write('ccw')
else:
	stdout.write('undefined')


X = input().split()
Y = int(input())
Answer = 'v<^>'
if Y % 2 == 0:
	print('undefined')
	exit()
if Y % 4 == 1:
	print('ccw' if Answer[Answer.index(X[0]) - 1] == X[1] else 'cw')
	exit()
print('cw' if Answer[Answer.index(X[0]) - 1] == X[1] else 'ccw')


(s, e) = input().split()
d = {}
d['^'] = 0
d['>'] = 1
d['v'] = 2
d['<'] = 3
n = int(input())
n = n % 4
counter = (d[e] - d[s] + 4) % 4
if n == counter and n != 2 and (n != 0):
	print('cw')
elif n == 4 - counter and n != 2 and (n != 0):
	print('ccw')
else:
	print('undefined')


a = input()
n = int(input())
d = {}
ans = {}
d['^'] = 1
d['>'] = 2
d['v'] = 3
d['<'] = 0
ans[2] = '>'
ans[1] = '^'
ans[0] = '<'
ans[3] = 'v'
count = d[a[0]]
count += n
count = count % 4
se = d[a[2]]
se += n
se = se % 4
if ans[count] == a[2] and ans[se] == a[0] or (ans[se] != a[0] and ans[count] != a[2]):
	print('undefined')
elif ans[count] == a[2]:
	print('cw')
elif ans[se] == a[0]:
	print('ccw')


d = 'v<^>'
(a, b) = map(d.find, input().split())
(n, a) = (int(input()), (b - a + 4) % 4)
print('undefined' if a == 2 or a == 0 else 'cw' if n % 4 == a else 'ccw')


s = input()
n = int(input())
a = ['v', '<', '^', '>']
k = n % 4
if k % 2 == 0:
	print('undefined')
elif (a.index(s[2]) - a.index(s[0])) % 4 == k:
	print('cw')
else:
	print('ccw')


DIRS = ['v', '<', '^', '>']
(a, b) = map(DIRS.index, input().split())
n = int(input())
delta = (b - a + 4) % 4
if delta == 0 or delta == 2:
	print('undefined')
elif delta == n % 4:
	print('cw')
else:
	print('ccw')
1


sign = input().split()
time = int(input())
types = 'v<^>'
i = [i for (i, x) in enumerate(types) if sign[0] == x][0]
turn1 = types[(i + time) % 4]
turn2 = types[(i - time) % 4]
if turn1 == sign[1] != turn2:
	print('cw')
elif turn2 == sign[1] != turn1:
	print('ccw')
else:
	print('undefined')


(A, B) = input().split()
C = int(input())
if A == '^':
	a = 0
elif A == '>':
	a = 1
elif A == 'v':
	a = 2
else:
	a = 3
if B == '^':
	b = 0
elif B == '>':
	b = 1
elif B == 'v':
	b = 2
else:
	b = 3
c = C % 4
if (a + c) % 4 == b and (a - c) % 4 == b:
	print('undefined')
elif (a + c) % 4 == b:
	print('cw')
elif (a - c) % 4 == b:
	print('ccw')
else:
	print('undefined')


fwd = ['v', '<', '^', '>']
bck = fwd[::-1]
(f, s) = input().split()
n = int(input()) % 4
fwdp = fwd.index(f)
bckp = bck.index(f)
(a1, a2) = (fwd[(fwdp + n) % 4], bck[(bckp + n) % 4])
if a1 == a2 == s:
	print('undefined')
elif a1 == s:
	print('cw')
else:
	print('ccw')


(start, end) = input().split()
n = int(input())
cw = {0: '^', 1: '>', 2: 'v', 3: '<'}
dcw = {'^': 0, '>': 1, 'v': 2, '<': 3}
ccw = {0: '^', 1: '<', 2: 'v', 3: '>'}
dccw = {'^': 0, '<': 1, 'v': 2, '>': 3}
modulo = n % 4
if cw[(dcw[start] + modulo) % 4] == ccw[(dccw[start] + modulo) % 4]:
	print('undefined')
elif cw[(dcw[start] + modulo) % 4] == end:
	print('cw')
elif ccw[(dccw[start] + modulo) % 4] == end:
	print('ccw')


from sys import stdin
data = stdin.readline().rstrip().split()
n = int(stdin.readline().rstrip()) % 4
dmap = {'^': 0, '>': 1, 'v': 2, '<': 3}
(a, b) = (dmap[data[0]], dmap[data[1]])
if (a + n) % 4 == b and (a - n) % 4 == b:
	print('undefined')
elif (a + n) % 4 == b:
	print('cw')
else:
	print('ccw')


(a, b) = input().split()
c = int(input())
if c % 2 == 0:
	print('undefined')
elif a == '^' and b == '>' or (a == '>' and b == 'v') or (a == 'v' and b == '<') or (a == '<' and b == '^'):
	print('cw' if c % 4 == 1 else 'ccw')
else:
	print('ccw' if c % 4 == 1 else 'cw')


(x, y) = input().split()
z = int(input()) % 4
if x == '^' and y == 'v':
	print('undefined')
elif x == 'v' and y == '^':
	print('undefined')
elif x == '<' and y == '>':
	print('undefined')
elif x == '>' and y == '<':
	print('undefined')
elif x == '>' and y == '>':
	print('undefined')
elif x == '<' and y == '<':
	print('undefined')
elif x == '^' and y == '^':
	print('undefined')
elif x == 'v' and y == 'v':
	print('undefined')
else:
	if x == '^' and y == '>' and (z == 1):
		print('cw')
	if x == '^' and y == '<' and (z == 3):
		print('cw')
	if x == '^' and y == '<' and (z == 1):
		print('ccw')
	if x == '^' and y == '>' and (z == 3):
		print('ccw')
	if x == '>' and y == 'v' and (z == 1):
		print('cw')
	if x == '>' and y == '^' and (z == 3):
		print('cw')
	if x == '>' and y == '^' and (z == 1):
		print('ccw')
	if x == '>' and y == 'v' and (z == 3):
		print('ccw')
	if x == 'v' and y == '<' and (z == 1):
		print('cw')
	if x == 'v' and y == '>' and (z == 3):
		print('cw')
	if x == 'v' and y == '>' and (z == 1):
		print('ccw')
	if x == 'v' and y == '<' and (z == 3):
		print('ccw')
	if x == '<' and y == '^' and (z == 1):
		print('cw')
	if x == '<' and y == 'v' and (z == 3):
		print('cw')
	if x == '<' and y == 'v' and (z == 1):
		print('ccw')
	if x == '<' and y == '^' and (z == 3):
		print('ccw')


from sys import stdin, stdout
(d1, d2) = stdin.readline().rstrip().split()
n = int(stdin.readline().rstrip())
direction = []
for x in [d1, d2]:
	if x == '^':
		direction.append(0)
	elif x == '>':
		direction.append(1)
	elif x == '<':
		direction.append(3)
	else:
		direction.append(2)
n = n % 4
lTrue = False
rTrue = False
if (direction[0] + n) % 4 == direction[1]:
	lTrue = True
if (direction[0] - n) % 4 == direction[1]:
	rTrue = True
if lTrue and rTrue:
	print('undefined')
elif lTrue:
	print('cw')
else:
	print('ccw')


string = input()
rotation = int(input())
start = string[0]
cstart = start
end = string[2]
if rotation % 2 == 0:
	print('undefined')
	quit()
if rotation > 4:
	rotation = rotation % 4
for i in range(rotation):
	if start == '>':
		start = 'v'
	elif start == 'v':
		start = '<'
	elif start == '<':
		start = '^'
	elif start == '^':
		start = '>'
if start == end:
	print('cw')
	quit()
start = cstart
for i in range(rotation):
	if start == '>':
		start = '^'
	elif start == 'v':
		start = '>'
	elif start == '<':
		start = 'v'
	elif start == '^':
		start = '<'
if start == end:
	print('ccw')
	quit()
print('undefined')


def e(d, s):
	return (s + (c if d else -c)) % 4
p = {'v': 0, '<': 1, '^': 2, '>': 3}
i = input().split()
(p1, p2) = [p[j] for j in i]
c = int(input())
(r1, r2) = (e(1, p1), e(0, p1))
if r1 == r2:
	print('undefined')
elif r1 == p2:
	print('cw')
else:
	print('ccw')


(b, e) = input().split()
n = int(input())
n = n % 4
if n == 0:
	print('undefined')
else:
	cw = 'v<^>v<^>'
	ccw = 'v>^<v>^<'
	i1 = cw.find(b)
	i2 = cw.find(e, i1 + 1)
	j1 = ccw.find(b)
	j2 = ccw.find(e, j1 + 1)
	if i2 - i1 == n and j2 - j1 == n:
		print('undefined')
	elif i2 - i1 == n:
		print('cw')
	elif j2 - j1 == n:
		print('ccw')


a = {'v': 0, '<': 1, '^': 2, '>': 3}
s = input().strip().split()
n = int(input())
cw = (a[s[0]] + n) % 4 == a[s[1]]
cc = (a[s[0]] - n) % 4 == a[s[1]]
if cw and (not cc):
	print('cw')
elif cc and (not cw):
	print('ccw')
else:
	print('undefined')


a = 'v<^>'
(q, w) = (str(i) for i in input().split())
k = int(input()) % 4
a1 = a.find(q)
a2 = a.find(w)
f1 = False
f2 = False
f3 = False
f4 = False
if a1 == a2 and k == 0:
	print('undefined')
else:
	if a1 <= a2:
		if abs(a2 - a1) == k:
			f1 = True
		if 4 - abs(a2 - a1) == k:
			f2 = True
	else:
		if a1 - a2 == k:
			f3 = True
		if 4 - a1 + a2 == k:
			f4 = True
	if f1 and f2 or (f3 and f4):
		print('undefined')
	elif f1 or f4:
		print('cw')
	elif f2 or f3:
		print('ccw')


a = 'v<^>'
d = dict()
d['v'] = 0
d['<'] = 1
d['^'] = 2
d['>'] = 3
(s, e) = map(lambda x: d[x], input().split())
n = int(input()) % 4
flag_left = False
flag_right = False
if a[(s + n) % 4] == a[e]:
	flag_left = True
if a[(s - n) % 4] == a[e]:
	flag_right = True
if flag_left and flag_right:
	print('undefined')
elif flag_left:
	print('cw')
elif flag_right:
	print('ccw')
else:
	print('undefined')


(s1, s2) = input().split()
n = int(input())
A = ['^', '>', 'v', '<']
if n % 2 == 0:
	print('undefined')
elif A[A.index(s2) - 1] == s1:
	if n % 4 == 3:
		print('ccw')
	else:
		print('cw')
elif n % 4 == 3:
	print('cw')
else:
	print('ccw')


state = {'^': 1, '>': 2, 'v': 3, '<': 4}
(a, b) = (state[x] for x in input().split())
n = int(input()) % 4
if (b - a) % 2 == 1 and n % 2 == 1:
	if (b - a) % 4 == 1:
		print('cw' if n == 1 else 'ccw')
		pass
	elif (b - a) % 4 == 3:
		print('cw' if n == 3 else 'ccw')
		pass
	else:
		print('undefined')
else:
	print('undefined')


class Node:

	def __init__(self, data):
		self.data = data
		self.next = None
		self.prev = None

class CreateList:

	def __init__(self):
		self.head = Node(None)
		self.tail = Node(None)
		self.head.next = self.tail
		self.head.prev = self.tail
		self.tail.next = self.head
		self.tail.prev = self.head

	def add(self, data):
		newNode = Node(data)
		if self.head.data is None:
			self.head = newNode
			self.tail = newNode
			newNode.next = self.head
			newNode.prev = self.tail
		else:
			self.tail.next = newNode
			newNode.prev = self.tail
			self.tail = newNode
			self.tail.next = self.head
			self.head.prev = self.tail
cl = CreateList()
cl.add('^')
cl.add('>')
cl.add('v')
cl.add('<')
in1 = input().split()
pStart = in1[0]
pEnd = in1[1]
n = int(input())
if n > 4:
	n = n % 4
cur = cl.head
for i in range(4):
	if cur.data == pStart:
		cur = cur
		break
	else:
		cur = cur.next
start = cur
cw = False
ccw = False
for i in range(n):
	cur = cur.next
if cur.data == pEnd:
	cw = True
cur = start
for i in range(n):
	cur = cur.prev
if cur.data == pEnd:
	ccw = True
if cw and (not ccw):
	print('cw')
elif ccw and (not cw):
	print('ccw')
else:
	print('undefined')


def main(a, b, n):
	ccw = ['^', '<', 'v', '>'] * 2
	cw = ['^', '>', 'v', '<'] * 2
	if n % 2 == 0:
		return 'undefined'
	n = n % 4
	if b == ccw[ccw.index(a) + n]:
		return 'ccw'
	elif b == cw[cw.index(a) + n]:
		return 'cw'
	return 'undefined'
print(main(*input().split(' '), int(input())))


directions = ['v', '<', '^', '>']
(x, y) = map(directions.index, input().split())
n = int(input())
a = (y - x + 4) % 4
if a == 0 or a == 2:
	print('undefined')
elif a == n % 4:
	print('cw')
else:
	print('ccw')


(a, b) = map(str, input().split())
n = int(input())
l = [118, 60, 94, 62]
for x in range(4):
	if l[x] == ord(a):
		c1 = x
	if l[x] == ord(b):
		c2 = x
if (c2 - c1) % 4 == 0 or (c2 - c1) % 4 == 2:
	p = 'undefined'
elif (c2 - c1) % 4 == 1 and n % 4 == 1 or ((c2 - c1) % 4 == 3 and n % 4 == 3):
	p = 'cw'
else:
	p = 'ccw'
print(p)


(start, end) = input().split()
n = int(input())
n %= 4
map = {'^': 0, '>': 1, 'v': 2, '<': 3}
start = map[start]
end = map[end]
if not n % 2:
	print('undefined')
elif (start + n) % 4 == end:
	print('cw')
else:
	print('ccw')


positions = ['v', '<', '^', '>']
(s, t) = input().split()
(a, b) = (positions.index(s), positions.index(t))
n = int(input())
c1 = (a + n) % 4 == b
p = a - n
if a < n:
	p = (4 - abs(p) % 4) % 4
else:
	p %= 4
c2 = p == b
if c1 and c2:
	print('undefined')
elif c1:
	print('cw')
else:
	print('ccw')


import sys
s = '^>v<'
ch2int = {}
for (i, c) in enumerate(s):
	ch2int[c] = i
(a, b, n) = sys.stdin.read().split()
a = ch2int[a]
b = ch2int[b]
n = int(n)
iscw = s[(a + n) % 4] == s[b]
isccw = s[(a - n) % 4] == s[b]
if iscw and (not isccw):
	print('cw')
elif not iscw and isccw:
	print('ccw')
else:
	print('undefined')


a = [i for i in input().split()]
n = int(input())
ans = None
pol = ['v', '<', '^', '>']
if pol[(pol.index(a[1]) + n) % 4] == a[0]:
	ans = 'ccw'
if pol[(pol.index(a[1]) - n) % 4] == a[0]:
	if ans != None:
		ans = 'undefined'
	else:
		ans = 'cw'
print(ans)


str1 = input('')
firststr = str1[0]
secondstr = str1[2]
num = int(input(''))

def switch(x):
	if x == 'v':
		return 1
	if x == '<':
		return 2
	if x == '^':
		return 3
	if x == '>':
		return 4
fsn = switch(firststr)
ssn = switch(secondstr)
output = 'undefined'
num = num % 4
flag1 = 0
flag2 = 0
if num == 0:
	num = 4
fsnnum = fsn + num
if fsn + num > 4:
	fsnnum = fsn + num - 4
if fsnnum == ssn:
	output = 'cw'
	flag1 = 1
if fsn - num == -4 + ssn or fsn - num == ssn:
	output = 'ccw'
	flag2 = 1
if flag1 == flag2:
	output = 'undefined'
print(output)


Toy = ['v', '<', '^', '>']
(a, b) = map(Toy.index, input().split())
n = int(input())
d = (b - a + 4) % 4
if d == 0 or d == 2:
	print('undefined')
elif d == n % 4:
	print('cw')
else:
	print('ccw')


import sys
y = input()
x = int(input().strip())
arr = ['v', '<', '^', '>']
for i in range(4):
	if arr[i] == y[0]:
		t = i
cw = (t + x) % 4
ccw = (t - x) % 4
if arr[cw] == arr[ccw]:
	print('undefined')
elif arr[cw] != y[2] and arr[ccw] != y[2]:
	print('undefined')
elif arr[cw] == y[2]:
	print('cw')
elif arr[ccw] == y[2]:
	print('ccw')


(s, e) = input().split()
n = int(input()) % 4
sp = ['v', '<', '^', '>']
i = sp.index(s)
j = i
while n > 0:
	i = (i + 1) % 4
	j = (j - 1) % 4
	n -= 1
if e == sp[i] and e != sp[j]:
	print('cw')
elif e == sp[j] and e != sp[i]:
	print('ccw')
else:
	print('undefined')


c = ['v', '<', '^', '>']
(s, e) = list(input().split())
n = int(input())
if n % 2 == 0:
	print('undefined')
(si, ei) = (c.index(s), c.index(e))
if n % 4 == 1:
	if ei - si == 1 or si - ei == 3:
		print('cw')
	else:
		print('ccw')
if n % 4 == 3:
	if ei - si == 1 or si - ei == 3:
		print('ccw')
	else:
		print('cw')


(s, g) = input().split()
n = int(input())
cw = {'<': 1, '^': 2, '>': 3, 'v': 4}
ccw = {'<': 1, '^': 4, '>': 3, 'v': 2}
n = n % 4
d1 = cw[g] - cw[s]
d2 = ccw[g] - ccw[s]
if d1 < 0:
	d1 += 4
if d2 < 0:
	d2 += 4
result = ''
if d1 == n and d2 != n:
	result = 'cw'
elif d2 == n and d1 != n:
	result = 'ccw'
else:
	result = 'undefined'
print(result)


(s, f) = map(str, input().split())
n = int(input())
(cw, ccw) = (['^', '>', 'v', '<'], ['^', '<', 'v', '>'])
(cwp, ccwp) = (cw[(cw.index(s) + n) % 4], ccw[(ccw.index(s) + n) % 4])
print('undefined' if cwp == ccwp or (cwp != f and ccwp != f) else 'cw' if cwp == f else 'ccw')


(s, f) = input().strip().split()
n = int(input())
rot = ['^', '>', 'v', '<']
d = {'^': 0, '>': 1, 'v': 2, '<': 3}
cw = (d[s] + n) % 4
ccw = (d[s] - n) % 4
if cw == ccw:
	print('undefined')
elif rot[cw] == f:
	print('cw')
else:
	print('ccw')


def main():
	(s, e) = input().split()
	N = int(input())
	mapping = {'^': '>', '<': '^', '>': 'v', 'v': '<'}
	if N % 2 == 0:
		return 'undefined'
	if N % 4 == 1:
		if mapping[s] == e:
			return 'cw'
		else:
			return 'ccw'
	elif mapping[s] == e:
		return 'ccw'
	else:
		return 'cw'
print(main())


(a, b) = (i for i in input().split())
n = int(input()) % 4
if n % 2:
	if a == 'v':
		if b == '>' and n == 1 or (b == '<' and n == 3):
			print('ccw')
		else:
			print('cw')
	elif a == '>':
		if b == '^' and n == 1 or (b == 'v' and n == 3):
			print('ccw')
		else:
			print('cw')
	elif a == '^':
		if b == '<' and n == 1 or (b == '>' and n == 3):
			print('ccw')
		else:
			print('cw')
	elif a == '<':
		if b == 'v' and n == 1 or (b == '^' and n == 3):
			print('ccw')
		else:
			print('cw')
else:
	print('undefined')


(s, e) = input().split()
n = int(input())
f = ['^', '>', 'v', '<']
(a, b) = (0, 0)
for i in range(4):
	if f[i] == s:
		a = i + 1
	if f[i] == e:
		b = i + 1
if n % 4 == 2 or n % 4 == 0:
	print('undefined')
elif n % 4 == abs(a - b):
	if a > b:
		print('ccw')
	else:
		print('cw')
elif a > b:
	print('cw')
else:
	print('ccw')


import sys
(a, b) = input().split()
n = int(input())
if a == 'v':
	lcw = ['<', '^', '>', 'v']
	lccw = ['>', '^', '<', 'v']
	n = n % 4 - 1
	if lcw[n] == lccw[n]:
		print('undefined')
		sys.exit()
	elif lcw[n] == b:
		print('cw')
		sys.exit()
	elif lccw[n] == b:
		print('ccw')
elif a == '^':
	lcw = ['>', 'v', '<', '^']
	lccw = ['<', 'v', '>', '^']
	n = n % 4 - 1
	if lcw[n] == lccw[n]:
		print('undefined')
		sys.exit()
	elif lcw[n] == b:
		print('cw')
		sys.exit()
	elif lccw[n] == b:
		print('ccw')
elif a == '>':
	lcw = ['v', '<', '^', '>']
	lccw = ['^', '<', 'v', '>']
	n = n % 4 - 1
	if lcw[n] == lccw[n]:
		print('undefined')
		sys.exit()
	elif lcw[n] == b:
		print('cw')
		sys.exit()
	elif lccw[n] == b:
		print('ccw')
elif a == '<':
	lcw = ['^', '>', 'v', '<']
	lccw = ['v', '>', '^', '<']
	n = n % 4 - 1
	if lcw[n] == lccw[n]:
		print('undefined')
		sys.exit()
	elif lcw[n] == b:
		print('cw')
		sys.exit()
	elif lccw[n] == b:
		print('ccw')


(pos1, pos2) = input().split()
turns_nr = int(input())
if turns_nr % 2 == 0:
	print('undefined')
	return
elif turns_nr % 4 == 1:
	lst = '<^>v<^>v'
	for (idx1, sym1) in enumerate(lst):
		if sym1 == pos1:
			if lst[idx1 - 1] == pos2:
				print('ccw')
				return
			elif lst[idx1 + 1] == pos2:
				print('cw')
				return
elif turns_nr % 4 == 3:
	lst = '<^>v<^>v'
	for (idx1, sym1) in enumerate(lst):
		if sym1 == pos1:
			if lst[idx1 - 1] == pos2:
				print('cw')
				return
			elif lst[idx1 + 1] == pos2:
				print('ccw')
				return


class CodeforcesTask834ASolution:

	def __init__(self):
		self.result = ''
		self.positions = ''
		self.time = 0

	def read_input(self):
		self.positions = input()
		self.time = int(input())

	def process_task(self):
		shift = self.time % 4
		if not shift:
			self.result = 'undefined'
		else:
			spinner = ['^', '>', 'v', '<']
			start_pos = spinner.index(self.positions[0])
			stop_pos = spinner.index(self.positions[2])
			cw_result = (start_pos + shift) % 4
			ccw_result = (start_pos - shift) % 4
			if cw_result == stop_pos and ccw_result == stop_pos:
				self.result = 'undefined'
			elif cw_result == stop_pos:
				self.result = 'cw'
			else:
				self.result = 'ccw'

	def get_result(self):
		return self.result
Solution = CodeforcesTask834ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


(s, f) = input().split()
n = int(input())
cw = ['v', '<', '^', '>']
ccw = ['v', '>', '^', '<']
ecw = cw[(cw.index(s) + n) % 4]
eccw = ccw[(ccw.index(s) + n) % 4]
if ecw == f:
	if eccw != f:
		print('cw')
	else:
		print('undefined')
elif eccw == f:
	if ecw != f:
		print('ccw')
	else:
		print('undefined')
else:
	print('undefined')


Input = lambda : map(str, input().split())
(S, E) = input().split()
n = int(input())
cw = ccw = True
l = ['^', '>', 'v', '<']
ind1 = l.index(S)
ind2 = l.index(E)
if ind1 <= ind2:
	if (n - (ind2 - ind1)) % 4 != 0:
		cw = False
elif (n - (3 - ind1 + (ind2 + 1))) % 4 != 0:
	cw = False
if cw == False:
	print('ccw')
	exit()
if ind1 >= ind2:
	if (n - (ind1 - ind2)) % 4 != 0:
		ccw = False
elif (n - (ind1 + (4 - ind2))) % 4 != 0:
	ccw = False
print('cw' if ccw == False else 'undefined')


(a, b) = [i for i in input().split()]
n = int(input())
pos = ['v', '<', '^', '>']
i = pos.index(a)
f1 = pos[(i + n) % 4]
f2 = pos[(i - n) % 4]
if f1 == f2:
	print('undefined')
elif f1 == b:
	print('cw')
elif f2 == b:
	print('ccw')
else:
	print('undefined')


(s, t) = input().split()
n = int(input())
a = '^>v<'
if n % 2 == 0:
	print('undefined')
else:
	i = a.find(s)
	d = a.find(t)
	if a[(i + n) % 4] == t:
		print('cw')
	else:
		print('ccw')


arrowslist = ('v', '<', '^', '>')
flag = True
arrows = input().split()
n = int(input()) % 4
k = arrowslist.index(arrows[0]) - arrowslist.index(arrows[1])
if k % 2 == 0:
	print('undefined')
if n == 3:
	flag = False
if k == 1 or k == -3:
	if flag:
		print('ccw')
	else:
		print('cw')
if k == -1 or k == 3:
	if flag:
		print('cw')
	else:
		print('ccw')


pos = input().split()
p1 = 0
p2 = 0
if pos[0] == '^':
	p1 = 0
if pos[0] == '>':
	p1 = 1
if pos[0] == 'v':
	p1 = 2
if pos[0] == '<':
	p1 = 3
if pos[1] == '^':
	p2 = 0
if pos[1] == '>':
	p2 = 1
if pos[1] == 'v':
	p2 = 2
if pos[1] == '<':
	p2 = 3
s = int(input())
s = s % 4
if (p1 + s) % 4 == (p1 - s) % 4:
	print('undefined')
elif (p1 + s) % 4 == p2:
	print('cw')
else:
	print('ccw')


d = input().replace(' ', '')
n = int(input())
n = n % 4
cw1 = ['^>', '>v', 'v<', '<^']
cw3 = ['^<', '>^', 'v>', '<v']
if d == '^v' or d == 'v^' or d == '<>' or (d == 'vv') or (d == '^^') or (d == '>>') or (d == '<<') or (d == '><'):
	print('undefined')
elif d in cw1 and n == 1 or (d in cw3 and n == 3):
	print('cw')
else:
	print('ccw')


(l, p) = (False, False)
(s1, s2) = map(str, input().split())
s = s1 + ''
n = int(input()) % 4
for i in range(n):
	if s == 'v':
		s = '<'
	elif s == '<':
		s = '^'
	elif s == '^':
		s = '>'
	elif s == '>':
		s = 'v'
if s == s2:
	l = True
s = s1 + ''
for i in range(n):
	if s == 'v':
		s = '>'
	elif s == '>':
		s = '^'
	elif s == '^':
		s = '<'
	elif s == '<':
		s = 'v'
if s == s2:
	p = True
if p == l:
	print('undefined')
elif l:
	print('cw')
else:
	print('ccw')


(start, end) = input().split(' ')
time = int(input())
time = time % 4
positions = ['v', '<', '^', '>']
pos_reverse = ['v', '>', '^', '<']
cw = ccw = False
pos_start_cw = positions.index(start)
pos_end_cw = positions.index(end)
pos_start_ccw = pos_reverse.index(start)
pos_end_ccw = pos_reverse.index(end)
if (pos_start_cw + time) % 4 == pos_end_cw:
	cw = True
if (pos_start_ccw + time) % 4 == pos_end_ccw:
	ccw = True
if cw is True:
	if ccw is False:
		print('cw')
	else:
		print('undefined')
elif ccw is True:
	if cw is False:
		print('ccw')
	else:
		print('undefined')
else:
	print('undefined')


(a, b) = input().split()
n = int(input())
m = {j: i for (i, j) in enumerate(['v', '>', '^', '<'])}
if n % 2 == 0:
	print('undefined')
else:
	print('c' + ('c' if (m[a] + n) % 4 == m[b] else '') + 'w')


import sys
spinner = input()
n = int(input())
if n > 4:
	n = n % 4
clock = 'v<^>v<^>'
clockr = '>^<v>^<v'
cw = ccw = 0
p = clock.index(spinner[0])
p2 = clockr.index(spinner[0])
if clock[p + n] == spinner[2]:
	cw = 1
if clockr[p2 + n] == spinner[2]:
	ccw = 1
if cw == 1 and ccw == 0:
	print('cw')
elif ccw == 1 and cw == 0:
	print('ccw')
else:
	print('undefined')


(i, f) = input().split()
n = int(input())
a = {'^': 0, '>': 90, 'v': 180, '<': 270}
b = {0: '^', 90: '>', 180: 'v', 270: '<'}
if b[(a[i] + n * 90) % 360] == f and b[(a[i] - n * 90) % 360] == f:
	print('undefined')
	exit()
if b[(a[i] + n * 90) % 360] == f:
	print('cw')
elif b[(a[i] - n * 90) % 360] == f:
	print('ccw')
else:
	print('undefined')


(s, e) = tuple(input().split())
n = int(input())
(s1, s2) = ('v<^>', 'v>^<')
print('cw' if s1[(s1.find(s) + n) % 4] == e and s2[(s2.find(s) + n) % 4] != e else 'ccw' if s2[(s2.find(s) + n) % 4] == e and s1[(s1.find(s) + n) % 4] != e else 'undefined')


(s, e) = input().split()
(cw, ccw) = (['^', '>', 'v', '<'], ['^', '<', 'v', '>'])
(n, a, b) = (int(input()), False, False)
if cw[(n + cw.index(s)) % 4] == e:
	a = True
if ccw[(n + ccw.index(s)) % 4] == e:
	b = True
print('undefined' if a and b else 'cw' if a and (not b) else 'ccw')


(a, b) = input().split()
a = ord(a)
b = ord(b)
n = int(input())
temp = n // 4
n = n % 4
if a == 118:
	if b == 118:
		print('undefined')
	elif b == 60:
		if n == 1:
			print('cw')
		elif n == 3:
			print('ccw')
	elif b == 94:
		if n == 2:
			print('undefined')
	elif b == 62:
		if n == 1:
			print('ccw')
		elif n == 3:
			print('cw')
elif a == 60:
	if b == 118:
		if n == 1:
			print('ccw')
		elif n == 3:
			print('cw')
	elif b == 60:
		print('undefined')
	elif b == 94:
		if n == 1:
			print('cw')
		elif n == 3:
			print('ccw')
	elif b == 62:
		if n == 2:
			print('undefined')
elif a == 94:
	if b == 118:
		if n == 2:
			print('undefined')
	elif b == 60:
		if n == 1:
			print('ccw')
		elif n == 3:
			print('cw')
	elif b == 94:
		if n == 0:
			print('undefined')
	elif b == 62:
		if n == 1:
			print('cw')
		elif n == 3:
			print('ccw')
elif a == 62:
	if b == 118:
		if n == 1:
			print('cw')
		elif n == 3:
			print('ccw')
	elif b == 60:
		if n == 2:
			print('undefined')
	elif b == 94:
		if n == 1:
			print('ccw')
		elif n == 3:
			print('cw')
	elif b == 62:
		if n == 0:
			print('undefined')


a = input().split()
n = int(input())
b = ['v', '>', '^', '<']
if n % 2 == 0:
	print('undefined')
elif (b.index(a[0]) + n) % 4 == b.index(a[1]):
	print('ccw')
else:
	print('cw')


s = ['v', '<', '^', '>']
(start, end) = input().split()
n = int(input())
for i in range(len(s)):
	if s[i] == start:
		start = i
	if s[i] == end:
		end = i
if s[(start + n) % 4] == s[(start - n) % 4] and s[(start + n) % 4] == s[end]:
	print('undefined')
elif s[(start + n) % 4] == s[end]:
	print('cw')
elif s[(start - n) % 4] == s[end]:
	print('ccw')
else:
	print('undefined')


x = input().split()
a = x[0]
b = x[1]
n = int(input())
cw = n % 4
ccw = 4 - cw
c = ['^', '>', 'v', '<']
k = c.index(a)
c1 = [c[k], c[(k + 1) % 4], c[(k + 2) % 4], c[(k + 3) % 4]]
if cw != ccw and c1[cw] == b:
	z = 'cw'
elif cw != ccw and c1[ccw] == b:
	z = 'ccw'
elif cw == ccw:
	z = 'undefined'
if n == 0:
	z = 'undefined'
if a == b:
	z = 'undefined'
print(z)


pos = [None, None]
(pos[0], pos[1]) = input().split()
sec = int(input())
if pos[0] == '^':
	now_pos = 1
elif pos[0] == '>':
	now_pos = 2
elif pos[0] == 'v':
	now_pos = 3
else:
	now_pos = 4
start = now_pos
if pos[1] == '^':
	end = 1
elif pos[1] == '>':
	end = 2
elif pos[1] == 'v':
	end = 3
else:
	end = 4
b1 = False
b2 = False
h1 = -100
h2 = -100
if start <= end:
	h1 = end - start
else:
	h1 = 4 - start + end
if start >= end:
	h2 = start - end
else:
	h2 = start + 4 - end
if h1 == h2 == sec % 4:
	b1 = b2 = True
elif h1 == sec % 4:
	b1 = True
elif h2 == sec % 4:
	b2 = True
if b1 and b2:
	print('undefined')
elif b1:
	print('cw')
elif b2:
	print('ccw')


(a, b) = input().split()
t = int(input())
d = dict()
d['^'] = 0
d['>'] = 1
d['v'] = 2
d['<'] = 3
(a, b) = (d[a], d[b])
t = t % 4
if t == 2 or t == 0:
	print('undefined')
elif t == 1:
	if (b - 1) % 4 == a:
		print('CW'.lower())
	else:
		print('CCW'.lower())
elif t == 3:
	if (b + 1) % 4 == a:
		print('CW'.lower())
	else:
		print('CCW'.lower())


table = ['<', 'v', '>', '^']
s = input().split()
final = s[1]
n = int(input()) % 4
start = table.index(s[0])
forwardans = table[(start + n) % 4]
backwardans = table[(start - n) % 4]
if forwardans == backwardans:
	print('undefined')
elif forwardans == final:
	print('ccw')
else:
	print('cw')


s = input()
n = int(input())
s1 = s[0]
s2 = s[2]
if s2 == 'v':
	s2 = 118
if s2 == '<':
	s2 = 60
if s2 == '^':
	s2 = 94
if s2 == '>':
	s2 = 62
if s1 == 'v':
	s1 = 118
if s1 == '<':
	s1 = 60
if s1 == '^':
	s1 = 94
if s1 == '>':
	s1 = 62
k = 0
p = 0
t = 0
if n % 4 == 0:
	t = 1
	print('undefined')
n1 = n % 4
n = n1
if s1 == 118:
	if n1 == 1 and s2 == 60:
		k = 1
	if n == 2 and s2 == 94:
		k = 1
	if n == 3 and s2 == 62:
		k = 1
if s1 == 60:
	if n1 == 1 and s2 == 94:
		k = 1
	if n == 2 and s2 == 62:
		k = 1
	if n == 3 and s2 == 118:
		k = 1
if s1 == 94:
	if n1 == 1 and s2 == 62:
		k = 1
	if n == 2 and s2 == 118:
		k = 1
	if n == 3 and s2 == 60:
		k = 1
if s1 == 62:
	if n1 == 1 and s2 == 118:
		k = 1
	if n == 2 and s2 == 60:
		k = 1
	if n == 3 and s2 == 94:
		k = 1
if s1 == 62:
	if n1 == 1 and s2 == 94:
		p = 1
	if n == 2 and s2 == 60:
		p = 1
	if n == 3 and s2 == 118:
		p = 1
if s1 == 94:
	if n1 == 1 and s2 == 60:
		p = 1
	if n == 2 and s2 == 118:
		p = 1
	if n == 3 and s2 == 62:
		p = 1
if s1 == 60:
	if n1 == 1 and s2 == 118:
		p = 1
	if n == 2 and s2 == 62:
		p = 1
	if n == 3 and s2 == 94:
		p = 1
if s1 == 118:
	if n1 == 1 and s2 == 62:
		p = 1
	if n == 2 and s2 == 94:
		p = 1
	if n == 3 and s2 == 60:
		p = 1
if t == 0:
	if k == 0 and p == 0:
		print('undefined')
	if k == 1 and p == 1:
		print('undefined')
	if k == 1 and p == 0:
		print('cw')
	if p == 1 and k == 0:
		print('ccw')


import sys
import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list or type(n) is str:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

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

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return int(str(n)[::-1])

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True
arr = ['^', '>', 'v', '<']
p = list(input().split())
t = ii()
if (arr.index(p[0]) - arr.index(p[1])) % 4 == 2 or (arr.index(p[0]) - arr.index(p[1])) % 4 == 0:
	print('undefined')
elif (arr.index(p[0]) - arr.index(p[1])) % 4 == t % 4:
	print('ccw')
elif (arr.index(p[0]) - arr.index(p[1])) % 4 == 4 - t % 4:
	print('cw')


(s, f) = input().split()
d = {'^': 0, '>': 1, 'v': 2, '<': 3}
s = d[s]
f = d[f]
n = int(input())
cw = (s + n) % 4
if abs(f - s) == 2 or s == f:
	print('undefined')
elif f == cw:
	print('cw')
else:
	print('ccw')


s = input().split()
d = {'^': 1, '>': 2, 'v': 3, '<': 4}
x = int(input()) % 4
a = (4 + d[s[1]] - d[s[0]]) % 4
b = (4 - a) % 4
if a == x and b != x:
	print('cw')
elif b == x and a != x:
	print('ccw')
else:
	print('undefined')


def main_function():
	input_str = [i for i in input().split(' ')]
	n = int(input())
	n = n % 4
	d = ['v', '<', '^', '>']
	if not n % 2:
		return 'undefined'
	starting_index = d.index(input_str[0])
	ending_index = d.index(input_str[1])
	new_index_1 = starting_index + n
	new_index_2 = starting_index - n
	if new_index_1 > 3:
		new_index_1 -= 4
	if new_index_2 < 0:
		new_index_2 = 4 - new_index_2
	if ending_index == new_index_1:
		return 'cw'
	return 'ccw'
print(main_function())


a = [[0, 'v'], [1, '<'], [2, '^'], [3, '>']]
(f, s) = input().split()
n = int(input())
n = n % 4
four = 4

def o(f):
	if f == 'v':
		f = 0
	elif f == '<':
		f = 1
	elif f == '^':
		f = 2
	else:
		f = 3
	return f
f = o(f)
s = o(s)
if f == 0 and s == 2 or (f == 1 and s == 3) or (s == 0 and f == 2) or (s == 1 and f == 3) or (f == s):
	print('undefined')
elif (f + n) % 4 == s:
	print('cw')
else:
	print('ccw')


m = {'^': 0, '>': 1, 'v': 2, '<': 3}
(a, b) = input().split()
n = int(input())
(a, b) = (m[a], m[b])
cwdist = (b - a) % 4
ccwdist = (a - b) % 4
if cwdist == ccwdist:
	print('undefined')
elif cwdist == n % 4:
	print('cw')
else:
	print('ccw')


(a, b) = map(str, input().split())
n = int(input())
if a == 'v':
	a = 1
if a == '<':
	a = 2
if a == '^':
	a = 3
if a == '>':
	a = 4
if b == 'v':
	b = 1
if b == '<':
	b = 2
if b == '^':
	b = 3
if b == '>':
	b = 4
a = int(a)
b = int(b) % 4
k = n % 4
po = a + k
protiv = a - k
if po % 4 != protiv % 4:
	if b == po % 4:
		print('cw')
	else:
		print('ccw')
else:
	print('undefined')


positions_input = input().split(' ')
times = int(input())
positions = ['v', '<', '^', '>']
i = times % 4

def fin_pos(idx, direction):
	global positions
	global i
	if direction == 'r':
		return positions[(idx + i) % 4]
	elif direction == 'l':
		return positions[(idx - i) % 4]
idx = positions.index(positions_input[0])
if fin_pos(idx, 'r') == fin_pos(idx, 'l') == positions_input[1]:
	print('undefined')
elif fin_pos(idx, 'r') == positions_input[1]:
	print('cw')
elif fin_pos(idx, 'l') == positions_input[1]:
	print('ccw')


from itertools import cycle
(begin, end) = input().split()
n = int(input()) % 4
answer = 'undefined'
if n != 0:
	clockwise = cycle('^>v<')
	counter_clockwise = cycle('^<v>')
	current_cw = next(clockwise)
	current_ccw = next(counter_clockwise)
	while current_cw != begin:
		current_cw = next(clockwise)
	while current_ccw != begin:
		current_ccw = next(counter_clockwise)
	for i in range(n):
		current_cw = next(clockwise)
		current_ccw = next(counter_clockwise)
	if current_cw != current_ccw == end:
		answer = 'ccw'
	elif end == current_cw != current_ccw:
		answer = 'cw'
print(answer)


c = '^>v<'
(a, b) = map(c.index, input().split())
n = int(input())
print([['ccw', 'cw'][(a + n) % 4 == b], 'undefined'][abs(a - b) % 2 == 0])


(begin, end) = input().split()
begin = str(begin)
end = str(end)
n = int(input())
arrayPosicoes = ['^', '>', 'v', '<']
finalPosition = n % 4
verifyClockWise = False
verifyCounterClock = False
parameter = arrayPosicoes.index(begin)
while finalPosition != 0:
	if parameter != 3:
		parameter += 1
	else:
		parameter = 0
	finalPosition -= 1
if arrayPosicoes[parameter] == end:
	verifyClockWise = True
finalPosition2 = n % 4
parameter2 = arrayPosicoes.index(begin)
while finalPosition2 != 0:
	if parameter2 != 0:
		parameter2 -= 1
	else:
		parameter2 = 3
	finalPosition2 -= 1
if arrayPosicoes[parameter2] == end:
	verifyCounterClock = True
if verifyClockWise == True and verifyCounterClock == False:
	print('cw')
elif verifyClockWise == False and verifyCounterClock == True:
	print('ccw')
else:
	print('undefined')


import sys
a = input()
b = int(input()) % 4
c = ord(a[0]) - ord(a[2])
d = {58: 'cw', 56: 'ccw', -58: 'ccw', -34: 'cw', 34: 'ccw', 32: 'cw', -56: 'cw', -32: 'ccw'}
if b % 2 == 0:
	sys.stdout.write('undefined')
elif b == 1:
	sys.stdout.write(d[c])
else:
	sys.stdout.write(d[-c])


import os
import sys

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l

def sq(a, target, arr=[]):
	s = sum(arr)
	if s == target:
		return arr
	if s >= target:
		return
	for i in range(len(a)):
		n = a[i]
		remaining = a[i + 1:]
		ans = sq(remaining, target, arr + [n])
		if ans:
			return ans

def SieveOfEratosthenes(n):
	cnt = 0
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			cnt += 1
	return cnt

def nCr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
mod = int(1000000000.0) + 7

def ssinp():
	return input()

def iinp():
	return int(input())

def nninp():
	return map(int, input().split())

def llinp():
	return list(map(int, input().split()))

def p(xyz):
	print(xyz)

def p2(a, b):
	print(a, b)
import math
from collections import OrderedDict
(start, end) = map(str, input().split())
n = int(input())
mul = ord(start) * ord(end)
if mul == 118 * 94 or mul == 60 * 62 or mul == 118 * 118 or (mul == 94 * 94) or (mul == 60 * 60) or (mul == 62 * 62):
	print('undefined')
else:
	f = 0
	if ord(end) > ord(start):
		(start, end) = (end, start)
		n = n + 2
	nos = n % 4
	if ord(start) == 94:
		if ord(end) == 62 and nos == 1 or (ord(end) == 60 and nos == 3):
			print('cw')
		else:
			print('ccw')
	elif ord(end) == 60 and nos == 1 or (ord(end) == 62 and nos == 3):
		print('cw')
	else:
		print('ccw')


a = ['v', '<', '^', '>']
(s, e) = input().split()
n = int(input())
l = a.index(s)
r = l
n = n % 4
for i in range(n):
	if l == 0:
		l = 3
	else:
		l -= 1
	if r == 3:
		r = 0
	else:
		r += 1
if a[l] == e and a[r] == e:
	print('undefined')
elif a[l] == e:
	print('ccw')
elif a[r] == e:
	print('cw')


(a, b) = input().split()
n = int(input())
mp = {'v': 0, '<': 1, '^': 2, '>': 3}
u = (mp[b] - mp[a] + 4) % 4
if u == 0 or u == 2:
	print('undefined')
elif u == n % 4:
	print('cw')
else:
	print('ccw')


(startpos, endpos) = str(input()).split()
n = int(input())
startnum = 0
endnum = 0
if startpos == '^':
	startnum = 0
elif startpos == '>':
	startnum = 1
elif startpos == 'v':
	startnum = 2
elif startpos == '<':
	startnum = 3
if endpos == '^':
	endnum = 0
elif endpos == '>':
	endnum = 1
elif endpos == 'v':
	endnum = 2
elif endpos == '<':
	endnum = 3
if (startnum + n) % 4 == endnum and (startnum - n) % 4 == endnum:
	print('undefined')
elif (startnum + n) % 4 == endnum:
	print('cw')
elif (startnum - n) % 4 == endnum:
	print('ccw')


from sys import stdin, stdout

def rint():
	return map(int, stdin.readline().split())
t = {'v': 0, '<': 1, '^': 2, '>': 3}
(a, b) = map(str, input().split())
n = int(input())
n %= 4
if n == 0 or n == 2:
	print('undefined')
	exit()
(a, b) = (t[a], t[b])
if b < a:
	b += 4
diff = b - a
if n == 1:
	if diff == 1:
		print('cw')
	elif diff == 3:
		print('ccw')
	else:
		print('undefined')
elif n == 3:
	if diff == 1:
		print('ccw')
	elif diff == 3:
		print('cw')
	else:
		print('undefined')


l = list(map(ord, input().split()))
n = int(input())
cw = [118, 60, 94, 62]
n = n % 4
ind = cw.index(l[0])
indCw = (n + ind) % 4
indCcw = ind
for i in range(n):
	if indCcw - 1 < 0:
		indCcw = 3
	else:
		indCcw -= 1
if indCw == indCcw:
	print('undefined')
elif cw[indCw] == l[1]:
	print('cw')
elif cw[indCcw] == l[1]:
	print('ccw')


def main():
	cw_dir = '^>v<'
	ccw_dir = '^<v>'
	input1 = input()
	input2 = input()
	startPos = input1[0]
	endPos = input1[2]
	secs = int(input2)
	cw = False
	ccw = False
	output = 'undefined'
	if (cw_dir.find(startPos) + secs) % 4 == cw_dir.find(endPos):
		cw = True
	if (ccw_dir.find(startPos) + secs) % 4 == ccw_dir.find(endPos):
		ccw = True
	if cw != ccw:
		if cw:
			output = 'cw'
		else:
			output = 'ccw'
	print(output)
main()


(start, end) = input().split()
n = int(input()) % 4
if start == 'v':
	start = 0
elif start == '<':
	start = 1
elif start == '^':
	start = 2
elif start == '>':
	start = 3
if end == 'v':
	end = 0
elif end == '<':
	end = 1
elif end == '^':
	end = 2
elif end == '>':
	end = 3
temp1 = (4 + end - start) % 4
temp2 = (4 + start - end) % 4
if temp1 == temp2 == n:
	print('undefined')
elif temp1 == n:
	print('cw')
elif temp2 == n:
	print('ccw')
else:
	print('ERROR')


dict = {'v': 0, '<': 1, '^': 2, '>': 3}
(i, j) = input().split()
num = int(input())
l = dict[i]
r = dict[j]
s = r - l % 4
num = num % 4
sf = 4 - s if s > 0 else -s
s = 4 + s if s < 0 else s
if s == 0 or abs(s) == 2:
	print('undefined')
elif num == sf:
	print('ccw')
elif num == s:
	print('cw')


ip = input().split()
sec = int(input()) % 4
if sec == 0 or sec == 2:
	print('undefined')
elif sec == 1:
	if ip[0] == '^':
		if ip[1] == '>':
			print('cw')
		else:
			print('ccw')
	elif ip[0] == '>':
		if ip[1] == 'v':
			print('cw')
		else:
			print('ccw')
	elif ip[0] == 'v':
		if ip[1] == '<':
			print('cw')
		else:
			print('ccw')
	elif ip[1] == '^':
		print('cw')
	else:
		print('ccw')
elif ip[0] == '^':
	if ip[1] == '>':
		print('ccw')
	else:
		print('cw')
elif ip[0] == '>':
	if ip[1] == 'v':
		print('ccw')
	else:
		print('cw')
elif ip[0] == 'v':
	if ip[1] == '<':
		print('ccw')
	else:
		print('cw')
elif ip[1] == '^':
	print('ccw')
else:
	print('cw')


(s, t) = map(lambda x: 'v<^>'.index(x), input().split())
n = int(input())
cw = (n + s - t) % 4 == 0
ccw = (n + t - s) % 4 == 0
if cw and (not ccw):
	print('cw')
elif not cw and ccw:
	print('ccw')
else:
	print('undefined')


l = input().split()
n = int(input())
l2 = []
for c in l:
	if ord(c) == 118:
		l2.append(0)
	elif ord(c) == 60:
		l2.append(1)
	elif ord(c) == 94:
		l2.append(2)
	elif ord(c) == 62:
		l2.append(3)
diff = l2[1] - l2[0]
cw = (diff - n) % 4 == 0
ccw = (diff + n) % 4 == 0
if cw and ccw:
	print('undefined')
elif cw:
	print('cw')
else:
	print('ccw')


(start, end) = [str(n) for n in input().split(' ')]
n = int(input())
offset_cw = {'^': 0, '>': 1, 'v': 2, '<': 3}
offset_ccw = {'^': 0, '<': 1, 'v': 2, '>': 3}

def check(start, end, n, dict):
	start_n = dict[start]
	end_n = dict[end]
	if (start_n + n) % 4 == end_n:
		return True
	else:
		return False
cw = check(start, end, n, offset_cw)
ccw = check(start, end, n, offset_ccw)
if cw and (not ccw):
	print('cw')
elif ccw and (not cw):
	print('ccw')
else:
	print('undefined')


d = {'v': 0, '<': 1, '^': 2, '>': 3}
(f1, f2) = input().split()
s = int(input())
x1 = (d[f1] + s) % 4 == d[f2]
x2 = (d[f1] - s) % 4 == d[f2]
if x1 and x2:
	print('undefined')
elif x1:
	print('cw')
else:
	print('ccw')


(str1, str2) = input().split()
n = int(input())
s = ['v', '<', '^', '>']
t = n
n = n % 4
if n == 2 or n == 0:
	print('undefined')
else:
	index1 = s.index(str1)
	index2 = s.index(str2)
	if index1 + n > 3:
		index3 = index1 + n - 4
	else:
		index3 = index1 + n
	if index3 == index2:
		print('cw')
	else:
		print('ccw')


set = ('v', '<', '^', '>')
(start, stop) = input().strip().split(' ')
time = int(input())
rotations = time % 4
startPos = set.index(start)
endPos = set.index(stop)
res = (startPos - endPos) % 4
if res == 3:
	if rotations == 1:
		print('cw')
	else:
		print('ccw')
elif res == 1:
	if rotations == 3:
		print('cw')
	else:
		print('ccw')
else:
	print('undefined')


s = input()
(a, b) = s.split()
d = '^>v<'
n = int(input()) % 4
if n == 2 or n == 0:
	print('undefined')
elif n == 1:
	if s in ['^ >', '> v', 'v <', '< ^']:
		print('cw')
	else:
		print('ccw')
elif s in ['^ >', '> v', 'v <', '< ^']:
	print('ccw')
else:
	print('cw')


(start, end) = input().split()
n = int(input())
l = ['^', '>', 'v', '<'] * 2
ni = n % 4
ans = []
if l[l.index(start) + ni] == end:
	ans.append('cw')
if l[[i for (i, n) in enumerate(l) if n == start][1] - ni] == end:
	ans.append('ccw')
if len(ans) == 2 or len(ans) == 0:
	print('undefined')
else:
	print(*ans)


(i, f) = list(input().split())
a = ['v', '<', '^', '>']
n = int(input())
n = n % 4
q = a.index(i)
c = q + n
ac = q - n
if c > 3:
	c = c % 4
if ac < 0:
	ac = ac % 4
if c == ac:
	print('undefined')
elif a[c] == f:
	print('cw')
else:
	print('ccw')


a = [x for x in input().split()]
start = a[0]
end = a[1]
t = int(input())
cw = '^>v<'
ccw = '^<v>'
if (t + cw.index(start)) % 4 == cw.index(end) and (t + ccw.index(start)) % 4 == ccw.index(end):
	print('undefined')
elif (t + cw.index(start)) % 4 == cw.index(end):
	print('cw')
else:
	print('ccw')


spinner = ['v', '<', '^', '>']
s = input().split()
n = int(input())
if n % 2 == 0:
	print('undefined')
elif (spinner.index(s[1]) - spinner.index(s[0]) + 4) % 4 == n % 4:
	print('cw')
else:
	print('ccw')


def cw(s):
	if s == 'v':
		return ['v', '<', '^', '>']
	elif s == '<':
		return ['<', '^', '>', 'v']
	elif s == '^':
		return ['^', '>', 'v', '<']
	else:
		return ['>', 'v', '<', '^']

def solve(n, start, end):
	arr_cw = cw(start)
	arr_ccw = list(reversed(arr_cw[1:] + arr_cw[0:1]))
	if n >= 4:
		n = n % 4
	expected_cw = arr_cw[n]
	expected_ccw = arr_ccw[n]
	if expected_ccw == expected_cw:
		return 'undefined'
	if end == expected_cw:
		return 'cw'
	if end == expected_ccw:
		return 'ccw'

def main():
	res = list(input().split(' '))
	n = int(input())
	print(solve(n, *res))
main()


(i, f) = map(str, input().split(' '))
n = int(input())
cw = ['^', '>', 'v', '<']
ccw = ['^', '<', 'v', '>']
inicio = cw.index(i)
_cw = cw[(inicio + n % 4) % 4]
inicio1 = ccw.index(i)
_ccw = ccw[(inicio1 + n % 4) % 4]
if _cw == f and _ccw != f:
	print('cw')
elif _ccw == f and _cw != f:
	print('ccw')
elif _cw == f and _ccw == f:
	print('undefined')


(x, y) = input().split()
n = int(input())
dirs = {'^': 1, '>': 2, 'v': 3, '<': 4}
if n % 2 == 0:
	print('undefined')
elif (dirs[y] - dirs[x]) % 4 == n % 4:
	print('cw')
else:
	print('ccw')


(fr, ls) = input().split()
n = int(input())
n %= 4
if n == 1:
	if fr == '^':
		if ls == '>':
			print('cw')
		else:
			print('ccw')
	if fr == '>':
		if ls == '^':
			print('ccw')
		else:
			print('cw')
	if fr == 'v':
		if ls == '>':
			print('ccw')
		else:
			print('cw')
	if fr == '<':
		if ls == '^':
			print('cw')
		else:
			print('ccw')
	exit()
if n == 3:
	if fr == '^':
		if ls == '<':
			print('cw')
		else:
			print('ccw')
	if fr == '>':
		if ls == '^':
			print('cw')
		else:
			print('ccw')
	if fr == 'v':
		if ls == '>':
			print('cw')
		else:
			print('ccw')
	if fr == '<':
		if ls == '^':
			print('ccw')
		else:
			print('cw')
	exit()
print('undefined')


(x, y) = input().split()
temp1 = 0
temp2 = 0
size = int(input())
list_cw = ['^', '>', 'v', '<', '^', '>', 'v', '<']
list_ccw = ['^', '<', 'v', '>', '^', '<', 'v', '>']
for i in range(0, 5):
	if x == list_cw[i] and y == list_cw[i + size % 4]:
		temp1 = 1
	if x == list_ccw[i] and y == list_ccw[i + size % 4]:
		temp2 = 2
	else:
		temp = 0
if temp1 == 1 and temp2 == 2:
	print('undefined')
elif temp1 == 1:
	print('cw')
else:
	print('ccw')


import sys

def f(cc):
	if ord(cc) == 118:
		return 0
	elif ord(cc) == 60:
		return 1
	elif ord(cc) == 94:
		return 2
	elif ord(cc) == 62:
		return 3
for word in sys.stdin:
	word = list(word)
	(a, b) = (word[0], word[2])
	n = int(input())
	ss = ''
	tmp1 = (f(a) + n) % 4
	tmp2 = (f(a) - n) % 4
	if tmp1 == tmp2:
		ss = 'undefined'
	elif tmp1 == f(b):
		ss = 'cw'
	elif tmp2 == f(b):
		ss = 'ccw'
	print(ss)


from sys import stdin, stdout
import cProfile, math
from collections import Counter
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10000000)

class Operation:

	def __init__(self, name, function, function_on_equal, neutral_value=0):
		self.name = name
		self.f = function
		self.f_on_equal = function_on_equal

def add_multiple(x, count):
	return x * count

def min_multiple(x, count):
	return x

def max_multiple(x, count):
	return x
sum_operation = Operation('sum', sum, add_multiple, 0)
min_operation = Operation('min', min, min_multiple, 1000000000.0)
max_operation = Operation('max', max, max_multiple, -1000000000.0)

class SegmentTree:

	def __init__(self, array, operations=[sum_operation, min_operation, max_operation]):
		self.array = array
		if type(operations) != list:
			raise TypeError('operations must be a list')
		self.operations = {}
		for op in operations:
			self.operations[op.name] = op
		self.root = SegmentTreeNode(0, len(array) - 1, self)

	def query(self, start, end, operation_name):
		if self.operations.get(operation_name) == None:
			raise Exception('This operation is not available')
		return self.root._query(start, end, self.operations[operation_name])

	def summary(self):
		return self.root.values

	def update(self, position, value):
		self.root._update(position, value)

	def update_range(self, start, end, value):
		self.root._update_range(start, end, value)

	def __repr__(self):
		return self.root.__repr__()

class SegmentTreeNode:

	def __init__(self, start, end, segment_tree):
		self.range = (start, end)
		self.parent_tree = segment_tree
		self.range_value = None
		self.values = {}
		self.left = None
		self.right = None
		if start == end:
			self._sync()
			return
		self.left = SegmentTreeNode(start, start + (end - start) // 2, segment_tree)
		self.right = SegmentTreeNode(start + (end - start) // 2 + 1, end, segment_tree)
		self._sync()

	def _query(self, start, end, operation):
		if end < self.range[0] or start > self.range[1]:
			return None
		if start <= self.range[0] and self.range[1] <= end:
			return self.values[operation.name]
		self._push()
		left_res = self.left._query(start, end, operation) if self.left else None
		right_res = self.right._query(start, end, operation) if self.right else None
		if left_res is None:
			return right_res
		if right_res is None:
			return left_res
		return operation.f([left_res, right_res])

	def _update(self, position, value):
		if position < self.range[0] or position > self.range[1]:
			return
		if position == self.range[0] and self.range[1] == position:
			self.parent_tree.array[position] = value
			self._sync()
			return
		self._push()
		self.left._update(position, value)
		self.right._update(position, value)
		self._sync()

	def _update_range(self, start, end, value):
		if end < self.range[0] or start > self.range[1]:
			return
		if start <= self.range[0] and self.range[1] <= end:
			self.range_value = value
			self._sync()
			return
		self._push()
		self.left._update_range(start, end, value)
		self.right._update_range(start, end, value)
		self._sync()

	def _sync(self):
		if self.range[0] == self.range[1]:
			for op in self.parent_tree.operations.values():
				current_value = self.parent_tree.array[self.range[0]]
				if self.range_value is not None:
					current_value = self.range_value
				self.values[op.name] = op.f([current_value])
		else:
			for op in self.parent_tree.operations.values():
				result = op.f([self.left.values[op.name], self.right.values[op.name]])
				if self.range_value is not None:
					bound_length = self.range[1] - self.range[0] + 1
					result = op.f_on_equal(self.range_value, bound_length)
				self.values[op.name] = result

	def _push(self):
		if self.range_value is None:
			return
		if self.left:
			self.left.range_value = self.range_value
			self.right.range_value = self.range_value
			self.left._sync()
			self.right._sync()
			self.range_value = None

	def __repr__(self):
		ans = '({}, {}): {}\n'.format(self.range[0], self.range[1], self.values)
		if self.left:
			ans += self.left.__repr__()
		if self.right:
			ans += self.right.__repr__()
		return ans

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def primeFactors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def isprime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result
TestCases = False
testingMode = False
optimiseForReccursion = False

def main():
	x = list(input().split())
	for (i, ele) in enumerate([94, 62, 118, 60]):
		if x[0] == chr(ele):
			a = i
		if x[1] == chr(ele):
			b = i
	n = get_int()
	x = n % 4
	a1 = (a + x) % 4 == b
	a2 = (a - x) % 4 == b
	if a1 and a2:
		print('undefined')
	elif a1:
		print('cw')
	else:
		print('ccw')
if TestCases:
	for _ in range(get_int()):
		cProfile.run('main()') if testingMode else main()
else:
	(cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()


(st, nd) = input().split()
n = int(input())
x = ['<', '^', '>', 'v']
st = x.index(st)
nd = x.index(nd)
if (st + nd) % 2 == 0:
	print('undefined')
else:
	n %= 4
	if (st + n) % 4 == nd:
		print('cw')
	else:
		print('ccw')


(a, b) = input().split(' ')
n = int(input())
d = {'v': 0, '>': 1, '^': 2, '<': 3}
(a, b) = (d[a], d[b])
ccw = bool((a + n) % 4 == b)
cw = bool((a - n) % 4 == b)
if cw and (not ccw):
	print('cw')
elif ccw and (not cw):
	print('ccw')
else:
	print('undefined')


(a, b) = map(str, input().split())
n = int(input())
f1 = ['<', 'v', '>', '^']
f2 = ['^', '>', 'v', '<']
h = n * 90 % 360 // 90
r = -h
j = -h
if a == '<':
	r += 0
	j += 3
elif a == 'v':
	r += 1
	j += 2
elif a == '>':
	r += 2
	j += 1
else:
	r += 3
	j += 0
if b == f1[r] == f2[j]:
	print('undefined')
elif b == f1[r]:
	print('cw')
elif b == f2[j]:
	print('ccw')
else:
	print('undefined')


S = list(input().split())
order = ['^', '>', 'v', '<']
N = int(input()) % 4
if N == 2 or N == 0:
	print('undefined')
elif N == 1:
	if order.index(S[1]) - order.index(S[0]) == 1 or order.index(S[1]) - order.index(S[0]) == -3:
		print('cw')
	else:
		print('ccw')
elif N == 3:
	if order.index(S[1]) - order.index(S[0]) == 3 or order.index(S[1]) - order.index(S[0]) == -1:
		print('cw')
	else:
		print('ccw')


(first, last) = input().split()
n = int(input())
cw = ['^', '>', 'v', '<', '^', '>', 'v', '<']
ccw = ['^', '<', 'v', '>', '^', '<', 'v', '>']
tmp1 = ''
tmp2 = ''
flag_cw = False
flag_ccw = False
movement = n % 4
tmp1 = cw[cw.index(first) + movement]
if tmp1 == last:
	flag_cw = True
tmp2 = ccw[ccw.index(first) + movement]
if tmp2 == last:
	flag_ccw = True
if flag_cw == flag_ccw == True:
	print('undefined')
elif flag_cw == True:
	print('cw')
else:
	print('ccw')


daf1 = ['^', '>', 'v', '<']
(a, b) = map(str, input().split())
n = int(input())
n = n % 4
if n % 2 == 0:
	print('undefined')
else:
	pos1 = daf1.index(a)
	posf = (pos1 + n) % 4
	fin = daf1[posf]
	if fin == b:
		print('cw')
	else:
		print('ccw')


(char1, char2) = input().split()
n = int(input()) % 4
cw = 'v<^>v<^>'
ccw = 'v>^<v>^<'
if n % 2 == 1 and cw[cw.find(char1) + n] == char2:
	print('cw')
elif n % 2 == 1 and ccw[ccw.find(char1) + n] == char2:
	print('ccw')
else:
	print('undefined')


states = ['v', '<', '^', '>']
(start, end) = input().split()
n = int(input())
cw = False
ccw = False
if states[(states.index(start) + n) % 4] == end:
	cw = True
if states[(states.index(start) - n) % 4] == end:
	ccw = True
print(['cw', 'ccw', 'undefined'][cw + ccw - (1 - ccw)])


(x, y) = map(str, input().split())
n = int(input())
if x == y:
	print('undefined')
elif x == '>' and y == '<':
	print('undefined')
elif x == '<' and y == '>':
	print('undefined')
elif x == '^' and y == 'v':
	print('undefined')
elif y == '^' and x == 'v':
	print('undefined')
elif x == '^' and y == '>':
	if (n - 1) % 4 == 0:
		print('cw')
	elif (n - 3) % 4 == 0:
		print('ccw')
	else:
		print('undefined')
elif x == '^' and y == '<':
	if (n - 1) % 4 == 0:
		print('ccw')
	elif (n - 3) % 4 == 0:
		print('cw')
	else:
		print('undefined')
elif x == 'v' and y == '>':
	if (n - 1) % 4 == 0:
		print('ccw')
	elif (n - 3) % 4 == 0:
		print('cw')
	else:
		print('undefined')
elif x == 'v' and y == '<':
	if (n - 1) % 4 == 0:
		print('cw')
	elif (n - 3) % 4 == 0:
		print('ccw')
	else:
		print('undefined')
elif y == '^' and x == '>':
	if (n - 1) % 4 == 0:
		print('ccw')
	elif (n - 3) % 4 == 0:
		print('cw')
	else:
		print('undefined')
elif y == '^' and x == '<':
	if (n - 1) % 4 == 0:
		print('cw')
	elif (n - 3) % 4 == 0:
		print('ccw')
	else:
		print('undefined')
elif y == 'v' and x == '>':
	if (n - 1) % 4 == 0:
		print('cw')
	elif (n - 3) % 4 == 0:
		print('ccw')
	else:
		print('undefined')
elif y == 'v' and x == '<':
	if (n - 1) % 4 == 0:
		print('ccw')
	elif (n - 3) % 4 == 0:
		print('cw')
	else:
		print('undefined')


s = input()
n = int(input())
a = 'v<^>v<^>'
b = 'v>^<v>^<'
if n % 2 == 0:
	print('undefined')
elif a[a.index(s[0]) + n % 4] == s[2]:
	print('cw')
elif b[b.index(s[0]) + n % 4] == s[2]:
	print('ccw')


d = {'v': ['v', '<', '^', '>'], '<': ['<', '^', '>', 'v'], '^': ['^', '>', 'v', '<'], '>': ['>', 'v', '<', '^']}
(start, end) = map(str, input().split())
n = int(input())
clock = d[start]
temp = clock[1:]
temp = temp[::-1]
anti = [clock[0]] + temp
mod = n % 4
if end == clock[mod] and end == anti[mod]:
	print('undefined')
elif end == clock[mod]:
	print('cw')
else:
	print('ccw')


(n, m) = input().strip().split()
t = int(input())
tr = t % 4
cww = [chr(118), '<', chr(94), '>']
cwww = [chr(118), '>', chr(94), '<']
p = cww.index(n)
q = cwww.index(n)
if cww[(p + tr) % 4] == cwww[(q + tr) % 4]:
	print('undefined')
elif cww[(p + tr) % 4] == m:
	print('cw')
elif cwww[(q + tr) % 4] == m:
	print('ccw')


def next(shape):
	if shape == 'v':
		return '<'
	elif shape == '<':
		return '^'
	elif shape == '^':
		return '>'
	else:
		return 'v'
(start, end) = input().split(' ')
n = int(input())
if n % 2 == 0:
	print('undefined')
elif n % 4 == 1:
	print('cw' if end == next(start) else 'ccw')
else:
	print('cw' if end == next(next(next(start))) else 'ccw')


elem = ['v', '<', '^', '>']
(a, b) = map(elem.index, input().split())
n = int(input())
diff = (b - a + 4) % 4
if diff == 0 or diff == 2:
	print('undefined')
elif diff == n % 4:
	print('cw')
else:
	print('ccw')


scw = ['0', 'v', '<', '^', '>']
sccw = ['0', 'v', '>', '^', '<']
(c1, c2) = input().split()
n = int(input())
n = n % 4
(n1, n2) = (scw.index(c1), sccw.index(c1))
if 4 - n1 >= n:
	a1 = scw[n1 + n]
else:
	a1 = scw[(n1 + n) % 4]
if 4 - n2 >= n:
	a2 = sccw[n2 + n]
else:
	a2 = sccw[(n2 + n) % 4]
if a1 == c2 and a2 == c2:
	print('undefined')
elif a1 == c2 and a2 != c2:
	print('cw')
else:
	print('ccw')


def main():
	(start, end) = input().split()
	n = int(input())
	d = {'v': 1, '<': 2, '^': 3, '>': 0}
	(start, end) = (d[start], d[end])
	rev = (start - n) % 4
	forw = (start + n) % 4
	if rev == forw == end:
		print('undefined')
	elif rev == end:
		print('ccw')
	elif forw == end:
		print('cw')
main()


d = dict(zip('v<^>', range(4)))
(x, y) = input().split()
t = int(input()) % 4
print('undefined' if t % 2 == 0 else 'ccw' if t == (d[x] - d[y]) % 4 else 'cw')


(i, f) = input().split()
n = int(input()) % 4
a = ['v', '<', '^', '>']
count = 0
t1 = False
t2 = False
temp = a.index(i)
while count < n:
	if temp == 3:
		temp = 0
	else:
		temp += 1
	count += 1
if a[temp] == f:
	t1 = True
count = 0
temp = a.index(i)
while count < n:
	if temp == 0:
		temp = 3
	else:
		temp -= 1
	count += 1
if a[temp] == f:
	t2 = True
if t1 == t2:
	print('undefined')
elif t1:
	print('cw')
else:
	print('ccw')


spins = ['v', '<', '^', '>']
spinner = list(map(str, input().split()))
n = int(input())
if n % 2 == 0:
	print('undefined')
elif (spins.index(spinner[0]) + n) % 4 == spins.index(spinner[1]):
	print('cw')
else:
	print('ccw')


(v1, v2) = input().split()
n = int(input())
o1 = ord(v1)
o2 = ord(v2)
if n % 4 == 0:
	print('undefined')
elif n % 4 == 1:
	if o1 == 118 and o2 == 60 or (o1 == 60 and o2 == 94) or (o1 == 94 and o2 == 62) or (o1 == 62 and o2 == 118):
		print('cw')
	else:
		print('ccw')
elif n % 4 == 2:
	print('undefined')
elif o1 == 118 and o2 == 62 or (o1 == 60 and o2 == 118) or (o1 == 94 and o2 == 60) or (o1 == 62 and o2 == 94):
	print('cw')
else:
	print('ccw')


import math as mt
import sys, string
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
s = input().split()
n = I()
flag = 0
if s[0] == '^' and s[1] == '>':
	if n % 4 == 1:
		ans1 = 'cw'
	if n % 4 == 3:
		ans1 = 'ccw'
if s[0] == '^' and s[1] == '<':
	if n % 4 == 1:
		ans1 = 'ccw'
	elif n % 4 == 3:
		ans1 = 'cw'
if s[0] == 'v' and s[1] == '>':
	if n % 4 == 1:
		ans1 = 'ccw'
	if n % 4 == 3:
		ans1 = 'cw'
if s[0] == 'v' and s[1] == '<':
	if n % 4 == 1:
		ans1 = 'cw'
	elif n % 4 == 3:
		ans1 = 'ccw'
if s[0] == '<' and s[1] == 'v':
	if n % 4 == 1:
		ans1 = 'ccw'
	if n % 4 == 3:
		ans1 = 'cw'
if s[0] == '<' and s[1] == '^':
	if n % 4 == 1:
		ans1 = 'cw'
	elif n % 4 == 3:
		ans1 = 'ccw'
if s[0] == '>' and s[1] == 'v':
	if n % 4 == 1:
		ans1 = 'cw'
	if n % 4 == 3:
		ans1 = 'ccw'
if s[0] == '>' and s[1] == '^':
	if n % 4 == 1:
		ans1 = 'ccw'
	elif n % 4 == 3:
		ans1 = 'cw'
if s[0] == '^' and s[1] == '^':
	if n % 4 == 0:
		flag = 1
if s[0] == '^' and s[1] == 'v':
	if n % 4 == 2:
		flag = 1
if s[0] == '<' and s[1] == '<':
	if n % 4 == 0:
		flag = 1
if s[0] == '<' and s[1] == '>':
	if n % 4 == 2:
		flag = 1
if s[0] == '>' and s[1] == '>':
	if n % 4 == 0:
		flag = 1
if s[0] == '>' and s[1] == '<':
	if n % 4 == 2:
		flag = 1
if s[0] == 'v' and s[1] == 'v':
	if n % 4 == 0:
		flag = 1
if s[0] == 'v' and s[1] == '^':
	if n % 4 == 2:
		flag = 1
if flag == 1:
	print('undefined')
else:
	print(ans1)


import math

def ria():
	return [int(i) for i in input().split()]
(a, b) = input().split()
n = ria()[0]
possible = []
st = '^>v<'
if st[(st.find(a) + n) % 4] == b:
	possible.append('cw')
if st[(st.find(a) - n) % 4] == b:
	possible.append('ccw')
if possible.__len__() > 1:
	print('undefined')
else:
	print(possible[0])


def rotate(start, n_rotations, direction):
	return (start + n_rotations * direction) % 4

def main():
	positions = {'^': 0, '>': 1, 'v': 2, '<': 3}
	[start, end] = input().split()
	(start, end) = (positions[start], positions[end])
	n_rotations = int(input())
	clockwise = rotate(start, n_rotations, 1)
	cclockwise = rotate(start, n_rotations, -1)
	print('undefined' if clockwise == cclockwise else 'cw' if clockwise == end else 'ccw')
main()


import sys
Input = sys.stdin.readline
tmp = 'v<^>'
(x, y) = Input().split()
a = tmp.index(x)
b = tmp.index(y)
n = int(Input())
if n % 2 == 0:
	print('undefined')
elif tmp[a - n % 4] == y:
	print('ccw')
else:
	print('cw')


(st, en) = input().split(' ')
n = int(input())
n = n % 4
if n == 0:
	print('undefined')
elif n == 1:
	if st == '^' and en == '>' or (st == '>' and en == 'v') or (st == 'v' and en == '<') or (st == '<' and en == '^'):
		print('cw')
	elif st == '^' and en == '<' or (st == '>' and en == '^') or (st == 'v' and en == '>') or (st == '<' and en == 'v'):
		print('ccw')
	else:
		print('undefined')
elif n == 2:
	if st == '^' and en == 'v' or (st == '>' and en == '<') or (st == 'v' and en == '^') or (st == '<' and en == '>'):
		print('undefined')
elif n == 3:
	if st == '^' and en == '>' or (st == '>' and en == 'v') or (st == 'v' and en == '<') or (st == '<' and en == '^'):
		print('ccw')
	elif st == '^' and en == '<' or (st == '>' and en == '^') or (st == 'v' and en == '>') or (st == '<' and en == 'v'):
		print('cw')
	else:
		print('undefined')


alph = 'v<^>'
pos = input()
n = int(input())
if n % 2 == 0:
	print('undefined')
elif (alph.find(pos[0]) - alph.find(pos[2])) % 4 - n % 4 == 0:
	print('ccw')
else:
	print('cw')


a = (94, 62, 118, 60, 94, 62, 118, 60)
b = (94, 60, 118, 62, 94, 60, 118, 62)
s = (*map(ord, input().split()),)
n = int(input()) % 4
if a[a.index(s[0]) + n] == s[1] and b[b.index(s[0]) + n] != s[1]:
	print('cw')
elif a[a.index(s[0]) + n] != s[1] and b[b.index(s[0]) + n] == s[1]:
	print('ccw')
else:
	print('undefined')


def cw(c, n):
	if c == '^':
		if n == 1:
			return '>'
		if n == 3:
			return '<'
	if c == '>':
		if n == 1:
			return 'v'
		if n == 3:
			return '^'
	if c == 'v':
		if n == 1:
			return '<'
		if n == 3:
			return '>'
	if c == '<':
		if n == 1:
			return '^'
		if n == 3:
			return 'v'

def rev(c):
	if c == 'v':
		return '^'
	if c == '^':
		return 'v'
	if c == '<':
		return '>'
	return '<'
(st, f) = input().split()
n = int(input())
if f == rev(st) or f == st:
	print('undefined')
elif f == cw(st, n % 4):
	print('cw')
else:
	print('ccw')


(st1, ed) = map(str, input().split())
m = ['v', '<', '^', '>']
si = m.index(st1)
ei = m.index(ed)
n = int(input())
n %= 4
if n % 2 == 0:
	print('undefined')
elif m[si - n] == ed:
	print('ccw')
else:
	print('cw')


(start, end) = input().split(' ')
n = int(input())
xn = n
yn = n
if start == '^':
	xn += 0
elif start == '>':
	xn += 1
elif start == 'v':
	xn += 2
elif start == '<':
	xn += 3
if start == '^':
	yn += 0
elif start == '<':
	yn += 1
elif start == 'v':
	yn += 2
elif start == '>':
	yn += 3
states_cw = '^>v<'
states_ccw = '^<v>'
xn %= 4
yn %= 4
if states_cw[xn] == end and states_ccw[yn] == end:
	print('undefined')
elif states_cw[xn] == end:
	print('cw')
elif states_ccw[yn] == end:
	print('ccw')
else:
	print('undefined')


(s, e) = input().split()
n = int(input())
ccw = '^<v>^<v>'
cw = '^>v<^>v<'
i = n % 4
if cw[cw.index(s) + i] == ccw[ccw.index(s) + i] == e:
	print('undefined')
elif ccw[ccw.index(s) + i] == e:
	print('ccw')
else:
	print('cw')


inp = input().split()
duration = int(input()) % 4
start = inp[0]
end = inp[1]
if start == '^':
	if duration == 1:
		if end == '>':
			print('cw')
		else:
			print('ccw')
	elif duration == 3:
		if end == '>':
			print('ccw')
		else:
			print('cw')
	else:
		print('undefined')
if start == '>':
	if duration == 1:
		if end == 'v':
			print('cw')
		else:
			print('ccw')
	elif duration == 3:
		if end == 'v':
			print('ccw')
		else:
			print('cw')
	else:
		print('undefined')
if start == 'v':
	if duration == 1:
		if end == '<':
			print('cw')
		else:
			print('ccw')
	elif duration == 3:
		if end == '<':
			print('ccw')
		else:
			print('cw')
	else:
		print('undefined')
if start == '<':
	if duration == 1:
		if end == '^':
			print('cw')
		else:
			print('ccw')
	elif duration == 3:
		if end == '^':
			print('ccw')
		else:
			print('cw')
	else:
		print('undefined')


(n, t) = map(str, input().split())
i = int(input())
if i < 0:
	i = 4 - abs(i) % 4
else:
	i %= 4
if n == '^':
	a = 1
elif n == '>':
	a = 2
elif n == 'v':
	a = 3
elif n == '<':
	a = 4
if t == '^':
	b = 1
elif t == '>':
	b = 2
elif t == 'v':
	b = 3
elif t == '<':
	b = 4
c = b - a
if c < 0:
	c = 4 - abs(c) % 4
else:
	c %= 4
if i == 0 or i == 2:
	print('undefined')
elif c == i:
	print('cw')
else:
	print('ccw')


cw = '<^>v'
ccw = '<v>^'
(start, end) = input().split()
time = int(input())
last_turns = time % 4
cw_end_pos = (cw.index(start) + last_turns) % 4
ccw_end_pos = (ccw.index(start) + last_turns) % 4
if cw[cw_end_pos] == ccw[ccw_end_pos]:
	print('undefined')
elif cw[cw_end_pos] == end:
	print('cw')
else:
	print('ccw')


(s, e) = input().split()
n = int(input())
n %= 4
if n == 2 or n == 0:
	print('undefined')
elif n == 1:
	if s == '<' and e == '^' or (s == '^' and e == '>') or (s == '>' and e == 'v') or (s == 'v' and e == '<'):
		print('cw')
	else:
		print('ccw')
elif s == '<' and e == 'v' or (s == '^' and e == '<') or (s == '>' and e == '^') or (s == 'v' and e == '>'):
	print('cw')
else:
	print('ccw')


(a, b) = input().split()
n = int(input())
l = ['v', '<', '^', '>']
i = l.index(a)
j = l.index(b)
if (j - i + 4) % 4 == 0 or (j - i + 4) % 4 == 2:
	print('undefined')
elif (j - i + 4) % 4 == n % 4:
	print('cw')
else:
	print('ccw')


(a, b) = map(str, input().split())
n = int(input())
c = ['v', '<', '^', '>', 'v', '<', '^', '>']
d = ['v', '>', '^', '<', 'v', '>', '^', '<']
if n % 4 == 1:
	for i in range(8):
		if a == c[i]:
			if b == c[i + 1]:
				print('cw')
				break
			else:
				for i in range(8):
					if a == d[i]:
						if b == d[i + 1]:
							print('ccw')
							break
						else:
							print('undefined')
							break
				break
elif n % 4 == 3:
	for i in range(8):
		if a == c[i]:
			if b == c[i + 3]:
				print('cw')
				break
			else:
				for i in range(8):
					if a == d[i]:
						if b == d[i + 3]:
							print('ccw')
							break
						else:
							print('undefined')
							break
				break
else:
	print('undefined')


(a, c, b) = list(str(input()))
n = int(input())
s = [94, 62, 118, 60]
if n % 2 == 0:
	print('undefined')
else:
	k = s.index(ord(a))
	if s[(k + n) % 4] == ord(b):
		print('cw')
	else:
		print('ccw')


(s, f) = map(ord, input().split(' '))
n = int(input())
a = [118, 60, 94, 62]
if not n % 2:
	print('undefined')
else:
	n %= 4
	k = a.index(s)
	if a[k - n] == f:
		print('ccw')
	else:
		print('cw')


a = input().split()
n = int(input())
m = ['^', '>', 'v', '<']
a1 = a[0]
a2 = a[1]
no = m.index(a1)
m1 = [m[no], m[(no + 1) % 4], m[(no + 2) % 4], m[(no + 3) % 4]]
n1 = n % 4
n2 = 4 - n1
if n1 == n2 or n == 0 or a1 == a2:
	print('undefined')
elif m1[n1] == a2:
	print('cw')
else:
	print('ccw')


positions = '>v<^'
(s, t) = input().split()
n = int(input())
si = positions.index(s)
ti_cw = positions[(si + n) % 4]
ti_ccw = positions[(si - n) % 4]
if n % 2 == 0:
	print('undefined')
elif t == ti_cw:
	print('cw')
elif t == ti_ccw:
	print('ccw')
else:
	assert False


pos = {'>': 0, 'v': 1, '<': 2, '^': 3}
(s, e) = input().split(' ')
spins = int(input())
x = (pos[e] - pos[s] - spins) % 4
if spins % 2 == 0:
	ans = 'undefined'
elif (pos[e] - pos[s]) % 4 == spins % 4:
	ans = 'cw'
elif (pos[s] - pos[e]) % 4 == spins % 4:
	ans = 'ccw'
print(ans)


s = '^>v<'
(a, b) = input().split()
n = int(input())
a = s.index(a)
b = s.index(b)
ok1 = False
ok2 = False
if (a + n) % 4 == b:
	ok1 = True
if (a - n) % 4 == b:
	ok2 = True
elif (a - n) % 4 + 4 == b:
	ok2 = True
if ok1 and (not ok2):
	print('cw')
elif not ok1 and ok2:
	print('ccw')
else:
	print('undefined')


(s, e) = input().split()
states = '^>v<'
n = int(input())
if n % 2 == 0:
	print('undefined')
elif (states.index(e) - states.index(s)) % 4 == n % 4:
	print('cw')
else:
	print('ccw')


(s, n, f, sp) = (input(), int(input()), 0, 'v<^>')
l = sp.index(s[0])
if sp[(l + n) % 4] == s[2]:
	f += 1
if sp[(l - n) % 4] == s[2]:
	f += 2
if f == 1:
	print('cw')
elif f == 2:
	print('ccw')
else:
	print('undefined')