import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * Created by dell on 7/30/2017.
 */
public class spinner {
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String args[])throws IOException {
        FastReader sc = new FastReader();
        String line1 = sc.nextLine();
        char s = line1.charAt(0);
        char e = line1.charAt(2);
        int sec=sc.nextInt();
        int x=sec%4;
        int index=0;
        char a[]={'v','<','^','>'};
        for(int i=0;i<=3;i++)
        {
            if(a[i]==s)
                index=i;
        }
        int flag=0;
        int c=0;
        int cw=0;

        if(a[(index+x)%4]==e)
        {
            flag=1;
            c++;
            cw=1;
        }

            int t=index-x;

            if(t<0)
            {
                t=4+t;
            }
            if(a[t]==e)
            {
                c++;
                flag=1;
                cw=0;
            }

        if(flag==0 || c==2)
        {
            System.out.println("undefined");
        }
        if(c==1 && cw==0)
            System.out.println("ccw");
        if(c==1 && cw==1)
            System.out.println("cw");
    }
}

import java.util.*;
import java.io.*;
public class The_Useless_Toy
{
	public static void main(String args[]) throws Exception
	{
		BufferedReader f=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer(f.readLine());
		HashMap<String,Integer> map=new HashMap<String,Integer>();
		map.put("<",0);
		map.put("^",1);
		map.put(">",2);
		map.put("v",3);
		String a=st.nextToken();
		String b=st.nextToken();
		int time=Integer.parseInt(f.readLine());
		if(Math.abs(map.get(a)-map.get(b))==2||map.get(a)==map.get(b))
			System.out.println("undefined");
		else
		{
			time=time%4;
			if((map.get(b)-map.get(a)+4)%4==time)
				System.out.println("cw");
			else
				System.out.println("ccw");
		}
	}
}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.lang.*;

public class ppm {

  static class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;

    public InputReader(InputStream st) {
      this.stream = st;
    }

    public int read() {
      if (snumChars == -1)
        throw new InputMismatchException();
      if (curChar >= snumChars) {
        curChar = 0;
        try {
          snumChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (snumChars <= 0)
          return -1;
      }
      return buf[curChar++];
    }

    public int nextInt() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      int res = 0;
      do {
        res *= 10;
        res += c - '0';
        c = read();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public long nextLong() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      long res = 0;
      do {
        res *= 10;
        res += c - '0';
        c = read();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public int[] nextIntArray(int n) {
      int a[] = new int[n];
      for (int i = 0; i < n; i++) {
        a[i] = nextInt();
      }
      return a;
    }

    public String readString() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = read();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public String nextLine() {
      int c = read();
      while (isSpaceChar(c))
        c = read();
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = read();
      } while (!isEndOfLine(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
      return c == '\n' || c == '\r' || c == -1;
    }

  }

    public static void main(String[] args){

    InputReader in = new InputReader(System.in);
    PrintWriter w = new PrintWriter(System.out);

        String s=in.nextLine();
       // System.out.println(s);
        int n=in.nextInt();
        char a=s.charAt(0);
        char b=s.charAt(2);
        int p=0,q=0;
        p=n%4;
        if((a=='v' && b=='<') )
        {
            if(p==1)
                System.out.println("cw");
            else if(p==3)
                 System.out.println("ccw");
            else
                System.out.println("undefined");
        }
        else if((a=='<' && b=='v') )
        {
            if(p==3)
                System.out.println("cw");
            else if(p==1)
                 System.out.println("ccw");
            else
                System.out.println("undefined");
        }
        else if((a=='v' && b=='^') ||(b=='v' && a=='^'))
        {
            if(p==2)
                System.out.println("undefined");
           /* else if(p==3)
                 System.out.println("ccw");
            else
                System.out.println("undefined");*/
        }
        else if((a=='v' && b=='>') )
        {
            if(p==3)
                System.out.println("cw");
            else if(p==1)
                 System.out.println("ccw");
            else
                System.out.println("undefined");
        }
         else if((a=='>' && b=='v') )
        {
            if(p==1)
                System.out.println("cw");
            else if(p==3)
                 System.out.println("ccw");
            else
                System.out.println("undefined");
        }
        else if((a=='<' && b=='^'))
        {
            if(p==1)
                System.out.println("cw");
            else if(p==3)
                 System.out.println("ccw");
            else
                System.out.println("undefined");
        }
        else  if((a=='^' && b=='<'))
        {
            if(p==3)
                System.out.println("cw");
            else if(p==1)
                 System.out.println("ccw");
            else
                System.out.println("undefined");
        }
        else if( (a=='<' && b=='>') || (b=='<' && a=='>') )
        {
           if(p==2)
                System.out.println("undefined");
        }
         else   if( (a=='^' && b=='>')  )
        {
            if(p==1)
                System.out.println("cw");
            else if(p==3)
                 System.out.println("ccw");
            else
                System.out.println("undefined");
        }
         else   if( (a=='>' && b=='^')  )
        {
            if(p==3)
                System.out.println("cw");
            else if(p==1)
                 System.out.println("ccw");
            else
                System.out.println("undefined");
        }
         else
         {
             System.out.println("undefined");
         }
    }
}

import java.util.*;
public class Main {

	public static void main(String[] args) {

		Scanner scan=new Scanner(System.in);
		String start=null,end=null;
		int num=0;
		start=scan.next();
		if(scan.hasNext()){
			end=scan.next();
		}
		if(scan.hasNext()){
			num=scan.nextInt();
			num=num%4;
		}
		String[] A={"v","<","^",">"};
		int cw=0,ccw=0;
		for(int i=0;i<4;i++){

			if(start.equals(A[i])){
				//System.out.println(A[i]+i);
				int l=i,r=i;
				for(int j=0;j<num;j++){
					l++;
					if(l==4){l=0;}
				}
				if(A[l].equals(end)){cw=1;}

				for(int j=0;j<num;j++){
					r--;
					if(r==-1){r=3;}
				}
				if(A[r].equals(end)){ccw=1;}

				if(cw==1&&ccw==1){
					System.out.println("undefined");
				}else if(cw==1){
					System.out.println("cw");
				}else{
					System.out.println("ccw");
				}

				break;
			}

		}

	}

}

import java.util.*;
public class test{
	public static void main(String[] args) {
		Scanner ob=new Scanner(System.in);

		char c1=ob.next(".").charAt(0);
		char c2=ob.next(".").charAt(0);
		ob.nextLine();
		int n=ob.nextInt();
		if(n>3){
			n=n%4;
		}
		int start_position=0;
		char arr[]={'v','<','^','>'};
		for(int i=0;i<arr.length;i++){
			if(c1==arr[i]){
				start_position=i;
				break;
			}
		}
		int clock_position=n+start_position;
		int anticlock_position=start_position-n+4;

		if(clock_position>=4)
			clock_position=clock_position%4;
		if (anticlock_position>=4) {
			anticlock_position=anticlock_position%4;
		}

		if(arr[clock_position]==c2 && arr[anticlock_position]==c2)
			System.out.println("undefined");
		else if(arr[clock_position]==c2)
			System.out.println("cw");
		else
			System.out.println("ccw");

	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CF426A {
	public static void main(String[] args) {
		char map[] = new char[256];
		map['v'] = 0;
		map['<'] = 1;
		map['^'] = 2;
		map['>'] = 3;
		MyScanner in = new MyScanner();
		char start = in.next().charAt(0);
		char end = in.next().charAt(0);
		int n = in.nextInt();
		if (Math.abs(map[start] - map[end]) == 2 || Math.abs(map[start] - map[end]) == 0) {
			System.out.println("undefined");
		} else {
			if ((map[start] + n) % 4 == map[end]) {
				System.out.println("cw");
			} else {
				System.out.println("ccw");
			}
		}
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}

import java.io.*;
import java.util.*;

public class Main {
    static FastScanner in;
    static PrintWriter out;
    static final int MOD = 1000000007;

    public static void main(String[] args) throws IOException {
        //        Scanner in = new Scanner(new File("input.txt"));
        //        Scanner in = new Scanner(System.in);
        //        System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream("output.txt")), true));
        out = new PrintWriter(System.out);
        in = new FastScanner(System.in);
        //        in = new FastScanner("input.txt");
        char s[] = in.nextLine().toCharArray();
        int n = in.nextInt();
        char a1 = s[0];
        char a2 = s[2];
        Map<Character, Integer> map = new HashMap<Character, Integer>();
        map.put('<', 0);
        map.put('v', 1);
        map.put('>', 2);
        map.put('^', 3);
        int b1 = map.get(a1);
        int b2 = map.get(a2);
        //        out.println(b1 + " " + b2);
        if ((b1 + n % 4) % 4 == b2 && (4 + b1 - n % 4) % 4 != b2)
            out.println("ccw");
        else if ((4 + b1 - n % 4) % 4 == b2 && (b1 + n % 4) % 4 != b2)
            out.println("cw");
        else
            out.println("undefined");
        out.close();
    }
}

class Pair {
    public String first; //first member of pair
    public int second; //second member of pair
    public Integer length;

    public Pair(String first, int second, int length) {
        this.first = first;
        this.second = second;
        this.length = length;
    }

    public Pair() {

    }
}

class PairComparable implements Comparator<Pair> {

    @Override
    public int compare(Pair o1, Pair o2) {
        if (o1.second < o2.second)
            return -1;
        else if (o1.second > o2.second)
            return 1;
        else {
            return -o1.length.compareTo(o2.length);
        }
    }
}

class FastScanner {

    BufferedReader br;
    StringTokenizer tokenizer;

    FastScanner(String fileName) throws FileNotFoundException {
        this(new FileInputStream(new File(fileName)));
    }

    FastScanner(InputStream is) {
        br = new BufferedReader(new InputStreamReader(is));
    }

    String nextLine() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    String next() throws IOException {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            String line = br.readLine();
            if (line == null) {
                return null;
            }
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    char nextChar() throws IOException {
        return next().charAt(0);
    }
}

/**
 * Created by Helga on 7/31/2017.
 */
// v - 118, < - 60, ^ - 94, > - 62
import java.util.*;
public class Main {
    public static void main(String... args)
    {
        Scanner input=new Scanner(System.in);
        String buf=input.nextLine();
        int begginingPosition=(int)buf.charAt(0);
        int finalPosition=(int)buf.charAt(2);
        int seconds=input.nextInt();
        int begin=0;int end=0;
         int[] positions=new int[5];
         positions[0]=0;
         positions[1]=118;
         positions[2]=60;
         positions[3]=94;
         positions[4]=62;
         boolean beginDone=false,endDone=false;
         for(int i=1;i<=4;i++)
         {
             if(begginingPosition==positions[i])
             {
                 begin=i;
                 beginDone=true;
             }
             if(finalPosition==positions[i])
             {
                 end=i;
                 endDone=true;
             }
             if(beginDone&&endDone)
             {
                 break;
             }
         }
         int connection=seconds%4;
         if(connection==2||connection==0)
         {
             System.out.println("undefined");
             return;
         }
         int difference=(end-begin);
         if(difference<0)
         {
             difference=4+difference;
         }

         if (difference==connection)
         {
             System.out.println("cw");
         }
         else
         {
             System.out.println("ccw");
         }
        //System.out.println(begginingPosition+" "+finalPosition+" "+seconds+" "+connection+" "+end+" "+begin+" "+difference);

    }
}

import java.util.*;
public class Test {
    public static void main(String[] args) {
    Scanner input=new Scanner(System . in );
    char []a={'^','>','v','<'};

    char c1=input.next().charAt(0),c2=input.next().charAt(0);
    int n=input.nextInt();
        if (n%2==0) {
            System.out.println("undefined");
        }
        else{
            int k,m;
            for ( k = 0; k < 4; k++) {
                if (a[k]==c1) {
                    break;
                }
            }
           m=n%4;
            if (m+k>4) {
              m=m+k-4;
            }
            else if (m+k<4) {
                m=m+k;
            }
            else m=0;
                if (a[m]==c2) {
                    System.out.println("cw");
                }else System.out.println("ccw");
            }
        }

    }

import java.io.*;
import java.util.*;

public class TheUselessToy {

	public static void main(String []args) {

		Scanner in = new Scanner(System.in);
		String str = in.nextLine();
		String s[] = str.split(" ");
		int n = in.nextInt();
		String cw[] = {"v","<","^",">"};
		String ccw[] = {"v",">","^","<"};
		if((s[0].contentEquals("^")||s[0].contentEquals("v")) && (s[1].contentEquals("v")||s[1].contentEquals("^")))
			System.out.println("undefined");
		else if(n%4==0)
			System.out.println("undefined");
		else
		{
			String first = s[0];
			int var1 = 0, var2 = 0;
			for(int i=0;i<=3;i++)
			{
				if(first.equals(cw[i]))
					var1 = i;
				if(first.equals(ccw[i]))
					var2 = i;
			}
			int ans = 0;
			if(n%4==1)
			{
				ans = 1;
			}
			else if(n%4==2)
			{
				ans = 2;
			}
			else if(n%4==3)
			{
				ans = 3;
			}

			int ans1 = ans + var1;
			int ans2 = ans + var2;
			if(cw[ans1%4].contentEquals(s[1]) && ccw[ans2%4].contentEquals(s[1]))
				System.out.println("undefined");
			else if(cw[ans1%4].contentEquals(s[1]))
				System.out.println("cw");
			else
				System.out.println("ccw");

		}
	}
}

import java.io.*;
import java.util.*;

public class A {
    FScanner in = new FScanner();
    PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out), true);

    void run() {
        char c1 = in.next().charAt(0);
        char c2 = in.next().charAt(0);
        int x = -1, y = -1;
        if (c1 == '^')
            x = 1;
        else if (c1 == '>')
            x = 2;
        else if (c1 == 'v')
            x = 3;
        else if (c1 == '<')
            x = 4;
        if (c2 == '^')
            y = 1;
        else if (c2 == '>')
            y = 2;
        else if (c2 == 'v')
            y = 3;
        else if (c2 == '<')
            y = 4;
        int n = in.nextInt();
        String ans = "";
        if (n % 2 == 0)
            ans = "undefined";
        else if ((x + n) % 4 == y % 4)
            ans = "cw";
        else if ((y + n) % 4 == x % 4)
            ans = "ccw";
        out.print(ans);
        out.close();
    }

    public static void main(String[] args){
        new A().run();
    }

    static class FScanner {
        BufferedReader br;
        StringTokenizer st;

        FScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

import java.util.Scanner;

public class UselessToy {
    private static final int[][] CW = {
            {-1,1,-1,3},
            {3,-1,1,-1},
            {-1,3,-1,1},
            {1,-1,3,-1}
    };
    private static final int[][] CCW = {
            {-1,3,-1,1},
            {1,-1,3,-1},
            {-1,1,-1,3},
            {3,-1,1,-1}
    };
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int startPos = posIdx(scanner.next().charAt(0));
        int endPos = posIdx(scanner.next().charAt(0));
        int transitions = scanner.nextInt() % 4;
        if (CW[startPos][endPos]==transitions) {
            System.out.println("cw");
        } else if (CCW[startPos][endPos]==transitions) {
            System.out.println("ccw");
        } else {
            System.out.println("undefined");
        }
    }

    public static int posIdx(char pos) {
        return pos=='v'? 0 : pos=='<' ? 1 : pos=='^'? 2 : 3;
    }
}

import java.io.*;
import java.util.StringTokenizer;
public class Useless {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer t = new StringTokenizer(in.readLine());
        String a = t.nextToken();
        String b = t.nextToken();
        int c = 0;
        int d = 0;
        int n = Integer.parseInt(in.readLine());
        if(a.equals("v"))
            c = 0;
        if(b.equals("v"))
            d = 0;
        if(a.equals(">"))
            c = 1;
        if(b.equals(">"))
            d = 1;
        if(a.equals("^"))
            c = 2;
        if(b.equals("^"))
            d = 2;
        if(a.equals("<"))
            c = 3;
        if(b.equals("<"))
            d = 3;
        int ccw = (c+n)%4;
        int cw = c - (n%4);
        if(cw==-1)
            cw = 3;
        if(cw==-2)
            cw = 2;
        if(cw==-3)
            cw = 1;
        if(cw==d && ccw!=d)
            System.out.println("cw");
        else if(cw!=d && ccw==d)
            System.out.println("ccw");
        else
            System.out.println("undefined");

    }
}

import java.util.Scanner;

public class UselessToy {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int startPos = posIdx(scanner.next().charAt(0));
        int endPos = posIdx(scanner.next().charAt(0));
        int transitions = scanner.nextInt();
        if (transitions%2==0) {
            System.out.println("undefined");
            return;
        }
        int endCW = (startPos + transitions) % 4;
        int endCCW = (startPos - transitions) % 4;
        if (endCCW<0) {
            endCCW += 4;
        }
        if (endCW==endPos) {
            System.out.println("cw");
        } else if (endCCW == endPos) {
            System.out.println("ccw");
        } else {
            System.out.println("undefined");
        }
    }

    public static int posIdx(char pos) {
        return pos=='v'? 0 : pos=='<' ? 1 : pos=='^'? 2 : 3;
    }
}

import java.util.Scanner;

public class C426A {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String start = scanner.next();
        int st;
        String end = scanner.next();
        int en;
        int seconds = scanner.nextInt();

        switch (start) {
            case "^":
                st = 0;
                break;
            case ">":
                st = 1;
                break;
            case "v":
                st = 2;
                break;
            default:
                st = 3;
                break;
        }

        switch (end) {
            case "^":
                en = 0;
                break;
            case ">":
                en = 1;
                break;
            case "v":
                en = 2;
                break;
            default:
                en = 3;
                break;
        }

        int enC = (st + seconds) % 4;
        int  enCC = (((st - seconds) % 4) + 4) % 4;

        if (enC == en && !(enCC == en)) System.out.println("cw");
        else if (enCC == en && !(enC == en)) System.out.println("ccw");
        else System.out.println("undefined");
    }
}

import java.io.*;
import java.util.*;
import java.lang.*;

public class spin{

    public static void main(String[] args) {

        char[] spin=new char[4];
        spin[0]=118;
        spin[1]=60;
        spin[2]=94;
        spin[3]=62;

        FastScanner fi=new FastScanner();
        long n;
        char[] start=fi.next().toCharArray();
        char []end=fi.next().toCharArray();
        n=fi.nextInt();
        int cw,ccw;
        String ans=" ";
        int i,j,k,d;
        int st,en;
        st=en=cw=ccw=0;
        for (i=0;i<4 ;i++ )
        {
            if (start[0]==spin[i]) {
                st=i;
            }
            if (end[0]==spin[i]) {
                en=i;
            }

        }
        d=Math.abs(st-en);
        if (st < en)
        {
            if (n>=d && (n-d)%4==0)
            {
                cw=1;
                ans="cw";
            }
            d=4-d;
            if (n>=d &&(n-d)%4==0 )
            {
                ccw=1;
                ans="ccw";
            }

        }
        else
        {
            if (n>=d && (n-d)%4==0)
            {
                ccw=1;
                ans="ccw";
            }
            d=4-d;
            if (n>=d && (n-d)%4==0)
            {
                cw=1;
                ans="cw";
            }
            if (st==en && n==0)
            {
                cw=ccw=1;
            }
        }

        if ((cw==1 && ccw==1) || (cw==0 && ccw==0)) {
            ans="undefined";
        }

        System.out.println(ans);
    }
}
class FastScanner
{
    BufferedReader br;
    StringTokenizer st;

    FastScanner()
    {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public String next()
    {
        while (st == null || !st.hasMoreTokens())
        {
            try
            {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    public int nextInt()
    {
        return Integer.parseInt(next());
    }
}

import java.util.Scanner;

/**
 * Created by ARKA on 03-08-2017.
 */
public class Imperium998 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String art = sc.nextLine();
        int spin = Integer.parseInt(sc.nextLine());

        spin = spin%4;

        String ans = "";
        if(spin%2==0)
            ans = "undefined";
        else {
            char firstCharacter = art.charAt(0);
            char secondCharacter = art.charAt(2);

            char[] a = {'v', '<', '^', '>'};

            int placefirst = 0;
            int placesecond = 0;

            for (int i = 0; i < a.length; i++) {
                if (a[i] == firstCharacter)
                    placefirst = i;
                if (a[i] == secondCharacter)
                    placesecond = i;
            }

            int delta = (placesecond - placefirst + 4) % 4;

            if(delta == spin){
                ans = "cw";
            }
            else
                ans = "ccw";
        }

        System.out.println(ans);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    boolean cwFlag, ccwFlag;
    char[] cw = {'^', '>', 'v', '<'};
    char[] ccw = {'^', '<', 'v', '>'};
    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    public void run() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] spin = br.readLine().split(" ");
        char start = spin[0].charAt(0);
        char end = spin[1].charAt(0);
        long n = Integer.parseInt(br.readLine());

        char curr = start;
        int currCount = 0;

        int mod = (int)(n % 4);

        if(curr == end && n == 0) {
            cwFlag = true;
        } else {
            for (int i = 0; i < mod; i++) {
                if (curr == '^') {
                    curr = '>';
                } else if (curr == '>') {
                    curr = 'v';
                } else if (curr == 'v') {
                    curr = '<';
                } else if (curr == '<') {
                    curr = '^';
                }
                currCount++;
                if (curr == end && currCount == mod) {
                    cwFlag = true;
                    break;
                }
            }
        }

        curr = start;
        currCount = 0;
        if(curr == end && n == 0) {
            ccwFlag = true;
        } else {
            for (int i = 0; i < mod; i++) {
                if (curr == '^') {
                    curr = '<';
                } else if (curr == '<') {
                    curr = 'v';
                } else if (curr == 'v') {
                    curr = '>';
                } else if (curr == '>') {
                    curr = '^';
                }
                currCount++;
                if (curr == end && currCount == mod) {
                    ccwFlag = true;
                    break;
                }
            }
        }

        if(cwFlag && !ccwFlag) {
            System.out.println("cw");
        } else if(!cwFlag && ccwFlag) {
            System.out.println("ccw");
        } else {
            System.out.println("undefined");
        }
    }
}

import java.util.*;
import java.io.*;

public final class Main {

    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        char firstChar = Character.valueOf(st.nextToken().charAt(0));
        char secondChar = Character.valueOf(st.nextToken().charAt(0));
        st = new StringTokenizer(br.readLine());
        int numberRotations = Integer.parseInt(st.nextToken()) % 4;

        if(numberRotations == 0){
            System.out.println("undefined");
            return;
        }

        int firstCharVal = getCharVal(firstChar);
        int secondCharVal = getCharVal(secondChar);

        int numClockWiseRotations = 0;
        int numCounterClockWiseRotations = 0;

        int tempFirstCharVal = firstCharVal;

        for(int i = 0; i<4; i++){
            if(tempFirstCharVal != secondCharVal){
                numClockWiseRotations++;
                tempFirstCharVal += 1;
                tempFirstCharVal %= 4;
            }else{
                break;
            }
        }

        tempFirstCharVal = firstCharVal;
        for(int i = 0; i<4; i++){
            if(tempFirstCharVal != secondCharVal){
                numCounterClockWiseRotations++;
                tempFirstCharVal -= 1;
                if(tempFirstCharVal < 0)
                    tempFirstCharVal = 3;
            }else{
                break;
            }
        }

        if(numClockWiseRotations == numCounterClockWiseRotations){
            System.out.println("undefined");
            return;
        }

        if(numberRotations == numClockWiseRotations){
            System.out.println("cw");
            return;
        }

        if(numCounterClockWiseRotations == numberRotations){
            System.out.println("ccw");
            return;
        }

        System.out.println("undefined");

    }

    private static int getCharVal(char inputChar) {
        if(inputChar == '^')
            return 0;
        if(inputChar == '>')
            return 1;
        if(inputChar == 'v')
            return 2;
        return 3;
    }
}

import java.util.*;
import java.io.*;

public class R426_A {
	FastScanner in;
	PrintWriter out;

	public void solve() {
		String s = in.next();
		String f = in.next();
		int a = -1;
		int b = -1;

		if (s.compareTo("^") == 0) {
			a = 4;
		}
		if (s.compareTo(">") == 0) {
			a = 5;
		}
		if (s.compareTo("v") == 0) {
			a = 6;
		}
		if (s.compareTo("<") == 0) {
			a = 7;
		}

		if (f.compareTo("^") == 0) {
			b = 4;
		}
		if (f.compareTo(">") == 0) {
			b = 5;
		}
		if (f.compareTo("v") == 0) {
			b = 6;
		}
		if (f.compareTo("<") == 0) {
			b = 7;
		}

		int n = in.nextInt();
		n %= 4;

		switch (n) {
		case 0: {
			out.println("undefined");
			return;
		}
		case 1: {
			if ((a - b == 1) || (a - b == -3)) {
				out.println("ccw");
			} else {
				out.println("cw");
			}
			return;
		}
		case 2: {
			out.println("undefined");
			return;
		}
		case 3: {
			if ((a - b == 1) || (a - b == -3)) {
				out.println("cw");
			} else {
				out.println("ccw");
			}
			return;
		}
		}
	}

	public void run() {
		in = new FastScanner();
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		solve();
		out.close();
	}

	class FastScanner {
		StringTokenizer st;
		BufferedReader br;

		FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args) {
		new R426_A().run();
	}
}

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;

public class Main{
	InputStream is;
	PrintWriter out;
	String INPUT = "./data/judge/201707/426A.txt";

	static Map<Character, Integer> map;
	{
		map = new HashMap<Character, Integer>();
		map.put('^', 0);
		map.put('>', 1);
		map.put('v', 2);
		map.put('<', 3);
	}
	void solve() {
		char fir = nc();
		char sec = nc();
		int n = ni();
		int start = map.get(fir);
		int end = map.get(sec);

		if ((start + n) % 4 == end && (start + n) % 4 == (start + 2) % 4 || start == end){
			out.println("undefined");
		}
		else if ((start + n) % 4 == end){
			out.println("cw");
		}
		else{
			out.println("ccw");
		}
	}

	void run() throws Exception {
		is = oj ? System.in : new FileInputStream(new File(INPUT));
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

	private void tr(Object... o) {
		if (!oj)
			System.out.println(Arrays.deepToString(o));
	}
}

import java.util.*;
import java.io.*;

public final class Main {

    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        char firstChar = Character.valueOf(st.nextToken().charAt(0));
        char secondChar = Character.valueOf(st.nextToken().charAt(0));

        st = new StringTokenizer(br.readLine());
        int numRotations = Integer.parseInt(st.nextToken());
        if(numRotations == 0){
            System.out.println("undefined");
            return;
        }

        int start = 0;

        switch (firstChar){
            case '^':
                start = 1;
                break;
            case '>':
                start = 2;
                break;
            case 'v':
                start = 3;
                break;
            case '<':
                start = 4;
                break;
        }

        int end = 0;

        switch (secondChar){
            case '^':
                end = 1;
                break;
            case '>':
                end = 2;
                break;
            case 'v':
                end = 3;
                break;
            case '<':
                end = 4;
                break;
        }

        //System.out.println(start + " " + end);
        int clockWiseRotations = 0;
        int cclockWiseRotations = 0;

        int startChar = start;
        int endChar = end;
        for(int i = 0; i<4; i++){
                if(startChar!=endChar){
                    clockWiseRotations++;
                }else{
                    break;
                }
                startChar += 1;
                if(startChar > 4)
                    startChar = 1;
        }

        //System.out.println(start + " " + end);
        startChar = start;
        for(int i = 0; i<4; i++){
            if(startChar!=endChar){
                cclockWiseRotations++;
            }else{
                break;
            }
            startChar -= 1;
            if(startChar == 0) {
                startChar = 4;
            }
        }

        numRotations %= 4;

        //System.out.println(clockWiseRotations + " "  + cclockWiseRotations);

        if(numRotations != clockWiseRotations && numRotations != cclockWiseRotations || numRotations == 2 || numRotations == 0){
            pw.println("undefined");
            pw.close();
            return;
        }

        if(numRotations == clockWiseRotations){
            pw.println("cw");
            pw.close();
            return;
        }else{
            pw.println("ccw");
            pw.close();
            return;
        }

    }
}

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;

public class Main {

	InputStream is;
	PrintWriter out;
	String INPUT = "";

	private static final long M = 1000000007L;

	void solve() {
		StringBuffer sb = new StringBuffer();
		String str = "v<^>";
		char s = nc();
		char e = nc();
		int N = ni() % 4;
		int d = (str.indexOf(s) - str.indexOf(e) + 4) % 4;
//		tr(N, d);
		out.println(d == N && d == 4 - N || d == 0 && N == 0 ? "undefined"
				: d == N ? "ccw" : d == 4 - N ? "cw" : "undefined");
	}

	private long gcd(long a, long b) {
		while (a != 0) {
			long tmp = b % a;
			b = a;
			a = tmp;
		}
		return b;
	}

	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;
	private boolean vis[];

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n) {
			if (!(isSpaceChar(b)))
				buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private String[] nas(int n) {
		String[] a = new String[n];
		for (int i = 0; i < n; i++)
			a[i] = ns();
		return a;
	}

	private Integer[] na2(int n) {
		Integer[] a = new Integer[n];
		for (int i = 0; i < n; i++)
			a[i] = Math.abs(ni());
		return a;
	}

	private int[][] na(int n, int m) {
		int[][] a = new int[n][];
		for (int i = 0; i < n; i++)
			a[i] = na(m);
		return a;
	}

	private Integer[][] na2(int n, int m) {
		Integer[][] a = new Integer[n][];
		for (int i = 0; i < n; i++)
			a[i] = na2(m);
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

    //StringTokenizer st=new StringTokenizer(br.readLine());
    //ArrayList<Integer> list = new ArrayList<Integer>();
    //int n=Integer.parseInt(st.nextToken());
    //Long n=Long.parseLong(st.nextToken());
    //long n=Long.parseLong(br.readLine());
    //int n=Integer.parseInt(br.readLine());
    //int n=scan.scanInt();
    /*int t=Integer.parseInt(br.readLine());
        for(;t!=0;t--){

        }*/

	public static void main (String[] args) throws java.lang.Exception
	{
	    Scan scan=new Scan();
		Print print=new Print();
		String inp1=scan.scanString();
		String inp2=scan.scanString();
		//inp2=scan.scanString();
	//	System.out.println(inp1+" "+inp2);
		int n=scan.scanInt();
		int start=(int)inp1.charAt(0);
		int end=(int)inp2.charAt(0);
		int p=0,e=0,i;
		if(start==118)p=1;

		if(start==60)p=2;

		if(start==94)p=3;

		if(start==62)p=4;

		if(end==118)e=1;

		if(end==60)e=2;

		if(end==94)e=3;

		if(end==62)e=4;

		int a,b;
		a=b=p;
		n%=4;
		for(i=1;i<=n;i++)
		{
		    a++;
		    if(a>4)
		    a=1;
		}

		for(i=1;i<=n;i++)
		{
		    b--;
		    if(b<=0)
		    b=4;
		}
		if(e==a && e==b)
		System.out.println("undefined");

		else
		{
		    if(e==a)
		    System.out.println("cw");

		    else
		    System.out.println("ccw");
		}

	}
}
class Scan
{
	private byte[] buf=new byte[1024];
	private int index;
	private InputStream in;
	private int total;
	public Scan()
	{
		in=System.in;
	}
	public int scan()throws IOException
	{
		if(total<0)
		throw new InputMismatchException();
		if(index>=total)
		{
			index=0;
			total=in.read(buf);
			if(total<=0)
			return -1;
		}
		return buf[index++];
	}
	public int scanInt()throws IOException
	{
		int integer=0;
		int n=scan();
		while(isWhiteSpace(n))
		n=scan();
		int neg=1;
		if(n=='-')
		{
			neg=-1;
			n=scan();
		}
		while(!isWhiteSpace(n))
		{
			if(n>='0'&&n<='9')
			{
				integer*=10;
				integer+=n-'0';
				n=scan();
			}
			else throw new InputMismatchException();
		}
		return neg*integer;
	}
	public double scanDouble()throws IOException
	{
		double doub=0;
		int n=scan();
		while(isWhiteSpace(n))
		n=scan();
		int neg=1;
		if(n=='-')
		{
			neg=-1;
			n=scan();
		}
		while(!isWhiteSpace(n)&&n!='.')
		{
			if(n>='0'&&n<='9')
			{
				doub*=10;
				doub+=n-'0';
				n=scan();
			}
			else throw new InputMismatchException();
		}
		if(n=='.')
		{
			n=scan();
			double temp=1;
			while(!isWhiteSpace(n))
			{
				if(n>='0'&&n<='9')
				{
					temp/=10;
					doub+=(n-'0')*temp;
					n=scan();
				}
				else throw new InputMismatchException();
			}
		}
		return doub*neg;
	}
	public String scanString()throws IOException
	{
		StringBuilder sb=new StringBuilder();
		int n=scan();
		while(isWhiteSpace(n))
		n=scan();
		while(!isWhiteSpace(n))
		{
			sb.append((char)n);
			n=scan();
		}
		return sb.toString();
	}
	private boolean isWhiteSpace(int n)
	{
		if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
		return true;
		return false;
	}
}

class Print
{
	private final OutputStream out;
	/*public Print(OutputStream outputStream)
	{
		writer=new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}*/
	public Print()
	{
		this.out=System.out;
	}
	public void print(String str)throws IOException
	{
		//buf=str.getBytes();
		for (int i = 0; i < str.length(); i++)
		{
			/*if (i != 0)
			out.write(' ');*/
			out.write(str.charAt(i));
		}
	}
	public void printLine(String str)throws IOException
	{
		print(str);
		out.write('\n');
	}
	public void close()throws IOException
	{
		out.close();
	}
}

import java.util.*;
import java.io.*;
import java.math.BigInteger;

/**
 *
 * @author rohan
 */

public class Main {

    static int mod = (int)1e9+7;

    static void solve() {

        char[] c = sc.nextLine().toCharArray();
        int n = sc.nextInt();
        int x=0,y=0;
        if(c[0]==94) x=0;
        else if(c[0]==62) x=1;
        else if(c[0]==118) x=2;
        else x=3;
        if(c[2]==94) y=0;
        else if(c[2]==62) y=1;
        else if(c[2]==118) y=2;
        else y=3;

        int dif = x-y;
        if((n&1)==0)    out.println("undefined");
        else
        {
            n=n%4;
            if(((x+n)%4)==y)
            {
                out.println("cw");

            }
            else out.println("ccw");
        }
        out.close();
    }

    static InputReader sc = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] args) {

        new Thread(null,new Runnable() {
            @Override
            public void run() {
                try{
                    solve();
                }
                catch(Exception e){
                    e.printStackTrace();
                }
            }
        },"1",1<<26).start();
    }

    static class Pair implements Comparable<Pair>{

        int x,y;

        Pair (int x,int y){
            this.x = x;
            this.y = y;
        }

        public int compareTo(Pair o)
        {
            return -Integer.compare(this.x,o.x);
        }

        @Override
        public String toString() {
            return x + " "+ y ;
        }

        public int hashCode() {
            return new Long(x).hashCode() * 31 + new Long(y).hashCode();
        }

    }

    static void debug(Object... o) {
            System.out.println(Arrays.deepToString(o));
    }

    static class InputReader {

        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
                this.stream = stream;
        }

        public int snext() {
                if (snumChars == -1)
                        throw new InputMismatchException();
                if (curChar >= snumChars) {
                        curChar = 0;
                        try {
                                snumChars = stream.read(buf);
                        } catch (IOException e) {
                                throw new InputMismatchException();
                        }
                        if (snumChars <= 0)
                                return -1;
                }
                return buf[curChar++];
        }

        public int nextInt() {
                int c = snext();
                while (isSpaceChar(c)) {
                        c = snext();
                }
                int sgn = 1;
                if (c == '-') {
                        sgn = -1;
                        c = snext();
                }
                int res = 0;
                do {
                        if (c < '0' || c > '9')
                                throw new InputMismatchException();
                        res *= 10;
                        res += c - '0';
                        c = snext();
                } while (!isSpaceChar(c));
                return res * sgn;
        }

        public long nextLong() {
                int c = snext();
                while (isSpaceChar(c)) {
                        c = snext();
                }
                int sgn = 1;
                if (c == '-') {
                        sgn = -1;
                        c = snext();
                }
                long res = 0;
                do {
                        if (c < '0' || c > '9')
                                throw new InputMismatchException();
                        res *= 10;
                        res += c - '0';
                        c = snext();
                } while (!isSpaceChar(c));
                return res * sgn;
        }

        public int[] nextIntArray(int n) {
                int a[] = new int[n];
                for (int i = 0; i < n; i++) {
                        a[i] = nextInt();
                }
                return a;
        }

        public long[] nextLongArray(int n) {
                long a[] = new long[n];
                for (int i = 0; i < n; i++) {
                        a[i] = nextLong();
                }
                return a;
        }

        public String readString() {
                int c = snext();
                while (isSpaceChar(c)) {
                        c = snext();
                }
                StringBuilder res = new StringBuilder();
                do {
                        res.appendCodePoint(c);
                        c = snext();
                } while (!isSpaceChar(c));
                return res.toString();
        }

        public String nextLine() {
                int c = snext();
                while (isSpaceChar(c))
                        c = snext();
                StringBuilder res = new StringBuilder();
                do {
                        res.appendCodePoint(c);
                        c = snext();
                } while (!isEndOfLine(c));
                return res.toString();
        }

        public boolean isSpaceChar(int c) {
                if (filter != null)
                        return filter.isSpaceChar(c);
                return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
                return c == '\n' || c == '\r' || c == -1;
        }

        public interface SpaceCharFilter {
                public boolean isSpaceChar(int ch);
        }

    }
}

import java.util.*;
import java.io.*;
import java.math.BigInteger;

/**
 *

 */

public class Main {

    static int mod = (int)1e9+7;

    static void solve() {

        char[] c = sc.nextLine().toCharArray();
        int n = sc.nextInt();
        int x=0,y=0;
        if(c[0]==94) x=0;
        else if(c[0]==62) x=1;
        else if(c[0]==118) x=2;
        else x=3;
        if(c[2]==94) y=0;
        else if(c[2]==62) y=1;
        else if(c[2]==118) y=2;
        else y=3;

        int dif = x-y;
        if((n&1)==0)    out.println("undefined");
        else
        {
            n=n%4;
            if(((x+n)%4)==y)
            {
                out.println("cw");

            }
            else out.println("ccw");
        }
        out.close();
    }

    static InputReader sc = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] args) {

        new Thread(null,new Runnable() {
            @Override
            public void run() {
                try{
                    solve();
                }
                catch(Exception e){
                    e.printStackTrace();
                }
            }
        },"1",1<<26).start();
    }

    static class Pair implements Comparable<Pair>{

        int x,y;

        Pair (int x,int y){
            this.x = x;
            this.y = y;
        }

        public int compareTo(Pair o)
        {
            return -Integer.compare(this.x,o.x);
        }

        @Override
        public String toString() {
            return x + " "+ y ;
        }

        public int hashCode() {
            return new Long(x).hashCode() * 31 + new Long(y).hashCode();
        }

    }

    static void debug(Object... o) {
            System.out.println(Arrays.deepToString(o));
    }

    static class InputReader {

        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
                this.stream = stream;
        }

        public int snext() {
                if (snumChars == -1)
                        throw new InputMismatchException();
                if (curChar >= snumChars) {
                        curChar = 0;
                        try {
                                snumChars = stream.read(buf);
                        } catch (IOException e) {
                                throw new InputMismatchException();
                        }
                        if (snumChars <= 0)
                                return -1;
                }
                return buf[curChar++];
        }

        public int nextInt() {
                int c = snext();
                while (isSpaceChar(c)) {
                        c = snext();
                }
                int sgn = 1;
                if (c == '-') {
                        sgn = -1;
                        c = snext();
                }
                int res = 0;
                do {
                        if (c < '0' || c > '9')
                                throw new InputMismatchException();
                        res *= 10;
                        res += c - '0';
                        c = snext();
                } while (!isSpaceChar(c));
                return res * sgn;
        }

        public long nextLong() {
                int c = snext();
                while (isSpaceChar(c)) {
                        c = snext();
                }
                int sgn = 1;
                if (c == '-') {
                        sgn = -1;
                        c = snext();
                }
                long res = 0;
                do {
                        if (c < '0' || c > '9')
                                throw new InputMismatchException();
                        res *= 10;
                        res += c - '0';
                        c = snext();
                } while (!isSpaceChar(c));
                return res * sgn;
        }

        public int[] nextIntArray(int n) {
                int a[] = new int[n];
                for (int i = 0; i < n; i++) {
                        a[i] = nextInt();
                }
                return a;
        }

        public long[] nextLongArray(int n) {
                long a[] = new long[n];
                for (int i = 0; i < n; i++) {
                        a[i] = nextLong();
                }
                return a;
        }

        public String readString() {
                int c = snext();
                while (isSpaceChar(c)) {
                        c = snext();
                }
                StringBuilder res = new StringBuilder();
                do {
                        res.appendCodePoint(c);
                        c = snext();
                } while (!isSpaceChar(c));
                return res.toString();
        }

        public String nextLine() {
                int c = snext();
                while (isSpaceChar(c))
                        c = snext();
                StringBuilder res = new StringBuilder();
                do {
                        res.appendCodePoint(c);
                        c = snext();
                } while (!isEndOfLine(c));
                return res.toString();
        }

        public boolean isSpaceChar(int c) {
                if (filter != null)
                        return filter.isSpaceChar(c);
                return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
                return c == '\n' || c == '\r' || c == -1;
        }

        public interface SpaceCharFilter {
                public boolean isSpaceChar(int ch);
        }

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

public class MainY {

	public static void main(String[] args) {

		List<String> input = getRawInput();

		int start = (int)(input.get(0).trim().split(" ")[0]).charAt(0);
		int ends = (int)(input.get(0).trim().split(" ")[1]).charAt(0);
		BigInteger big = new BigInteger(input.get(1).trim());

		int []completeAcii ={94, 62, 118, 60};

		BigInteger rest = big.mod(new BigInteger("4"));
			int pos = getPosition(start, completeAcii);

			int []aux = createAuxExcludePos(pos, completeAcii);

			int []aux2 = createAux(aux);

			if (rest.equals(new BigInteger("3")) && aux2[0]==ends){
				System.out.println("ccw");
			} else
			if (rest.equals(new BigInteger("1")) && aux2[0]==ends){
				System.out.println("cw");
			}else

			if (rest.equals(new BigInteger("3")) && aux2[2]==ends){
				System.out.println("cw");
			} else
			if (rest.equals(new BigInteger("1")) && aux2[2]==ends){
				System.out.println("ccw");
			}else{
			System.out.println("undefined");
			}

	}

	private static int[] createAux(int[] aux) {
		List<Integer>auxList  = new ArrayList<>();
		for (int i=0;i<aux.length;i++){
			if (aux[i]!=0){
				auxList.add(aux[i]);
			}
		}
		int[]a = new int [auxList.size()];
		for (int i=0;i<auxList.size();i++){
			a[i]=auxList.get(i);
		}
		return a;
	}

	private static int[] createAuxExcludePos(int pos, int[] completeAcii) {
		int result[] = new int[completeAcii.length];
		int k = 0;
		if (pos+1<completeAcii.length){
			for (int i=(pos+1); i<completeAcii.length;i++){
				result[k++] = completeAcii[i];
			}
			for (int i=0;i<pos;i++){
				result[k++] = completeAcii[i];
			}
		}else{
			for (int i=0;i<pos;i++){
				result[i] = completeAcii[i];
			}
		}

		return result;
	}

	private static int getPosition(int start, int[] completeAcii) {
		int i=0;
		for (i=0;i<completeAcii.length;i++){
			if (completeAcii[i]==start){
				return i;
			}
		}
		return 0;
	}

	public static List<String> getRawInput() {
		List<String> line = new ArrayList<>();

		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			line.add(br.readLine().trim());
			line.add(br.readLine().trim());
		} catch (IOException e) {
			e.printStackTrace();
		}
		return line;

	}
}

import java.io.*;
import java.util.*;

public class A {

	public static void main(String[] args) {
		FastScannerA sc = new FastScannerA(System.in);

		String start = sc.next();
		String end = sc.next();

		int dura = sc.nextInt();

		int left = dura % 4;

		if(left == 0 || start == end){
			System.out.println("undefined");
			System.exit(0);
		}

		char[] arr = new char[] {'v', '<', '^', '>'};

		int stIdx = -1;
		int endIdx = -1;

		for(int i = 0 ; i < 4 ; i++){
			if(arr[i] == start.charAt(0)){
				stIdx = i;
			}
			if(arr[i] == end.charAt(0)){
				endIdx = i;
			}
		}

		if(Math.abs(stIdx - endIdx) == left && 4 - Math.abs(stIdx - endIdx) == left){
			System.out.println("undefined");
		}
		else if(Math.abs(stIdx - endIdx) == left){
			if(stIdx < endIdx){
				System.out.println("cw");
			}
			else{
				System.out.println("ccw");
			}

		}
		else if(4 - Math.abs(stIdx - endIdx) == left){
			if(stIdx < endIdx){
				System.out.println("ccw");
			}
			else{
				System.out.println("cw");
			}
		}
		else{
			System.out.println("undefined");
		}

	}
}

class FastScannerA{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public FastScannerA(InputStream stream)
    {
        this.stream = stream;
    }

    public int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars)
        {
            curChar = 0;
            try
            {
                numChars = stream.read(buf);
            } catch (IOException e)
            {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt()
    {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-')
        {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do
        {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public String next()
    {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do
        {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public String nextLine()
    {
        int c = read();
        StringBuilder res = new StringBuilder();
        do
        {
            res.appendCodePoint(c);
            c = read();
        } while (!isLineEndChar(c));
        return res.toString();
    }

    public double nextDouble() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        double res = 0;
        while (!isSpaceChar(c) && c != '.') {
            if (c == 'e' || c == 'E')
                return res * Math.pow(10, nextInt());
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        if (c == '.') {
            c = read();
            double m = 1;
            while (!isSpaceChar(c)) {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                m /= 10;
                res += (c - '0') * m;
                c = read();
            }
        }
        return res * sgn;
    }

    public long nextLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public boolean isSpaceChar(int c)
    {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public boolean isLineEndChar(int c)
    {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == '\n' || c == '\r' || c == -1;
    }

    public interface SpaceCharFilter
    {
        public boolean isSpaceChar(int ch);
    }
}

import java.util.Scanner;

/**
 *
 * @author acm
 */
public class Spring {
    public static void main(String[] args) {
        Scanner i = new Scanner(System.in);
        String h = "v<^>";
        String a = "v>^<";

        char f = i.next().charAt(0);
        char e = i.next().charAt(0);

        int n = i.nextInt();

        int ih = h.indexOf(f);
        int ia = a.indexOf(f);

        char p = h.charAt((ih+n)%4);
        char u = a.charAt((ia+n)%4);

        if(p == u){
            System.out.println("undefined");
        }else{
            System.out.println(p==e?"cw":"ccw");
        }
    }

}

import java.util.*;
import java.io.*;
public final class spinner
{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s="^>v<";
        char ch[]=s.toCharArray();
        char c=sc.next().charAt(0);
        char d=sc.next().charAt(0);
        int b=sc.nextInt();
        int j=s.indexOf(c);
        char h[]=new char[ch.length];
        int k=j;
        for(int u=0;u<ch.length;u++)
        {
            h[u]=ch[k];
            k++;
            if(k==ch.length)
                k=0;
        }
       int w=b%4;
      if(b%2==0)
            System.out.println("undefined");
       else if(h[0+w]==d)
            System.out.println("cw");
      else
          System.out.println("ccw");
      }}

import java.io.*;
import java.util.*;
public final class Main{
	public static void main(String args[]){
		Scanner in=new Scanner(System.in);
		String a=in.next();
		String b=in.next();
		int x=in.nextInt();
		x=x%4;
		String s[]={"<","^",">","v"};
		int pos=0;
		for(int i=0;i<4;i++){
			if(s[i].equals(a))
				pos=i;
		}
		int n=pos+x;
		if(n>=4)
			n=n-4;
		int m=pos-x;
		if(m<0)
			m+=4;
		if(b.equals(s[n]) && !b.equals(s[m]))
			System.out.println("cw");
		else if(b.equals(s[m]) && !b.equals(s[n]))
			System.out.println("ccw");
		else
			System.out.println("undefined");

	}
}

import java.util.*;

public class Works {
    static int[] a = {118,60,94,62};
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int first = in.next().charAt(0);
        int last = in.next().charAt(0);
        int n = in.nextInt();
        int buff = n;
        String out = "";
        int posFirst = findPos(first);
        int posLast = findPos(last);
        boolean cw = false;

        if ( n % 2 == 0 || posFirst - posLast  == 2 || posFirst - posLast == -2) out = "undefined";
        else {
            if ((posFirst + n) % 4 == posLast) out = "cw";
            else out = "ccw";
        }

//        if (posFirst - posLast  == 2 || posFirst - posLast == -2 || posFirst - posLast == 0) out = "undefined";
//        else {
//            int i = posFirst + 1;
//            while (n-- > 0) {
//                if (i > 3) i = 0;
//                if (a[i] == a[posLast] && n == 0) {
//                    out = "cw";
//                    cw = true;
//                    break;
//                }
//                i++;
//            }
//            i = posFirst - 1;
//            n = buff;
//            while (n-- > 0 && !cw) {
//                if (i < 0) i = 3;
//                if (a[i] == a[posLast] && n == 0) {
//                    out = "ccw";
//                    break;
//                }
//                i--;
//            }
//        }
//        if (out.isEmpty()) out = "undefined";
        System.out.println(out);

    }

    private static int findPos(int k) {
        for (int i = 0; i < a.length; i++) {
            if (a[i] == k) return i;
        }
        return 0;
    }

}

import java.util.*;

public class Solution
{
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		String[] s = in.nextLine().split(" ");
		char start=s[0].charAt(0);
		char end=s[1].charAt(0);
		int n=in.nextInt();
		int[] cw=new int[400];
		int[] ccw=new int[400];
		cw['v']='<';
		cw['<']='^';
		cw['^']='>';
		cw['>']='v';
		ccw['v']='>';
		ccw['>']='^';
		ccw['^']='<';
		ccw['<']='v';
		int tempcw=start,tempccw=start;
		for(int i=0;i<n%4;i++) tempcw=cw[tempcw];
			for(int i=0;i<n%4;i++) tempccw=ccw[tempccw];
				if(end==tempcw && end==tempccw) System.out.println("undefined");
		else if(end==tempcw) System.out.println("cw");
		else if(end==tempccw) System.out.println("ccw");
		else
		{
			System.exit(1);
		}
	}
}

import java.util.*;

public class Solution
{
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		String input=in.nextLine();
		char start=(input.split(" "))[0].charAt(0);
		char end=(input.split(" "))[1].charAt(0);
		int n=in.nextInt();
		if(n%4==0 || n%4==2)
			System.out.println("undefined");
		else
		{
			switch(start)
			{
				case 'v' :
				if(n%4==1)
				{
					if(end=='<') System.out.println("cw");
					else if(end=='>') System.out.println("ccw");
				}
				else
				{
					if(end=='<') System.out.println("ccw");
					else if(end=='>') System.out.println("cw");
				}
				break;

				case '<' :
				if(n%4==1)
				{
					if(end==94) System.out.println("cw");
					else if(end=='v') System.out.println("ccw");
				}
				else
				{
					if(end=='^') System.out.println("ccw");
					else if(end=='v') System.out.println("cw");
				}
				break;

				case 94 :
				if(n%4==1)
				{
					if(end=='>') System.out.println("cw");
					else if(end=='<') System.out.println("ccw");
				}
				else
				{
					if(end=='>') System.out.println("ccw");
					else if(end=='<') System.out.println("cw");
				}
				break;

				case '>' :
				if(n%4==1)
				{
					if(end=='v') System.out.println("cw");
					else if(end=='^') System.out.println("ccw");
				}
				else
				{
					if(end=='v') System.out.println("ccw");
					else if(end=='^') System.out.println("cw");
				}
				break;
			}
		}
	}
}

//package hiougyf;
import java.util.*;

public class Main {
	public static void main (String[] args)
	 {
					Scanner sc =new Scanner(System.in);
					char f=sc.next().charAt(0);
					char l=sc.next().charAt(0);
					char a[]=new char[4];
					a[0]=(char)94;
					a[1]=(char)62;
					a[2]=(char)118;
					a[3]=(char)60;
					char b[]=new char[4];
					b[0]=(char)94;
					b[3]=(char)62;
					b[2]=(char)118;
					b[1]=(char)60;
					int n=sc.nextInt();
					int flag=0;
				if(n%2==0) {
					System.out.println("undefined");
					flag=9;
				}
		if(flag!=9) {
			for(int i=0;i<4;i++) {
						if(b[i]==f) {
							long j=((i+(n%4))%4);
							//if(n>4) j--;
							if(b[(int)j]==l) {
								System.out.println("ccw");
								flag=9;
								break;
							}
						}
					}
					if(flag!=9) {
						for(int i=0;i<4;i++) {
							if(a[i]==f) {
								long j=((i+(n%4))%4);
								//if(n>4) j--;
								if(a[(int)j]==l) {
									System.out.println("cw");
									flag=9;
									break;
								}
							}
						}
					}
				}
				 }

}

//package year;

import java.io.*;
import java.util.*;

public class prac {
	static PrintWriter out=new PrintWriter(System.out);
	public static void main(String[] args) {

		InputReader in=new InputReader(System.in);
	String str=in.readString();
	String str2=in.readString();
	//System.out.println(str+" "+str2);
	int n=in.nextInt();
	boolean cc=false;
	boolean cw=false;
	int s=0;
	int e=0;
	if((int)str.charAt(0)==118){
		s=0;
	}
	if((int)str.charAt(0)==60){
		s=1;
	}
	if((int)str.charAt(0)==94){
		s=2;
	}
	if((int)str.charAt(0)==62){
		s=3;
	}if((int)str2.charAt(0)==118){
		e=0;
	}
	if((int)str2.charAt(0)==60){
		e=1;
	}if((int)str2.charAt(0)==94){
		e=2;
	}if((int)str2.charAt(0)==62){
		e=3;
	}
	if((s+n)%4==e)
		cc=true;
	if((e+n)%4==s){
		cw=true;
	}
	//System.out.println(s+" "+e);
	if(cc&&cw){
		System.out.println("undefined");
	return;
	}
	else{
		if(cc){
			System.out.println("cw");
return;
		}
		if(cw)
		{		System.out.println("ccw");
	return;
		}
		System.out.println("undefined");

	}

	out.close();
	}

	//out.println(t);

	public static class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;

		public InputReader(InputStream st) {
			this.stream = st;
		}

		public int read() {
			/* internless */

			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public double nextDouble() {
			String doub = readString();
			return Double.parseDouble(doub);
		}

		public float nextFloat() {
			String doub = readString();
			return Float.parseFloat(doub);
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] sieve(int n) {
			int ar[] = new int[n + 1];
			ar[0] = 0;
			ar[1] = 1;
			for (int i = 2; i < ar.length; i++) {
				if (ar[i] == 0) {
					for (int k = i; k < ar.length; k = k + i) {
						if (ar[k] == 0) {
							ar[k] = i;
						}
					}
				}
			}
			return ar;
		}

		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}

		public Long[] nextLongArray(int n) {
			Long a[] = new Long[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextLong();
			}
			return a;
		}

		public ArrayList<ArrayList<Integer>> initlist(int n) {
			ArrayList<ArrayList<Integer>> list = new ArrayList<>();
			for (int i = 0; i <= n; i++) {
				list.add(new ArrayList<Integer>());
			}
			return list;
		}

		public int[] initdp(int n) {
			int ar[] = new int[n];
			for (int i = 0; i < n; i++) {
				ar[i] = -1;
			}
			return ar;
		}

		public int[][] initdp(int n, int m) {
			int ar[][] = new int[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++)
					ar[i][j] = -1;
			}
			return ar;
		}

		public char[] constring(String str) {
			char[] ar = new char[str.length()];
			for (int i = 0; i < str.length(); i++) {
				ar[i] = str.charAt(i);

			}
			return ar;
		}

		public static long gcd(long a, long b) {
			a = Math.abs(a);
			b = Math.abs(b);
			while (b != 0) {
				long temp = a % b;
				a = b;
				b = temp;
			}
			return a;
		}

		public static int longCompare(long a, long b) {
			if (a < b) {
				return -1;
			}
			if (a > b) {
				return 1;
			}
			return 0;
		}

		public String readString() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}
}

import java.util.*;
import java.io.*;
import java.lang.*;
public class A834 {
	private static long mod = 1000000007;

	public static void main(String[] args) {
		InputReader in=new InputReader(System.in);
		PrintWriter pw=new PrintWriter(System.out);

		String a=in.nextLine();
		char c1=a.charAt(0);
		char c2=a.charAt(2);
		long l=in.nextLong();
		int[] arr=new int[2];
		//pw.println(c1+" "+c2);
		if(c1=='^')
			arr[0]=0;
		else if(c1=='<')
			arr[0]=3;
		else if(c1=='>')
			arr[0]=1;
		else
			arr[0]=2;
		if(c2=='^')
			arr[1]=0;
		else if(c2=='<')
			arr[1]=3;
		else if(c2=='>')
			arr[1]=1;
		else
			arr[1]=2;
		l=l%4;
	//	pw.println(l);
		//pw.println(arr[1]+" "+arr[0]+" "+l);
	 if(Math.abs(arr[0]-arr[1])==2 ||Math.abs(arr[0]-arr[1])==0)
			pw.println("undefined");
	 else 	if(arr[1]>arr[0] &&Math.abs(arr[1]-arr[0])==(4-l))
				pw.println("ccw");
		else if(arr[1]>arr[0] && Math.abs(arr[1]-arr[0])==l)
				pw.print("cw");
		else if(arr[1]<arr[0] && Math.abs(arr[1]-arr[0])==(4-l))
				pw.println("cw");
		else if(arr[1]<arr[0] && Math.abs(arr[1]-arr[0])==l)
			pw.println("ccw");

		pw.flush();
		pw.close();
	}

	static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}
		public long[] nextLongArray(int n) {
			long a[] = new long[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextLong();
			}
			return a;
		}

		public String readString() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}

	public static int[] suffle(int[] a,Random gen)
	{
		int n = a.length;
		for(int i=0;i<n;i++)
		{
			int ind = gen.nextInt(n-i)+i;
			int temp = a[ind];
			a[ind] = a[i];
			a[i] = temp;
		}
		return a;
	}

	public static void swap(int a, int b){
		int temp = a;
		a = b;
		b = temp;
	}

	public static ArrayList<Integer> primeFactorization(int n)
	{
		ArrayList<Integer> a =new ArrayList<Integer>();
		for(int i=2;i*i<=n;i++)
		{
			while(n%i==0)
			{
				a.add(i);
				n/=i;
			}
		}
		if(n!=1)
			a.add(n);
		return a;
	}

	public static void sieve(boolean[] isPrime,int n)
	{
		for(int i=1;i<n;i++)
			isPrime[i] = true;

		isPrime[0] = false;
		isPrime[1] = false;

		for(int i=2;i*i<n;i++)
		{
			if(isPrime[i] == true)
			{
				for(int j=(2*i);j<n;j+=i)
					isPrime[j] = false;
			}
		}
	}

	public static int GCD(int a,int b)
	{
		if(b==0)
			return a;
		else
			return GCD(b,a%b);
	}

	public static long GCD(long a,long b)
	{
		if(b==0)
			return a;
		else
			return GCD(b,a%b);
	}

	public static long LCM(long a,long b)
	{
		return (a*b)/GCD(a,b);
	}

	public static int LCM(int a,int b)
	{
		return (a*b)/GCD(a,b);
	}

	public static int binaryExponentiation(int x,int n)
	{
	    int result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=result * x;
	        x=x*x;
	        n=n/2;
	    }
	    return result;
	}

	public static long binaryExponentiation(long x,long n)
	{
	    long result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=result * x;
	        x=x*x;
	        n=n/2;
	    }
	    return result;
	}

	public static int modularExponentiation(int x,int n,int M)
	{
	    int result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=(result * x)%M;
	        x=(x*x)%M;
	        n=n/2;
	    }
	    return result;
	}

	public static long modularExponentiation(long x,long n,long M)
	{
	    long result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=(result * x)%M;
	        x=(x*x)%M;
	        n=n/2;
	    }
	    return result;
	}

	public static int modInverse(int A,int M)
	{
	    return modularExponentiation(A,M-2,M);
	}

	public static long modInverse(long A,long M)
	{
	    return modularExponentiation(A,M-2,M);
	}

	public static boolean isPrime(int n)
	{

	    if (n <= 1)  return false;
	    if (n <= 3)  return true;

	    if (n%2 == 0 || n%3 == 0)
	    	return false;

	    for (int i=5; i*i<=n; i=i+6)
	    {
	        if (n%i == 0 || n%(i+2) == 0)
	           return false;
	    }

	    return true;
	}

	static class pair implements Comparable<pair>
	{
		Integer x, y;
		pair(int x,int y)
		{
			this.x=x;
			this.y=y;
		}

		public int compareTo(pair o) {
			int result = x.compareTo(o.x);
			if(result==0)
				result = y.compareTo(o.y);

			return result;
		}
	}
}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package javaapplication95;

import java.util.Scanner;

/**
 *
 * @author Hp
 */
public class JavaApplication95 {

    public static char clockwise(char c)
    {
        if(c == '^')
            return '>';
        else if(c == '>')
            return 'v';
        else if(c == 'v')
            return '<';
        else
            return '^';
    }

    public static char counterclockwise(char c)
    {
        if(c == '^')
            return '<';
        else if(c == '>')
            return '^';
        else if(c == 'v')
            return '>';
        else
            return 'v';
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        char start = scan.next().charAt(0);
        char end = scan.next().charAt(0);
        boolean cw = false, ccw = false;
        int N = scan.nextInt();
        char temp = start;
        N = N % 4;
        for(int i = 0; i < N; i++)
        {
            temp = clockwise(temp);
        }
        if(temp == end)
            cw = true;

            temp = start;
            for(int i = 0; i < N; i++)
            {
                temp = counterclockwise(temp);
            }
            if(temp == end)
            {
                ccw = true;
            }

        if(cw && ccw)
            System.out.println("undefined");
        else if(cw)
            System.out.println("cw");
        else if(ccw)
            System.out.println("ccw");
        else
            System.out.println("undefined");
    }

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Reader in = new Reader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Reader in, PrintWriter out) {
            char start = in.nextString().charAt(0);
            char end = in.nextString().charAt(0);
            int[][] cw = new int[4][4];

            for (int i = 0; i < 4; i++) {
                for (int j = 0; j < 4; j++) {
                    cw[i][j] = j - i;
                    if (cw[i][j] < 0) {
                        cw[i][j] += 4;
                    }
                }
            }

            int ans = in.nextInt() % 4;

            if (cw[getIndex(start)][getIndex(end)] == ans && ans != 2 && ans != 0) {
                out.println("cw");
            } else if (Math.abs(4 - cw[getIndex(start)][getIndex(end)]) == ans && ans != 2 && ans != 0) {
                out.println("ccw");
            } else {
                out.println("undefined");
            }
        }

        private int getIndex(char start) {
            if (start == 'v') {
                return 0;
            } else if (start == '<') {
                return 1;
            } else if (start == '^') {
                return 2;
            } else {
                return 3;
            }
        }

    }

    static class Reader {
        private InputStream mIs;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public Reader() {
            this(System.in);
        }

        public Reader(InputStream is) {
            mIs = is;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = mIs.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}

import java .util.*;
public class St
{
	public static void main(String[]args)
	{
     Scanner sc= new Scanner(System.in);
    String [] s1=(sc.nextLine()).split(" ");
	//String x1= s1[0];
	 int x1=(s1[0].equals("v"))?1:(s1[0].equals(">"))?2:(s1[0].equals("<"))?4:3;
	 String x2 =s1[1];
	 x2=(s1[1].equals("v"))?"1":(s1[1].equals(">"))?"2":(s1[1].equals("<"))?"4":"3";
	 int  s2 =sc.nextInt()%4;
	 if(s2==0&&x1==Integer.parseInt(x2))
	 {
		 System.out.println("undefined");
	 }
	 else
	 {
		 if((x1+s2)%4==Integer.parseInt(x2)||(x1+s2)%4+4==Integer.parseInt(x2))
    	 {
    	 if(x1-s2<=0)
    	 {
    		 if(x1-s2+4==Integer.parseInt(x2))
    		 {	 System.out.println("undefined");
    		 }
    		 else
    			 System.out.println("ccw");
    	 }
    	 else
    	 {
    		 if(x1-s2==Integer.parseInt(x2))
    		 {	 System.out.println("undefined");
    		 }
    		 else
    			 System.out.println("ccw");
    	 }
	}
	else
		{
	if(x1-s2<=0)
   	 {
   		 if(x1-s2+4==Integer.parseInt(x2))
   		 {	 System.out.println("cw");
   		 }
  	 }
		 else
    	 {
    		 if(x1-s2==Integer.parseInt(x2))
    		 {	 System.out.println("cw");
    		 }
    		 else
    		 {
    			 System.out.println("undefined");
    	       }
    	 }
	      }
	 }
	}
}

import java.util.Scanner;

public class R426A {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String c1 = scan.next(), c2 = scan.next(); scan.nextLine();
		int n = scan.nextInt();
		int i1, i2;
		if(c1.equals("^")) i1=1;
		else if(c1.equals(">")) i1=2;
		else if(c1.equals("v")) i1=3;
		else i1=4;

		if(c2.equals("^")) i2=1;
		else if(c2.equals(">")) i2=2;
		else if(c2.equals("v")) i2=3;
		else i2=4;

		int temp = i2-i1;
		if(temp==-3) temp=1;
		if(temp==3) temp=-1;

		if(Math.abs(temp)==2) {System.out.println("undefined"); return;}
		if(temp<0&&n%4==1) System.out.println("ccw");
		else if(temp<0&&n%4==3) System.out.println("cw");
		else if(temp>0&&n%4==1) System.out.println("cw");
		else if(temp>0&&n%4==3) System.out.println("ccw");
		else System.out.println("undefined");
	}
}

import java.util.*;
import java.io.*;

public class codeforces{
	static class InputReader {
		public BufferedReader reader;
			public StringTokenizer tokenizer;

			public InputReader() {
				reader = new BufferedReader(new InputStreamReader(System.in));
				tokenizer = null;
			}

			public String next() {
				while (tokenizer == null || !tokenizer.hasMoreTokens()) {
					try {
						tokenizer = new StringTokenizer(reader.readLine());
					} catch (IOException e) {
						throw new RuntimeException(e);
					}
				}
				return tokenizer.nextToken();
			}

			public int nextInt() {
				return Integer.parseInt(next());
			}

			public long nextLong() {
				return Long.parseLong(next());
			}

			public double nextDouble() {
				return Double.parseDouble(next());
			}

			public String nextLine() {
				String s = null;
				try {
					s = reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return s;
			}

			public String nextParagraph() {
				String line = null;
				String ans = "";
				try {
					while ((line = reader.readLine()) != null) {
						ans += line;
					}
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return ans;
			}
		}

	static void printArray(int ar[]){
		for(int x:ar)
			System.out.print(x+" ");
	}
	static boolean checkCondition(int a,int b){
		int max = Math.max(a,b);
		int c=a|b;
		if(c <= max)
			return true;
		else return false;
	}
	public static void main(String args[]){
		InputReader sc=new InputReader();
		PrintWriter pw=new PrintWriter(System.out);
		String start = sc.next();
		String end = sc.next();
		int n=sc.nextInt();
		int num = n%4;
		if(num ==2 || num ==0 ){
			pw.println("undefined");
			pw.close();
			return;
		}
		HashMap<Character,Integer> map = new HashMap<Character,Integer>();
		map.put('v',0);
		map.put('<',1);
		map.put('^',2);
		map.put('>',3);
		int val = map.get(start.charAt(0));
		int v1 = val-num;
		int v2 = val+num;
		if(v1<0)
			v1+=4;
		if(v2>=4)
			v2=v2%4;
		if(v1 == map.get(end.charAt(0)))
			pw.println("ccw");
		else pw.println("cw");
		pw.close();
	}
}

import java.util.*;

public class Darshjava
{
    public static void main(String args [])
    {
        Scanner enter = new Scanner (System.in) ;
        char s = enter.next().charAt(0) , e = enter.next().charAt(0) ;
        int n = enter.nextInt();
        if (n % 4 == 0 && s == e)System.out.println("undefined");
        else if(n % 4 == 2 && s == 118 && e == 94) System.out.println("undefined");
        else if (n % 4 == 2 && s == 94 && e == 118) System.out.println("undefined");
        else if (n % 4 == 2 && s == 60 && e == 62) System.out.println("undefined");
        else if (n % 4 == 2 && s == 62 && e == 60) System.out.println("undefined");
        else if (n % 4 == 1 && s == 94 && e == 60) System.out.println("ccw");
        else if (n % 4 == 1 && s == 94 && e == 62) System.out.println("cw");
        else if (n % 4 == 1 && s == 118 && e == 60) System.out.println("cw");
        else if (n % 4 == 1 && s == 118 && e == 62) System.out.println("ccw");
        else if (n % 4 == 1 && s == 60 && e == 118) System.out.println("ccw");
        else if (n % 4 == 1 && s == 60 && e == 94) System.out.println("cw");
        else if (n % 4 == 1 && s == 62 && e == 118) System.out.println("cw");
        else if (n % 4 == 1 && s == 62 && e == 94) System.out.println("ccw");
        else if (n % 4 == 3 && s == 94 && e == 60) System.out.println("cw");
        else if (n % 4 == 3 && s == 94 && e == 62) System.out.println("ccw");
        else if (n % 4 == 3 && s == 118 && e == 60) System.out.println("ccw");
        else if (n % 4 == 3 && s == 118 && e == 62) System.out.println("cw");
        else if (n % 4 == 3 && s == 60 && e == 118) System.out.println("cw");
        else if (n % 4 == 3 && s == 60 && e == 94) System.out.println("ccw");
        else if (n % 4 == 3 && s == 62 && e == 118) System.out.println("cw");
        else if (n % 4 == 3 && s == 62 && e == 94) System.out.println("ccw");
    }
}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {

	static HashMap<Character, Long> degrees = new HashMap<Character, Long>();

	public static char rotate(char start, long dur, boolean dir) {

		long degree = degrees.get(start);
		if (dir) {
			// ccw
			degree += 90 * dur;

		} else {
			degree -= 90 * dur;

		}

		degree = degree % 360;

		if (degree < 0) {
			degree = 360 + degree;
		}

		char ret = 'a';

		Iterator it = degrees.entrySet().iterator();
		while (it.hasNext()) {
			Map.Entry<Character, Long> pair = (Map.Entry<Character, Long>) it
					.next();
			if (pair.getValue() == degree) {
				ret = pair.getKey();
			}

		}

		return ret;

	}

	public static void main(String[] args) {

		degrees.put('>', new Long(0));
		degrees.put('<', new Long(180));
		degrees.put('^', new Long(90));
		degrees.put('v', new Long(270));

		Scanner in = new Scanner(System.in);
		String start = in.next();
		String end = in.next();
		long dur = in.nextLong();

		char ccw = rotate(start.toCharArray()[0], dur, true);
		char cw = rotate(start.toCharArray()[0], dur, false);

		if (cw == ccw) {
			System.out.println("undefined");
			return;
		}

		if (cw == end.toCharArray()[0]) {
			System.out.println("cw");
			return;
		}

		if (ccw == end.toCharArray()[0]) {
			System.out.println("ccw");
			return;
		}

		System.out.println("undefined");
		return;

	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class toy {
	public static PrintWriter out;

	   //-----------MyScanner class for faster input----------
	   public static class MyScanner {
	      BufferedReader br;
	      StringTokenizer st;

	      public MyScanner() {
	         br = new BufferedReader(new InputStreamReader(System.in));
	      }

	      String next() {
	          while (st == null || !st.hasMoreElements()) {
	              try {
	                  st = new StringTokenizer(br.readLine());
	              } catch (IOException e) {
	                  e.printStackTrace();
	              }
	          }
	          return st.nextToken();
	      }

	      int nextInt() {
	          return Integer.parseInt(next());
	      }

	      long nextLong() {
	          return Long.parseLong(next());
	      }

	      double nextDouble() {
	          return Double.parseDouble(next());
	      }

	      String nextLine(){
	          String str = "";
		  try {
		     str = br.readLine();
		  } catch (IOException e) {
		     e.printStackTrace();
		  }
		  return str;
	      }

	   }
	   public static void main(String args[]) throws Exception {
			class prob {

				public void solve() {
					MyScanner sc = new MyScanner();
					String in = "^>v<";
					String x = sc.next();
					//x += sc.next();
					x += sc.next();
					int sec = sc.nextInt();
					sec = (sec % 4);
					if ((sec % 2) == 0) {
						System.out.println("undefined");
						return;
					}
					int idx1 = in.indexOf(x.charAt(0));
					int idx2 = in.indexOf(x.charAt(1));
					int delta = (idx2 - idx1 + 4) % 4;

					System.out.println(delta == sec ? "cw": "ccw");
				}
			}
			prob s = new prob();
			s.solve();
		}
}

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String in = br.readLine();
		int n = Integer.parseInt(br.readLine());
		switch(in.charAt(0)) {
		case '<':
			switch(in.charAt(2)) {
			case '>':
			case '<': System.out.print("undefined"); break;
			case '^': if(n%4==1)
						System.out.print("cw");
					  else {
						  if(n%4==3)
							  System.out.print("ccw");
						  else
							  System.out.print("undefined");
					  }
			          break;
			case 'v': if(n%4==1)
						System.out.print("ccw");
					  else {
						  if(n%4==3)
							  System.out.print("cw");
						  else
							  System.out.print("undefined");
					  }
			          break;
			}
			break;

		case '^':
			switch(in.charAt(2)) {
			case 'v':
			case '^': System.out.print("undefined");
					  break;
			case '>': if(n%4==1)
						System.out.print("cw");
					  else {
						  if(n%4==3)
							  System.out.print("ccw");
						  else
							  System.out.print("undefined");
					  }
			          break;
			case '<': if(n%4==1)
						System.out.print("ccw");
					  else {
						  if(n%4==3)
							  System.out.print("cw");
						  else
							  System.out.print("undefined");
					  }
			          break;
			}
			break;

		case '>':
			switch(in.charAt(2)) {
			case '>':
			case '<': System.out.print("undefined"); break;
			case 'v': if(n%4==1)
						System.out.print("cw");
					  else {
						  if(n%4==3)
							  System.out.print("ccw");
						  else
							  System.out.print("undefined");
					  }
			          break;
			case '^': if(n%4==1)
						System.out.print("ccw");
					  else {
						  if(n%4==3)
							  System.out.print("cw");
						  else
							  System.out.print("undefined");
					  }
			          break;
			}
			break;

		case 'v':
			switch(in.charAt(2)) {
			case '^':
			case 'v': System.out.print("undefined"); break;
			case '<': if(n%4==1)
						System.out.print("cw");
					  else {
						  if(n%4==3)
							  System.out.print("ccw");
						  else
							  System.out.print("undefined");
					  }
			          break;
			case '>': if(n%4==1)
						System.out.print("ccw");
					  else {
						  if(n%4==3)
							  System.out.print("cw");
						  else
							  System.out.print("undefined");
					  }
			          break;
			}
			break;
		}
	}
}

import java.util.*;
import java.io.*;
public class useless {
	public static void main(String[] args) throws Exception {
		// BufferedReader in = new BufferedReader(new FileReader("test.in"));
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintStream out = System.out;

		String line = in.readLine();
		int s = 0, f = 0;
		if (line.charAt(0) == 'v') s = 0;
		else if (line.charAt(0) == '<') s = 1;
		else if (line.charAt(0) == '^') s = 2;
		else s = 3;
		if (line.charAt(2) == 'v') f = 0;
		else if (line.charAt(2) == '<') f = 1;
		else if (line.charAt(2) == '^') f = 2;
		else f = 3;

		int n = Integer.parseInt(in.readLine());
		// cw works
		if ((n % 4 + s) % 4 == f) {
			if ((n % 4 + f) % 4 == s) {
				out.println("undefined");
			} else {
				out.println("cw");
			}
		} else { // cw doesn't work
			out.println("ccw");
		}
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Don Li
 */
public class TheUselessToy {

    String P = "v<^>";

    void solve() {
        char a = in.nextToken().charAt(0), b = in.nextToken().charAt(0);
        int n = in.nextInt();

        n &= 3;

        if (n == 0 || n == 2) {
            out.println("undefined");
            return;
        }

        int p = P.indexOf(a), q = P.indexOf(b);
        if (((p + n) & 3) == q) out.println("cw");
        else out.println("ccw");
    }

    public static void main(String[] args) {
        in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        new TheUselessToy().solve();
        out.close();
    }

    static FastScanner in;
    static PrintWriter out;

    static class FastScanner {
        BufferedReader in;
        StringTokenizer st;

        public FastScanner(BufferedReader in) {
            this.in = in;
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Don Li
 */
public class TheUselessToy {

    String P = "v<^>";

    void solve() {
        char a = in.nextToken().charAt(0), b = in.nextToken().charAt(0);
        int n = in.nextInt();

        n %= 4;

        if (n == 0 || n == 2) {
            out.println("undefined");
            return;
        }

        int p = P.indexOf(a), q = P.indexOf(b);
        if ((p + n) % 4 == q) out.println("cw");
        else out.println("ccw");
    }

    public static void main(String[] args) {
        in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        new TheUselessToy().solve();
        out.close();
    }

    static FastScanner in;
    static PrintWriter out;

    static class FastScanner {
        BufferedReader in;
        StringTokenizer st;

        public FastScanner(BufferedReader in) {
            this.in = in;
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}

import java.io.*;
import java.util.*;

public class Main {

	void howUdoin() {

		String st=inps();

		char a='^',d='<',b='>',c='v';
		char s=st.charAt(0);
		st=inps();
		char e=st.charAt(0);
		int n=inpi();
		int f=0;
		double x,y;
		String ans="";
		if((s==a || s==c) && (e==a || e==c)){

			System.out.println("undefined");
			return;

		}
		else if((s==b || s==d) && (e==b || e==d)){
			System.out.println("undefined");
			return;
		}
		x=(double)(n+3)/4;
		y=(double)(n+1)/4;
		if(x-Math.floor(x)==0){
			f=1;
		}
		else if(y-Math.floor(y)==0){
			f=2;
		}
		else {
			System.out.println("undefined");
			return;
		}
		if(s==a){
			if((f==1 && e==b) || (f==2 && e==d)){
				ans="cw";
			}
			else{
				ans="ccw";
			}
		}
		else if(s==b){
			if((f==1 && e==c) || (f==2 && e==a)){
				ans="cw";
			}
			else{
				ans="ccw";
			}
		}
		else if(s==c){
			if((f==1 && e==d) || (f==2 && e==b)){
				ans="cw";
			}
			else{
				ans="ccw";
			}
		}
		else{
			if((f==1 && e==a) || (f==2 && e==c)){
				ans="cw";
			}
			else{
				ans="ccw";
			}
		}
		System.out.println(ans);

	}

	InputStream obj;
	PrintWriter out;
	String check = "";

	public static void main(String[] args) throws IOException {
		new Main().main1();
	}

	void main1() throws IOException {
		out = new PrintWriter(System.out);
		obj = check.isEmpty() ? System.in : new ByteArrayInputStream(check.getBytes());
		howUdoin();
		out.flush();
		out.close();
	}
	byte inbuffer[] = new byte[1024];
	int lenbuffer = 0, ptrbuffer = 0;

	int readByte() {
		if (lenbuffer == -1) {
			throw new InputMismatchException();
		}
		if (ptrbuffer >= lenbuffer) {
			ptrbuffer = 0;
			try {
				lenbuffer = obj.read(inbuffer);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
		}
		if (lenbuffer <= 0) {
			return -1;
		}
		return inbuffer[ptrbuffer++];
	}

	boolean isSpaceChar(int c) {
		return (!(c >= 33 && c <= 126));
	}

	int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b));
		return b;
	}

	String inps() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	String inpsl() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (b!='\n') {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	int inpi() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	long inpl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	float inpf() {
		return Float.parseFloat(inps());
	}

	double inpd() {
		return Double.parseDouble(inps());
	}

	char inpc() {
		return (char) skip();
	}

	int[] inpia(int n) {
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = inpi();
		}
		return a;
	}

	long[] inpla(int n) {
		long a[] = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = inpl();
		}
		return a;
	}

	String[] inpsa(int n) {
		String a[] = new String[n];
		for (int i = 0; i < n; i++) {
			a[i] = inps();
		}
		return a;
	}

}

import java.io.*;
import java.util.*;

public class A {
    public static void solution(BufferedReader reader, PrintWriter writer)
            throws IOException {
        In in = new In(reader);
        Out out = new Out(writer);
        String s = "v<^>";
        char c1 = in.next().charAt(0), c2 = in.next().charAt(0);
        int p1 = s.indexOf(c1), p2 = s.indexOf(c2);
        int n = in.nextInt() % 4;
        if ((p1 + n) % 4 == p2 && n % 2 != 0)
            out.println("cw");
        else if ((p1 + 4 - n) % 4 == p2 && n % 2 != 0)
            out.println("ccw");
        else
            out.println("undefined");
    }

    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in));
        PrintWriter writer = new PrintWriter(
                new BufferedWriter(new OutputStreamWriter(System.out)));
        solution(reader, writer);
        writer.close();
    }

    protected static class In {
        private BufferedReader reader;
        private StringTokenizer tokenizer = new StringTokenizer("");

        public In(BufferedReader reader) {
            this.reader = reader;
        }

        public String next() throws IOException {
            while (!tokenizer.hasMoreTokens())
                tokenizer = new StringTokenizer(reader.readLine());
            return tokenizer.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public int[] nextIntArray(int n) throws IOException {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public int[] nextIntArray1(int n) throws IOException {
            int[] a = new int[n + 1];
            for (int i = 1; i <= n; i++)
                a[i] = nextInt();
            return a;
        }

        public int[] nextIntArraySorted(int n) throws IOException {
            int[] a = nextIntArray(n);
            Random r = new Random();
            for (int i = 0; i < n; i++) {
                int j = i + r.nextInt(n - i);
                int t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
            Arrays.sort(a);
            return a;
        }

        public long[] nextLongArray(int n) throws IOException {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

        public long[] nextLongArray1(int n) throws IOException {
            long[] a = new long[n + 1];
            for (int i = 1; i <= n; i++)
                a[i] = nextLong();
            return a;
        }

        public long[] nextLongArraySorted(int n) throws IOException {
            long[] a = nextLongArray(n);
            Random r = new Random();
            for (int i = 0; i < n; i++) {
                int j = i + r.nextInt(n - i);
                long t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
            Arrays.sort(a);
            return a;
        }
    }

    protected static class Out {
        private PrintWriter writer;
        private static boolean local = System
                .getProperty("ONLINE_JUDGE") == null;

        public Out(PrintWriter writer) {
            this.writer = writer;
        }

        public void print(char c) {
            writer.print(c);
        }

        public void print(int a) {
            writer.print(a);
        }

        public void printb(int a) {
            writer.print(a);
            writer.print(' ');
        }

        public void println(Object a) {
            writer.println(a);
        }

        public void println(Object[] os) {
            for (int i = 0; i < os.length; i++) {
                writer.print(os[i]);
                writer.print(' ');
            }
            writer.println();
        }

        public void println(int[] a) {
            for (int i = 0; i < a.length; i++) {
                writer.print(a[i]);
                writer.print(' ');
            }
            writer.println();
        }

        public void println(long[] a) {
            for (int i = 0; i < a.length; i++) {
                writer.print(a[i]);
                writer.print(' ');
            }
            writer.println();
        }

        public void flush() {
            writer.flush();
        }

        public static void db(Object... objects) {
            if (local)
                System.out.println(Arrays.deepToString(objects));
        }
    }
}

import java.util.Scanner;
public class P834A
{
	public static void main(String[] args)
	{
	 Scanner scan=new Scanner(System.in);
	 char i,f;
	 int n;
	 i=scan.next().charAt(0);
	 f=scan.next().charAt(0);
	 n=scan.nextInt();
	 n%=4;
	 if(n==0||n==2)
		System.out.println("undefined");
	 else if(n==1)
		{
		 switch(i)
			{
			 case 'v': if(f=='<')
					System.out.println("cw");
				   else
					System.out.println("ccw");
				   break;
			 case '<': if(f=='^')
					System.out.println("cw");
				   else
					System.out.println("ccw");
				   break;
			 case '^': if(f=='>')
					System.out.println("cw");
				   else
					System.out.println("ccw");
				   break;
			 case '>': if(f=='v')
					System.out.println("cw");
				   else
					System.out.println("ccw");
				   break;
			}
		}
	 else
		{
		 switch(i)
			{
			 case 'v': if(f=='>')
					System.out.println("cw");
				   else
					System.out.println("ccw");
				   break;
			 case '<': if(f=='v')
					System.out.println("cw");
				   else
					System.out.println("ccw");
				   break;
			 case '^': if(f=='<')
					System.out.println("cw");
				   else
					System.out.println("ccw");
				   break;
			 case '>': if(f=='^')
					System.out.println("cw");
				   else
					System.out.println("ccw");
				   break;
			}
		}
	}
}

import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		//DisjointSet set = new DisjointSet(26);

		InputReader sc1 = new InputReader(System.in);
		PrintWriter sc2 = new PrintWriter(System.out);
		char start = sc1.readString().charAt(0);
		char end = sc1.readString().charAt(0);
		int time = sc1.nextInt();
		time = time%4;
		int s=0,e=0;
		char c[] = {'v', '<', '^', '>'};
		for(int i=0;i<4;i++) {
			if(start==c[i]) {
				s = i;
				break;
			}
		}
		for(int i=0;i<4;i++) {
			if(end==c[i]) {
				e = i;
				break;
			}
		}
		boolean cw = false, ccw = false;
		if((s+time)%4==e) {
			cw = true;
		}

		s = (s - time)%4;
		if(s<0) {
			s = 4 + s;
		}
		if(s==e) {
			ccw = true;
		}
		if(cw==true && ccw==true) {
			System.out.println("undefined");
		}
		else if(cw==true) {
			sc2.println("cw");
		}
		else {
			sc2.println("ccw");
		}
		sc2.close();
	}
	/*
	 * 	DIVISORS
	 * */
	public static void divsors(int n) {
		for(int i=1;i<=Math.sqrt(n)+1;i++) {
			if(n%i==0) {
				if(n/i==i) {
					System.out.print(i+" ");
				}
				else {
					System.out.print	(i+" "+n/i);
				}
			}
		}
	}

	/*
	 * 	GCD
	 * */

	public static int GCD(int x, int y) {
		if(x==0) {
			return y;
		}
		return GCD(y%x, x);
	}

	/*
	 * 	GCD EXTENDED
	 * */

	public static int gcdExtended(int a, int b, int x, int y) {
		if(a==0) {
			x = 0;
			y = 1;
			return b;
		}

		int x1 = 1, y1 = 1;
		int gcd = gcdExtended(b%a, a, x1, y1);
		x = y1 - (b/a)*x1;
		y = x1;

		return gcd;
	}

	static class DisjointSet{
		static StringBuilder str = new StringBuilder();
		static int count = 0;
		int rank[];
		int parent[];
		int n;
		DisjointSet(int n){
			this.n = n;
			rank = new int[n];
			Arrays.fill(rank, 0);
			parent = new int[n];
			makeSet();

		}
		void makeSet() {
			for(int i=0;i<n;i++) {
				parent[i] = i;
			}
		}

		int find(int x) {
			if(parent[x]!=x) {
				parent[x] = find(parent[x]);
			}
			return parent[x];
		}

		void union(int x, int y) {
			int xRoot = find(x);
			int yRoot = find(y);

			if(xRoot==yRoot) {
				return;
			}

			if(rank[xRoot]>rank[yRoot]) {
				parent[yRoot] = xRoot;
				Append(x,y);
				count++;
			}
			else if(rank[xRoot]<rank[yRoot]) {
				parent[xRoot] = yRoot;
				Append(x,y);
				count++;
			}
			else {
				parent[yRoot] = xRoot;
				rank[xRoot] = rank[xRoot] + 1;
				count++;
				Append(x,y);
			}
		}

		void Append(int x, int y) {
			str.append((char)(x+97)+" "+(char)(y+97)+"\n");
		}
	}
	static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public String readString() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}
}

import java.util.*;
import java.lang.*;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.io.*;
public class Solution {
	static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try{
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
	public int[] readIntArray(int n) {
			int[] arr = new int[n];
			for(int i=0; i<n; ++i)
				arr[i]=nextInt();
			return arr;
		}

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
	static String solve(char a, char b, int t) {
    	return "";
	}
	public static void main(String args[]) throws IOException {
        FastReader sc = new FastReader();
        long start = System.currentTimeMillis();
        	String s = sc.nextLine();

        	int n = sc.nextInt();
        	int[] pos = new int[256];
    		pos[118]=0;
    		pos[60]=1;
    		pos[94]=2;
    		pos[62]=3;
    		if(n%2==0)
    			System.out.println("undefined");
    		else if((pos[s.charAt(2)]-pos[s.charAt(0)]+4)%4==n%4)
    			System.out.println("cw");
    		else
    			System.out.println("ccw");

        	//System.out.println(solve(a,b,t));

        	long end = System.currentTimeMillis();
        	NumberFormat formatter = new DecimalFormat("#0.00000");
        	//System.out.print("Execution time is " + formatter.format((end - start) / 1000d) + " seconds");
        }
}

import java.util.*;
public class MyClass {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        char r=scan.next().charAt(0),l=scan.next().charAt(0);
        int n=scan.nextInt(),x=0,y=0;
        char a [] = {'v','<','^','>'},b [] = {'v','>','^','<'};
        for (int i=0;i<4;i++){if(a[i]==r)x=i;if(b[i]==r)y=i;}
        if(n%2==0) System.out.print("undefined");
        else if(a[(x+n%4)%4]==l)System.out.print("cw");
        else if (b[(y+n%4)%4]==l)System.out.print("ccw");
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author captainTurtle
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String a = in.next();
            String b = in.next();
            int n = in.nextInt();
            String c = Ascii(a, b, n);
            System.out.println(c);
            System.out.flush();
            in.close();

        }

        public static String Ascii(String x, String y, int time) {
            int a = x.charAt(0);
            int b = y.charAt(0);
            int sonuc = a - b;
            String cikti = "";
            if (a == 62) {
                if (time % 4 == 1) {
                    if (sonuc == (-56)) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }

                } else if (time % 4 == 2 || time % 4 == 0) {
                    cikti = "undefined";
                } else if (time % 4 == 3) {
                    if (sonuc == (-32)) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                }

            }
            if (a == 118) {

                if (time % 4 == 1) {
                    if (sonuc == 58) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }

                } else if (time % 4 == 2 || time % 4 == 0) {
                    cikti = "undefined";
                } else if (time % 4 == 3) {
                    if (sonuc == 56) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                }

            }
            if (a == 60) {
                if (time % 4 == 1) {
                    if (sonuc == (-34)) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                } else if (time % 4 == 2 || time % 4 == 0) {

                    cikti = "undefined";

                } else if (time % 4 == 3) {
                    if (sonuc == (-58)) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                }

            }
            if (a == 94) {
                if (time % 4 == 1) {
                    if (sonuc == 32) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }

                } else if (time % 4 == 2 || time % 4 == 0) {

                    cikti = "undefined";

                } else if (time % 4 == 3) {
                    if (sonuc == 34) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                }

            }

            return cikti;
        }

    }
}

import java.util.*;

public class TestClass {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.nextLine();
		char[] arr=new char[]{'^','>','v','<'};
		char d1=s.charAt(0);
		char d2=s.charAt(2);
		int rotation=sc.nextInt()%4;
		int index=0;
		for(int i=1;i<=3;++i){
			if(arr[i]==d1) index=i;
		}
		if(rotation==0 || rotation==2) System.out.println("undefined");
		else if(rotation==1){
			if(arr[(rotation+index)%4]==d2) System.out.println("cw");
			else System.out.println("ccw");
		}
		else{
			if(arr[(rotation+index)%4]==d2) System.out.println("cw");
			else System.out.println("ccw");

		}

	}

	}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import java.io.OutputStreamWriter;
import java.util.ArrayList;

public class tenth {

    public static void main(String args[]) throws Exception {
	String sp=br.readLine().trim();
	String ss[]=sp.split(" ");
	int t=input()%4,j=0,k=0;

	if(sp.charAt(0)=='^')
	    j=0;
	if(sp.charAt(0)=='>')
	    j=1;
	if(sp.charAt(0)=='v')
	    j=2;
	if(sp.charAt(0)=='<')
	    j=3;
	if(sp.charAt(2)=='^')
	    k=0;
	if(sp.charAt(2)=='>')
	    k=1;
	if(sp.charAt(2)=='v')
	    k=2;
	if(sp.charAt(2)=='<')
	    k=3;

		if(t==0||t==2){
	        System.out.print("undefined");

		}

		else if((j+t)%4==k){

	        System.out.print("cw");
	    }
	    else{
	      System.out.print("ccw");
	    }

	}

 static BufferedReader br = new BufferedReader(new InputStreamReader(
            System.in));
    private static String s[];

    public static void input(int a[], int p) throws IOException {
        s = br.readLine().split(" ");
        int i;
        for (i = 0; i < p; i++) {
            a[i] = Integer.parseInt(s[i]);
        }

    }

    public static void input(long a[], int p) throws IOException {
        s = br.readLine().split(" ");
        int i;
        for (i = 0; i < p; i++) {
            a[i] = Long.parseLong(s[i]);
        }
    }

    public static void input(double a[], int p) throws IOException {
        s = br.readLine().split(" ");
        int i;
        for (i = 0; i < p; i++) {
            a[i] = Double.parseDouble(s[i]);
        }
    }

    public static int input() throws IOException {
        int a;
        a = Integer.parseInt(br.readLine());
        return a;
    }

}

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String start = sc.next();
        String end = sc.next();
        int sec = sc.nextInt();
        String cw = new String("v<^>v<^>v<^>v<^>");
        String ccw = new String("v>^<v>^<v<^>v<^>");
        if (sec % 2 != 0) {
            if (cw.charAt(sec % 4 + cw.indexOf(start)) == end.charAt(0)) {
                System.out.print("cw");
            } else if (ccw.charAt(sec % 4 + ccw.indexOf(start)) == end.charAt(0)) {
                System.out.print("ccw");
            } else {
                System.out.print("undefined");
            }
        } else {
            System.out.print("undefined");
        }
    }
}

import java.io.*;
import java.lang.*;
import java.util.*;
public class a
{
public static void main(String[] args)
{
  Scanner kbd = new Scanner(System.in);
 String s = kbd.nextLine();
int n = kbd.nextInt();
 //v (ASCII code 118, lowercase v), < (ASCII code 60), ^ (ASCII code 94) or > (ASCII code 62)
 int a[]={118,60,94,62};
 //System.out.println(s.length());
 int first = (int) s.charAt(0);
  int last=(int) s.charAt(s.length()-1);

 int first_index=0;
 for(int i=0;i<4;i++)
 {
   if(first==a[i])
   first_index=i;
 }
 //System.out.println(first_index);//2

 int last_index=0;
 for(int i=0;i<4;i++)
 {
   if(last==a[i])
   last_index=i;
 }
// System.out.println(last_index);//3
 int ex = n%4;//1
 int f=first_index;
 for(int i=0;i<ex;i++)
 {
   if(f==3)
   f=0;
   else
   f+=1;
 }

 int f1=first_index;
 for(int i=0;i<ex;i++)
 {
   if(f1==0)
   f1=3;
   else
   f1-=1;
 }

 if(a[f]==last&&a[f1]!=last)
 System.out.println("cw");
 else if(a[f1]==last&&a[f]!=last)
 System.out.println("ccw");
 else
 System.out.println("undefined");

}

}

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char a = sc.next().charAt(0);
        char b = sc.next().charAt(0);
        int n = sc.nextInt();

        boolean first = (getIndex(a) + n % 4) % 4 == getIndex(b);
        boolean second = (getIndex(a) + 4 - n % 4) % 4 == getIndex(b);
        if (first && !second) {
            System.out.println("cw");
        } else if (!first && second) {
            System.out.println("ccw");
        } else {
            System.out.println("undefined");
        }
    }

    private static int getIndex(char c) {
        switch (c) {
            case 'v':
                return 0;
            case '<':
                return 1;
            case '^':
                return 2;
            case '>':
                return 3;
            default:
                return 0;
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class UselessToys {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] p = in.readLine().split(" ");
		int n = Integer.parseInt(in.readLine());
		char a = p[0].charAt(0);
		char b = p[1].charAt(0);
		int aa = 0;
		int bb = 0;
		if(a=='^') {
			aa = 1;
		} else if(a == '>') {
			aa = 2;
		} else if(a == 'v') {
			aa = 3;
		} else {
			aa = 4;
		}
		if(b=='^') {
			bb = 1;
		} else if(b == '>') {
			bb = 2;
		} else if(b == 'v') {
			bb = 3;
		} else {
			bb = 4;
		}
		n = n % 4;
		int x = Math.abs(aa-bb);
		if(x % 2 == 0) {
			System.out.println("undefined");
		} else {
			if(bb > aa) {
				if(bb -aa == n) {
					System.out.println("cw");
				} else {
					System.out.println("ccw");
				}
			} else {
				if(aa - bb == n) {
					System.out.println("ccw");
				} else {
					System.out.println("cw");
				}
			}
		}

	}
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class A {
	public static void main(String[] args) throws IOException {
		File inputFile = new File("entrada");
		if (inputFile.exists())
			System.setIn(new FileInputStream(inputFile));
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder out = new StringBuilder();
		String line;
		char[] spin = new char[256];
		spin['^'] = 0; spin['>'] = 1; spin['v'] = 2; spin['<'] = 3;
		spin[0] = '^'; spin[1] = '>'; spin[2] = 'v'; spin[3] = '<';
		while ((line = in.readLine()) != null) {
			String[] w = line.trim().split(" ");
			int n = Integer.parseInt(in.readLine().trim());
			if(n == 0) out.append("undefined\n");
			else{
				int a = spin[w[0].charAt(0)], b = spin[w[1].charAt(0)];
				int dif = n % 4;
				boolean cw = true, ccw = true;
				cw &= spin[b] == spin[(a + dif) % 4];
				ccw &= spin[b] == spin[(4 + (a - dif) % 4) % 4];
				out.append((cw && ccw) || (!cw && !ccw) ? "undefined" : cw ? "cw" : "ccw" ).append('\n');
			}
		}
		System.out.print(out);
	}

	public static Integer[] readInts(String line) {
		StringTokenizer st = new StringTokenizer(line.trim());
		Integer a[] = new Integer[st.countTokens()], index = 0;
		while (st.hasMoreTokens())
			a[index++] = Integer.parseInt(st.nextToken());
		return a;
	}

	public static Long[] readLongs(String line) {
		StringTokenizer st = new StringTokenizer(line.trim());
		Long a[] = new Long[st.countTokens()];
		int index = 0;
		while (st.hasMoreTokens())
			a[index++] = Long.parseLong(st.nextToken());
		return a;
	}

	public static Double[] readDoubles(String line) {
		StringTokenizer st = new StringTokenizer(line.trim());
		Double a[] = new Double[st.countTokens()];
		int index = 0;
		while (st.hasMoreTokens())
			a[index++] = Double.parseDouble(st.nextToken());
		return a;
	}
}

import java.util.Scanner;

public class Spinner {
	private static Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		Spinner s = new Spinner();
		String answer = new String();
		SpinPosition initialPosition = s.new SpinPosition(in.next().charAt(0));
		SpinPosition finalPosition = s.new SpinPosition(in.next().charAt(0));
		long time = in.nextLong();
		time %= 4;
		int clockWise = (finalPosition.positionOrder > initialPosition.positionOrder) ? finalPosition.positionOrder - initialPosition.positionOrder
																					  :  4 - Math.abs(finalPosition.positionOrder - initialPosition.positionOrder);
		int counterCW = (finalPosition.positionOrder > initialPosition.positionOrder) ?  4 - Math.abs(finalPosition.positionOrder - initialPosition.positionOrder)
				  : Math.abs(finalPosition.positionOrder - initialPosition.positionOrder);
		if(time == 0 || clockWise == counterCW)
		{
			answer = "undefined";
		}
		else
		{
			if(time - clockWise == 0)
			{
				answer = "cw";
			}
			else if(time - counterCW == 0)
			{
				answer = "ccw";
			}
			else
			{
				answer = "undefined";
			}
		}
		System.out.println(answer);
	}

	public class SpinPosition
	{
		int positionOrder;
		char position;
		public SpinPosition(char x)
		{
			position = x;
			if(position == 'v')
			{
				positionOrder = 1;
			}else if(position == '<') {
				positionOrder = 2;
			}else if (position == '^') {
				positionOrder = 3;
			}else {
				positionOrder = 4;
			}
		}
	}

}

import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		while (sc.hasNext()) {
			String s1=sc.next();
			String s2=sc.next();
			long n=sc.nextLong();
			HashMap<Character,Integer>map=new HashMap<Character,Integer>();
			map.put('v', 0);
			map.put('<', 1);
			map.put('^', 2);
			map.put('>', 3);
			n=n%4;
			char a=s1.charAt(0);
			char b=s2.charAt(0);
			boolean a1=false;
			boolean b1=false;
			if((map.get(a)+n)%4==map.get(b).intValue()){
				a1=true;
			}
			if(((map.get(a)-n)%4+4)%4==map.get(b).intValue()){
				b1=true;
			}
			if(a1&&!b1){
				pw.println("cw");
			}else if(!a1&b1){
				pw.println("ccw");
			}else{
				pw.println("undefined");
			}
			pw.flush();
		}
	}
}

import java.util.*;

public class Temp {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		//System.out.println("GO");

		String str = scn.nextLine();
		char si = str.charAt(0), li = str.charAt(2);

		int n = scn.nextInt();
		if (n % 4 == 0) {
			System.out.println("undefined");
		} else if (n % 4 == 1) {
			if (si == 60) {
				if (li == 94) {
					System.out.println("cw");
				} else if (li == 118) {
					System.out.println("ccw");
				} else {
					System.out.println("undefined");
				}
			} else if (si == 94) {
				if (li == 62) {
					System.out.println("cw");
				} else if (li == 60) {
					System.out.println("ccw");
				} else {
					System.out.println("undefined");
				}
			} else if (si == 62) {
				if (li == 118) {
					System.out.println("cw");
				} else if (li == 94) {
					System.out.println("ccw");
				} else {
					System.out.println("undefined");
				}
			} else if (si == 118) {
				if (li == 60) {
					System.out.println("cw");
				} else if (li == 62) {
					System.out.println("ccw");
				} else {
					System.out.println("undefined");
				}
			}
		} else if (n % 4 == 2) {
			System.out.println("undefined");
		} else if (n % 4 == 3) {
			if (si == 60) {
				if (li == 118) {
					System.out.println("cw");
				} else if (li == 94) {
					System.out.println("ccw");
				} else {
					System.out.println("undefined");
				}
			} else if (si == 94) {
				if (li == 60) {
					System.out.println("cw");
				} else if (li == 62) {
					System.out.println("ccw");
				} else {
					System.out.println("undefined");
				}
			} else if (si == 62) {
				if (li == 94) {
					System.out.println("cw");
				} else if (li == 118) {
					System.out.println("ccw");
				} else {
					System.out.println("undefined");
				}
			} else if (si == 118) {
				if (li == 62) {
					System.out.println("cw");
				} else if (li == 60) {
					System.out.println("ccw");
				} else {
					System.out.println("undefined");
				}
			}
		}
	}
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Three_Palindrome {
	public static void main(String[] args)throws Throwable {
		BufferedReader bf = new BufferedReader(new InputStreamReader (System.in));
		PrintWriter pw = new PrintWriter(System.out, true);
		String inp = bf.readLine();
		int start=inp.charAt(0)=='^'? 0:inp.charAt(0)=='>'? 1:inp.charAt(0)=='v'? 2:3;
		int end=inp.charAt(2)=='^'? 0:inp.charAt(2)=='>'? 1:inp.charAt(2)=='v'? 2:3;
		int steps=Integer.parseInt(bf.readLine());
		steps%=4;
		boolean cw =false;
		boolean ccw=false;
		if((start+steps)%4==end)
			cw=true;
		int op2=(start-steps)%4;
		if(op2!=0 && op2<0)
			op2+=4;
		if(op2==end)
			ccw=true;
		if(cw && !ccw)
			pw.print("cw");
		else if(ccw && !cw)
			pw.print("ccw");
		else
			pw.print("undefined");
		pw.close();
	}
}

import java.util.*;
import java.io.*;

public class useless{
	public static void main(String[] args) throws IOException {
		BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
		String[] spin = read.readLine().split(" ");
		String[] cosa = {"v",">","^","<"};
		int n = Integer.parseInt(read.readLine());
		if(n%2 == 0)System.out.println("undefined");
		else{
			if(spin[0].equals(cosa[0])){
				if(cosa[n%4].equals(spin[1])) System.out.println("ccw");
				else System.out.println("cw");
			}
			else if(spin[0].equals(cosa[1])){
				if(cosa[(n+1)%4].equals(spin[1])) System.out.println("ccw");
				else System.out.println("cw");
			}
			else if(spin[0].equals(cosa[2])){
				if(cosa[(n+2)%4].equals(spin[1])) System.out.println("ccw");
				else System.out.println("cw");
			}
			else{
				if(cosa[(n+3)%4].equals(spin[1])) System.out.println("ccw");
				else System.out.println("cw");
			}
		}
	}
}

import java.io.BufferedReader;
import java.io.PrintWriter;

import java.io.InputStreamReader;

import java.io.IOException;

import java.util.StringTokenizer;

public class Main {

    static Scanner in = new Scanner();
    static PrintWriter out = new PrintWriter(System.out);

    public static int val(char c) {
        switch(c) {
            case 'v':
                return 3;
            case '<':
                return 2;
            case '^':
                return 1;
            case '>':
                return 0;
        }
        return Integer.MAX_VALUE;
    }

    public static void main(String[] args) throws IOException {
        char[] c = in.nextLine().toCharArray();
        int d = (val(c[0]) - val(c[2]) + 4) % 4, n = in.nextInt() % 4;
        out.print((d == 2 ? "undefined" : (d == n ? (d == 0 ? "undefined" : "cw") : "ccw")));
        out.close();
    }

    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        public Scanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
            st = new StringTokenizer("");
        }

        public String next() throws IOException {
            if(!st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public String nextLine() throws IOException {
            if(!st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            String r = st.nextToken("\n");
            st = new StringTokenizer(br.readLine(), " ");
            return r;
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
    }
}

/*
⣿⣿⣿⣿⣿⣿⡷⣯⢿⣿⣷⣻⢯⣿⡽⣻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠸⣿⣿⣆⠹⣿⣿⢾⣟⣯⣿⣿⣿⣿⣿⣿⣽⣻⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣻⣽⡿⣿⣎⠙⣿⣞⣷⡌⢻⣟⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣿⣿⡄⠹⣿⣿⡆⠻⣿⣟⣯⡿⣽⡿⣿⣿⣿⣿⣽⡷⣯⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣟⣷⣿⣿⣿⡀⠹⣟⣾⣟⣆⠹⣯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢠⡘⣿⣿⡄⠉⢿⣿⣽⡷⣿⣻⣿⣿⣿⣿⡝⣷⣯⢿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣯⢿⣾⢿⣿⡄⢄⠘⢿⣞⡿⣧⡈⢷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣧⠘⣿⣷⠈⣦⠙⢿⣽⣷⣻⣽⣿⣿⣿⣿⣌⢿⣯⢿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣟⣯⣿⢿⣿⡆⢸⡷⡈⢻⡽⣷⡷⡄⠻⣽⣿⣿⡿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣏⢰⣯⢷⠈⣿⡆⢹⢷⡌⠻⡾⢋⣱⣯⣿⣿⣿⣿⡆⢻⡿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⡎⣿⢾⡿⣿⡆⢸⣽⢻⣄⠹⣷⣟⣿⣄⠹⣟⣿⣿⣟⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⡇⢸⣯⣟⣧⠘⣷⠈⡯⠛⢀⡐⢾⣟⣷⣻⣿⣿⣿⡿⡌⢿⣻⣿⣿
⣿⣿⣿⣿⣿⣿⣧⢸⡿⣟⣿⡇⢸⣯⣟⣮⢧⡈⢿⣞⡿⣦⠘⠏⣹⣿⣽⢿⣿⣿⣿⣿⣯⣿⣿⣿⡇⢸⣿⣿⣾⡆⠹⢀⣠⣾⣟⣷⡈⢿⣞⣯⢿⣿⣿⣿⢷⠘⣯⣿⣿
⣿⣿⣿⣿⣿⣿⣿⡈⣿⢿⣽⡇⠘⠛⠛⠛⠓⠓⠈⠛⠛⠟⠇⢀⢿⣻⣿⣯⢿⣿⣿⣿⣷⢿⣿⣿⠁⣾⣿⣿⣿⣧⡄⠇⣹⣿⣾⣯⣿⡄⠻⣽⣯⢿⣻⣿⣿⡇⢹⣾⣿
⣿⣿⣿⣿⣿⣿⣿⡇⢹⣿⡽⡇⢸⣿⣿⣿⣿⣿⣞⣆⠰⣶⣶⡄⢀⢻⡿⣯⣿⡽⣿⣿⣿⢯⣟⡿⢀⣿⣿⣿⣿⣿⣧⠐⣸⣿⣿⣷⣿⣿⣆⠹⣯⣿⣻⣿⣿⣿⢀⣿⢿
⣿⣿⣿⣿⣿⣿⣿⣿⠘⣯⡿⡇⢸⣿⣿⣿⣿⣿⣿⣿⣧⡈⢿⣳⠘⡄⠻⣿⢾⣽⣟⡿⣿⢯⣿⡇⢸⣿⣿⣿⣿⣿⣿⡀⢾⣿⣿⣿⣿⣿⣿⣆⠹⣾⣷⣻⣿⡿⡇⢸⣿
⣿⣿⣿⣿⣿⣿⣿⣿⡇⢹⣿⠇⢸⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠻⡇⢹⣆⠹⣟⣾⣽⣻⣟⣿⣽⠁⣾⣿⣿⣿⣿⣿⣿⣇⣿⣿⠿⠛⠛⠉⠙⠋⢀⠁⢘⣯⣿⣿⣧⠘⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⡈⣿⡃⢼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡙⠌⣿⣆⠘⣿⣞⡿⣞⡿⡞⢠⣿⣿⣿⣿⣿⡿⠛⠉⠁⢀⣀⣠⣤⣤⣶⣶⣶⡆⢻⣽⣞⡿⣷⠈⣿
⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠘⠁⠉⠉⠉⠉⠉⠉⠉⠉⠉⠙⠛⠛⢿⣄⢻⣿⣧⠘⢯⣟⡿⣽⠁⣾⣿⣿⣿⣿⣿⡃⢀⢀⠘⠛⠿⢿⣻⣟⣯⣽⣻⣵⡀⢿⣯⣟⣿⢀⣿
⣿⣿⣿⣟⣿⣿⣿⣿⣶⣶⡆⢀⣿⣾⣿⣾⣷⣿⣶⠿⠚⠉⢀⢀⣤⣿⣷⣿⣿⣷⡈⢿⣻⢃⣼⣿⣿⣿⣿⣻⣿⣿⣿⡶⣦⣤⣄⣀⡀⠉⠛⠛⠷⣯⣳⠈⣾⡽⣾⢀⣿
⣿⢿⣿⣿⣻⣿⣿⣿⣿⣿⡿⠐⣿⣿⣿⣿⠿⠋⠁⢀⢀⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣌⣥⣾⡿⣿⣿⣷⣿⣿⢿⣷⣿⣿⣟⣾⣽⣳⢯⣟⣶⣦⣤⡾⣟⣦⠘⣿⢾⡁⢺
⣿⣻⣿⣿⡷⣿⣿⣿⣿⣿⡗⣦⠸⡿⠋⠁⢀⢀⣠⣴⢿⣿⣽⣻⢽⣾⣟⣷⣿⣟⣿⣿⣿⣳⠿⣵⣧⣼⣿⣿⣿⣿⣿⣾⣿⣿⣿⣿⣿⣽⣳⣯⣿⣿⣿⣽⢀⢷⣻⠄⠘
⣿⢷⣻⣿⣿⣷⣻⣿⣿⣿⡷⠛⣁⢀⣀⣤⣶⣿⣛⡿⣿⣮⣽⡻⣿⣮⣽⣻⢯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⢀⢸⣿⢀⡆
⠸⣟⣯⣿⣿⣷⢿⣽⣿⣿⣷⣿⣷⣆⠹⣿⣶⣯⠿⣿⣶⣟⣻⢿⣷⣽⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢀⣯⣟⢀⡇
⣇⠹⣟⣾⣻⣿⣿⢾⡽⣿⣿⣿⣿⣿⣆⢹⣶⣿⣻⣷⣯⣟⣿⣿⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⢀⡿⡇⢸⡇
⣿⣆⠹⣷⡻⣽⣿⣯⢿⣽⣻⣿⣿⣿⣿⣆⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⢸⣿⠇⣼⡇
⡙⠾⣆⠹⣿⣦⠛⣿⢯⣷⢿⡽⣿⣿⣿⣿⣆⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠃⠎⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⢀⣿⣾⣣⡿⡇
⣿⣷⡌⢦⠙⣿⣿⣌⠻⣽⢯⣿⣽⣻⣿⣿⣿⣧⠩⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⢰⢣⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⢀⢀⢿⣞⣷⢿⡇
⣿⣽⣆⠹⣧⠘⣿⣿⡷⣌⠙⢷⣯⡷⣟⣿⣿⣿⣷⡀⡹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣈⠃⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⢀⣴⡧⢀⠸⣿⡽⣿⢀
⢻⣽⣿⡄⢻⣷⡈⢿⣿⣿⢧⢀⠙⢿⣻⡾⣽⣻⣿⣿⣄⠌⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⢁⣰⣾⣟⡿⢀⡄⢿⣟⣿⢀
⡄⢿⣿⣷⢀⠹⣟⣆⠻⣿⣿⣆⢀⣀⠉⠻⣿⡽⣯⣿⣿⣷⣈⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⢀⣠⠘⣯⣷⣿⡟⢀⢆⠸⣿⡟⢸
⣷⡈⢿⣿⣇⢱⡘⢿⣷⣬⣙⠿⣧⠘⣆⢀⠈⠻⣷⣟⣾⢿⣿⣆⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⣠⡞⢡⣿⢀⣿⣿⣿⠇⡄⢸⡄⢻⡇⣼
⣿⣷⡈⢿⣿⡆⢣⡀⠙⢾⣟⣿⣿⣷⡈⠂⠘⣦⡈⠿⣯⣿⢾⣿⣆⠙⠻⠿⠿⠿⠿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⢋⣠⣾⡟⢠⣿⣿⢀⣿⣿⡟⢠⣿⢈⣧⠘⢠⣿
⣿⣿⣿⣄⠻⣿⡄⢳⡄⢆⡙⠾⣽⣿⣿⣆⡀⢹⡷⣄⠙⢿⣿⡾⣿⣆⢀⡀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⣀⣠⣴⡿⣯⠏⣠⣿⣿⡏⢸⣿⡿⢁⣿⣿⢀⣿⠆⢸⣿
⣿⣿⣿⣿⣦⡙⣿⣆⢻⡌⢿⣶⢤⣉⣙⣿⣷⡀⠙⠽⠷⠄⠹⣿⣟⣿⣆⢙⣋⣤⣤⣤⣄⣀⢀⢀⢀⢀⣾⣿⣟⡷⣯⡿⢃⣼⣿⣿⣿⠇⣼⡟⣡⣿⣿⣿⢀⡿⢠⠈⣿
⣿⣿⣿⣿⣿⣷⣮⣿⣿⣿⡌⠁⢤⣤⣤⣤⣬⣭⣴⣶⣶⣶⣆⠈⢻⣿⣿⣆⢻⣿⣿⣿⣿⣿⣿⣷⣶⣤⣌⣉⡘⠛⠻⠶⣿⣿⣿⣿⡟⣰⣫⣴⣿⣿⣿⣿⠄⣷⣿⣿⣿
*/

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class b{

	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		char c1=s.next().charAt(0);
		char c2=s.next().charAt(0);
		int n=s.nextInt();
		String ccw="^<v>^<v>";
		String cw="^>v<^>v<";

		int rem=n%4;
		if(rem==2||rem==0) {
			System.out.println("undefined");
		}else {
			int index=-1;
			for(int i=0;i<cw.length();i++) {
				if(cw.charAt(i)==c1) {
					index=i;
					break;
				}
			}

			if(cw.charAt(index+rem)==c2) {
				System.out.println("cw");
			}else {
				System.out.println("ccw");
			}

		}

}
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Three_Palindrome {
	public static void main(String[] args)throws Throwable {
		BufferedReader bf = new BufferedReader(new InputStreamReader (System.in));
		PrintWriter pw = new PrintWriter(System.out, true);
		String inp = bf.readLine();
		int start=inp.charAt(0)=='^'? 0:inp.charAt(0)=='>'? 1:inp.charAt(0)=='v'? 2:3;
		int end=inp.charAt(2)=='^'? 0:inp.charAt(2)=='>'? 1:inp.charAt(2)=='v'? 2:3;
		int steps=Integer.parseInt(bf.readLine());
		steps%=4;
		boolean cw =false;
		boolean ccw=false;
		if((start+steps)%4==end)
			cw=true;
		int op2=(start-steps)%4;
		if(op2!=0)
			op2+=4;
		if(op2==end)
			ccw=true;
		if(cw && !ccw)
			pw.print("cw");
		else if(ccw && !cw)
			pw.print("ccw");
		else
			pw.print("undefined");
		pw.close();
	}
}

import java.util.*;
import java.io.*;

public final class Main {

    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        char firstChar = Character.valueOf(st.nextToken().charAt(0));
        char secondChar = Character.valueOf(st.nextToken().charAt(0));

        st = new StringTokenizer(br.readLine());
        int numRotations = Integer.parseInt(st.nextToken());

        int start = 0;

        switch (firstChar){
            case '^':
                start = 1;
                break;
            case '>':
                start = 2;
                break;
            case 'v':
                start = 3;
                break;
            case '<':
                start = 4;
                break;
        }

        int end = 0;

        switch (secondChar){
            case '^':
                end = 1;
                break;
            case '>':
                end = 2;
                break;
            case 'v':
                end = 3;
                break;
            case '<':
                end = 4;
                break;
        }

        int clockWiseRotations = 0;
        int cclockWiseRotations = 0;

        int startChar = start;
        int endChar = end;
        for(int i = 0; i<4; i++){
                if(startChar!=endChar){
                    clockWiseRotations++;
                }else{
                    break;
                }
                startChar += 1;
                startChar %= 4;
        }

        //System.out.println(start + " " + end);
        startChar = start;
        for(int i = 0; i<4; i++){
            if(startChar!=endChar){
                cclockWiseRotations++;
            }else{
                break;
            }
            startChar -= 1;
            if(startChar < 0) {
                startChar = 0;
            }
        }

        numRotations %= 4;

        if(numRotations != clockWiseRotations && numRotations != cclockWiseRotations || numRotations == 2){
            pw.println("undefined");
            pw.close();
            return;
        }

        if(numRotations == clockWiseRotations){
            pw.println("cw");
            pw.close();
            return;
        }else{
            pw.println("ccw");
            pw.close();
            return;
        }

    }
}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {

	static HashMap<Character, Integer> degrees = new HashMap<Character, Integer>();

	public static char rotate(char start, int dur, boolean dir) {

		int degree = degrees.get(start);
		// System.out.println(degree);
		if (dir) {
			// ccw
			degree += 90 * dur;

		} else {
			degree -= 90 * dur;

		}
		degree = degree % 360;

		if (degree < 0) {
			degree = 360 + degree;
		}

		char ret = 'a';
		Iterator it = degrees.entrySet().iterator();
		while (it.hasNext()) {
			Map.Entry<Character, Integer> pair = (Map.Entry<Character, Integer>) it
					.next();
			if (pair.getValue() == degree) {
				ret = pair.getKey();
			}

		}

		return ret;

	}

	public static void main(String[] args) {

		degrees.put('>', 0);
		degrees.put('<', 180);
		degrees.put('^', 90);
		degrees.put('v', 270);

		Scanner in = new Scanner(System.in);
		String start = in.next();
		String end = in.next();
		int dur = in.nextInt();

		char ccw = rotate(start.toCharArray()[0], dur, true);
		char cw = rotate(start.toCharArray()[0], dur, false);

		if (cw == ccw) {
			System.out.println("undefined");
			return;
		}

		if (cw == end.toCharArray()[0]) {
			System.out.println("cw");
			return;
		}

		if (ccw == end.toCharArray()[0]) {
			System.out.println("ccw");
			return;
		}

		System.out.println("undefined");
		return;

	}
}

import java.io.*;
import java.util.*;
import java.lang.*;

public class Rextester{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = new Integer(br.readLine());
        br.close();
        int a = (int)st.nextToken().charAt(0);
        int b = (int)st.nextToken().charAt(0);
        if(a==94&&b==62){
            if(n%4==1){
                System.out.println("cw");
                return;
            }
            else if(n%4==3){
                System.out.println("ccw");
            }
        }
        else if(a==94&&b==60){
            if(n%4==1){
                System.out.println("cw");
                return;
            }
            else if(n%4==1){
                System.out.println("ccw");
                return;
            }
        }
        else if(a==118&&b==62){
            if(n%4==1){
                System.out.println("ccw");
                return;
            }
            else if(n%4==3){
                System.out.println("cw");
                return;
            }
        }
        else if(a==118&&b==60){
            if(n%4==1){
                System.out.println("cw");
                return;
            }
            else if(n%4==3){
                System.out.println("ccw");
                return;
            }
        }
        else if(a==62&&b==118){
            if(n%4==1){
                System.out.println("cw");
                return;
            }
            else if(n%4==3){
                System.out.println("ccw");
                return;
            }
        }
        else if(a==62&&b==94){
            if(n%4==1){
                System.out.println("ccw");
                return;
            }
            else if(n%4==3){
                System.out.println("cw");
                return;
            }
        }
        else if(a==60&&b==94){
            if(n%4==1){
                System.out.println("cw");
                return;
            }
            else if(n%4==3){
                System.out.println("ccw");
                return;
            }
        }
        else if(a==60&&b==118){
            if(n%4==1){
                System.out.println("ccw");
                return;
            }
            else if(n%4==3){
                System.out.println("cw");
                return;
            }
        }
        else{
            System.out.println("undefined");
        }
    }
}

import java.util.*;
public class Test {
    public static void main(String[] args) {
    Scanner input=new Scanner(System . in );
    char []a={'^','>','v','<'};

    char c1=input.next().charAt(0),c2=input.next().charAt(0);
    int n=input.nextInt();
        if (n%2==0) {
            System.out.println("undefined");
        }
        else{
            int k,m=0;
            for ( k = 0; k < 4; k++) {
                if (a[k]==c1) {
                    break;
                }
            }
           m=n%4;
            if (m+k>4) {
              m=m+k-4;
            }
            else if (m+k<4) {
                m=m+k;
            }
                if (a[m]==c2) {
                    System.out.println("cw");
                }else System.out.println("ccw");
            }
        }

    }

import java.util.Scanner;

public class TheUselessToy {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		String spinner = in.nextLine();
		int numOfRotations = in.nextInt();

		String[] directions = spinner.split(" ");

		char startPosition = directions[0].charAt(0);
		char endPosition = directions[1].charAt(0);

		char cwPosition = startPosition;
		char ccwPosition = startPosition;

		for (int i = 0; i < numOfRotations; i++) {
			if (cwPosition == '^') {
				cwPosition = '>';
			} else if (cwPosition == '>') {
				cwPosition = 'v';
			} else if (cwPosition == 'v') {
				cwPosition = '<';
			} else if (cwPosition == '<') {
				cwPosition = '^';
			}
			if (ccwPosition == '^') {
				ccwPosition = '<';
			} else if (ccwPosition == '>') {
				ccwPosition = '^';
			} else if (ccwPosition == 'v') {
				ccwPosition = '>';
			} else if (ccwPosition == '<') {
				ccwPosition = 'v';
			}
		}

		if (endPosition == cwPosition) {
			System.out.println("cw");
		} else if (endPosition == ccwPosition) {
			System.out.println("ccw");
		} else {
			System.out.println("undefined");
		}

	}

}

import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.ArrayList;

public class tenth {

    public static void main(String args[]) throws Exception {
	Reader s =new Reader();
	String sp=s.readLine();
	int t=s.nextInt()%4,j=0,k=0;

	if(sp.charAt(0)=='^')
	    j=1;
	if(sp.charAt(0)=='>')
	    j=2;
	if(sp.charAt(0)=='<')
	    j=3;
	if(sp.charAt(0)=='v')
	    j=4;
	if(sp.charAt(2)=='^')
	    k=1;
	if(sp.charAt(2)=='>')
	    k=2;
	if(sp.charAt(2)=='<')
	    k=3;
	if(sp.charAt(2)=='v')
	    k=4;

	    if((j+t)%4==k){

	        System.out.println("cw");
	    }
	    else if((k+t)%4==j){
	      System.out.println("ccw");
	    }
	    else{
	          System.out.println("undefined");
	    }

	}

//From GeeksForGeeks
    static class Reader {

        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n') {
                    break;
                }
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException {
            int ret = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            boolean neg = (c == '-');
            if (neg) {
                c = read();
            }
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (neg) {
                return -ret;
            }
            return ret;
        }

        public long nextLong() throws IOException {
            long ret = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            boolean neg = (c == '-');
            if (neg) {
                c = read();
            }
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg) {
                return -ret;
            }
            return ret;
        }

        public double nextDouble() throws IOException {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            boolean neg = (c == '-');
            if (neg) {
                c = read();
            }

            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (c == '.') {
                while ((c = read()) >= '0' && c <= '9') {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg) {
                return -ret;
            }
            return ret;
        }

        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1) {
                buffer[0] = -1;
            }
        }

        private byte read() throws IOException {
            if (bufferPointer == bytesRead) {
                fillBuffer();
            }
            return buffer[bufferPointer++];
        }

        public void close() throws IOException {
            if (din == null) {
                return;
            }
            din.close();
        }
    }

}

import java.util.*;
import java.io.*;

public final class Main {

    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        char firstChar = Character.valueOf(st.nextToken().charAt(0));
        char secondChar = Character.valueOf(st.nextToken().charAt(0));

        st = new StringTokenizer(br.readLine());
        int numRotations = Integer.parseInt(st.nextToken());

        int start = 0;

        switch (firstChar){
            case '^':
                start = 1;
                break;
            case '>':
                start = 2;
                break;
            case 'v':
                start = 3;
                break;
            case '<':
                start = 4;
                break;
        }

        int end = 0;

        switch (secondChar){
            case '^':
                end = 1;
                break;
            case '>':
                end = 2;
                break;
            case 'v':
                end = 3;
                break;
            case '<':
                end = 4;
                break;
        }

        //System.out.println(start + " " + end);
        int clockWiseRotations = 0;
        int cclockWiseRotations = 0;

        int startChar = start;
        int endChar = end;
        for(int i = 0; i<4; i++){
                if(startChar!=endChar){
                    clockWiseRotations++;
                }else{
                    break;
                }
                startChar += 1;
                if(startChar > 4)
                    startChar = 1;
        }

        //System.out.println(start + " " + end);
        startChar = start;
        for(int i = 0; i<4; i++){
            if(startChar!=endChar){
                cclockWiseRotations++;
            }else{
                break;
            }
            startChar -= 1;
            if(startChar == 0) {
                startChar = 4;
            }
        }

        numRotations %= 4;

        //System.out.println(clockWiseRotations + " "  + cclockWiseRotations);

        if(numRotations != clockWiseRotations && numRotations != cclockWiseRotations || numRotations == 2){
            pw.println("undefined");
            pw.close();
            return;
        }

        if(numRotations == clockWiseRotations){
            pw.println("cw");
            pw.close();
            return;
        }else{
            pw.println("ccw");
            pw.close();
            return;
        }

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

public class MainY {

	public static void main(String[] args) {

		List<String> input = getRawInput();

		int start = (int)(input.get(0).trim().split(" ")[0]).charAt(0);
		int ends = (int)(input.get(0).trim().split(" ")[1]).charAt(0);
		BigInteger big = new BigInteger(input.get(1).trim());

		int []completeAcii ={94, 62, 118, 60};

		BigInteger rest = big.mod(new BigInteger("4"));
		if(rest.equals(new BigInteger("2"))){
			System.out.println("undefined");
		}else{
			int pos = getPosition(start, completeAcii);
			int []aux = createAuxExcludePos(pos, completeAcii);
			int []aux2 = createAux(aux);

			if (rest.equals(new BigInteger("3")) && aux2[0]==ends){
				System.out.println("ccw");
			}
			if (rest.equals(new BigInteger("1")) && aux2[0]==ends){
				System.out.println("cw");
			}

			if (rest.equals(new BigInteger("3")) && aux2[2]==ends){
				System.out.println("cw");
			}
			if (rest.equals(new BigInteger("1")) && aux2[2]==ends){
				System.out.println("ccw");
			}

		}

	}

	private static int[] createAux(int[] aux) {
		List<Integer>auxList  = new ArrayList<>();
		for (int i=0;i<aux.length;i++){
			if (aux[i]!=0){
				auxList.add(aux[i]);
			}
		}
		int[]a = new int [auxList.size()];
		for (int i=0;i<auxList.size();i++){
			a[i]=auxList.get(i);
		}
		return a;
	}

	private static int[] createAuxExcludePos(int pos, int[] completeAcii) {
		int result[] = new int[completeAcii.length];
		if (pos+1<completeAcii.length){
			for (int i=(pos+1); i<completeAcii.length;i++){
				result[i] = completeAcii[i];
			}
			for (int i=0;i<pos;i++){
				result[i] = completeAcii[i];
			}
		}else{
			for (int i=0;i<pos;i++){
				result[i] = completeAcii[i];
			}
		}

		return result;
	}

	private static int getPosition(int start, int[] completeAcii) {
		int i=0;
		for (i=0;i<completeAcii.length;i++){
			if (completeAcii[i]==start){
				return i;
			}
		}
		return 0;
	}

	public static List<String> getRawInput() {
		List<String> line = new ArrayList<>();

		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			line.add(br.readLine().trim());
			line.add(br.readLine().trim());
		} catch (IOException e) {
			e.printStackTrace();
		}
		return line;

	}
}

import java.util.Scanner;

public class UselessToy {
    private static final int[][] CW = {
            {0,1,2,3},
            {3,0,1,2},
            {2,3,0,1},
            {1,2,3,0}
    };
    private static final int[][] CCW = {
            {0,3,2,1},
            {1,0,3,2},
            {2,1,0,3},
            {3,2,1,0}
    };
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int startPos = posIdx(scanner.next().charAt(0));
        int endPos = posIdx(scanner.next().charAt(0));
        int transitions = scanner.nextInt() % 4;
        if (CW[startPos][endPos]==transitions) {
            System.out.println("cw");
        } else if (CCW[startPos][endPos]==transitions) {
            System.out.println("ccw");
        } else {
            System.out.println("undefined");
        }
    }

    public static int posIdx(char pos) {
        return pos=='v'? 0 : pos=='<' ? 1 : pos=='^'? 2 : 3;
    }
}

import java.io.*;
import java.util.*;

public class Main {
    static FastScanner in;
    static PrintWriter out;
    static final int MOD = 1000000007;

    public static void main(String[] args) throws IOException {
        //        Scanner in = new Scanner(new File("input.txt"));
        //        Scanner in = new Scanner(System.in);
        //        System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream("output.txt")), true));
        out = new PrintWriter(System.out);
        in = new FastScanner(System.in);
        //        in = new FastScanner("input.txt");
        char s[] = in.nextLine().toCharArray();
        int n = in.nextInt();
        char a1 = s[0];
        char a2 = s[2];
        Map<Character, Integer> map = new HashMap<Character, Integer>();
        map.put('<', 0);
        map.put('v', 1);
        map.put('>', 2);
        map.put('^', 3);
        int b1 = map.get(a1);
        int b2 = map.get(a2);
        //        out.println(b1 + " " + b2);
        if ((b1 + n % 4) % 4 == b2 && (b1 - n % 4) % 4 != b2)
            out.println("ccw");
        else if ((b1 - n % 4) % 4 == b2 && (b1 + n % 4) % 4 != b2)
            out.println("cw");
        else
            out.println("undefined");
        out.close();
    }
}

class Pair {
    public String first; //first member of pair
    public int second; //second member of pair
    public Integer length;

    public Pair(String first, int second, int length) {
        this.first = first;
        this.second = second;
        this.length = length;
    }

    public Pair() {

    }
}

class PairComparable implements Comparator<Pair> {

    @Override
    public int compare(Pair o1, Pair o2) {
        if (o1.second < o2.second)
            return -1;
        else if (o1.second > o2.second)
            return 1;
        else {
            return -o1.length.compareTo(o2.length);
        }
    }
}

class FastScanner {

    BufferedReader br;
    StringTokenizer tokenizer;

    FastScanner(String fileName) throws FileNotFoundException {
        this(new FileInputStream(new File(fileName)));
    }

    FastScanner(InputStream is) {
        br = new BufferedReader(new InputStreamReader(is));
    }

    String nextLine() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    String next() throws IOException {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            String line = br.readLine();
            if (line == null) {
                return null;
            }
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    char nextChar() throws IOException {
        return next().charAt(0);
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author captainTurtle
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String a = in.next();
            String b = in.next();
            int n = in.nextInt();
            String c = Ascii(a, b, n);
            System.out.println(c);
            System.out.flush();
            in.close();

        }

        public static String Ascii(String x, String y, int time) {
            int a = x.charAt(0);
            int b = y.charAt(0);
            int sonuc = a - b;
            String cikti = "";
            if (a == 62) {
                if (time % 6 == 0) {
                    cikti = "undefined";
                } else if (time % 4 == 1) {
                    if (sonuc == (-56)) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }

                } else if (time % 4 == 2) {
                    if (sonuc == 2) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                } else if (time % 4 == 3) {
                    if (sonuc == (-32)) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                } else if (time % 4 == 0) {
                    if (sonuc == 0) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                }

            }
            if (a == 118) {
                if (time % 6 == 0) {
                    cikti = "undefined";
                } else if (time % 4 == 1) {
                    if (sonuc == 58) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }

                } else if (time % 4 == 2) {
                    if (sonuc == 24) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                } else if (time % 4 == 3) {
                    if (sonuc == 56) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                } else if (time % 4 == 0) {
                    if (sonuc == 0) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }

                }

            }
            if (a == 60) {
                if (time % 6 == 0) {
                    cikti = "undefined";
                } else if (time % 4 == 1) {
                    if (sonuc == (-34)) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                } else if (time % 4 == 2) {
                    if (sonuc == (-2)) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                } else if (time % 4 == 3) {
                    if (sonuc == (-32)) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                } else if (time % 4 == 0) {
                    if (sonuc == 0) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                }

            }
            if (a == 94) {
                if (time % 6 == 0) {
                    cikti = "undefined";
                } else if (time % 4 == 1) {
                    if (sonuc == 32) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }

                } else if (time % 4 == 2) {
                    if (sonuc == (-24)) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                } else if (time % 4 == 3) {
                    if (sonuc == 34) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                } else if (time % 4 == 0) {
                    if (sonuc == 0) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                }

            }

            return cikti;
        }

    }
}

import java.io.*;
import java.util.*;

public class Main {

	void howUdoin() {
		Scanner te=new Scanner(System.in);
		String st=te.nextLine();
		int n=inpi();
		char a='^',d='<',b='>',c='v';
		char s=st.charAt(0),e=st.charAt(2);
		int f=0;
		double x,y;
		String ans="";
		if((s==a || s==c) && (e==a || e==c)){

			System.out.println("undifined");
			return;

		}
		else if((s==b || s==d) && (e==b || e==d)){
			System.out.println("undifined");
			return;
		}
		x=(double)(n+3)/4;
		y=(double)(n+1)/4;
		if(x-Math.floor(x)==0){
			f=1;
		}
		else if(y-Math.floor(y)==0){
			f=2;
		}
		else {
			System.out.println("undifined");
			return;
		}
		if(s==a){
			if((f==1 && e==b) || (f==2 && e==d)){
				ans="cw";
			}
			else{
				ans="ccw";
			}
		}
		else if(s==b){
			if((f==1 && e==c) || (f==2 && e==a)){
				ans="cw";
			}
			else{
				ans="ccw";
			}
		}
		else if(s==c){
			if((f==1 && e==d) || (f==2 && e==b)){
				ans="cw";
			}
			else{
				ans="ccw";
			}
		}
		else{
			if((f==1 && e==a) || (f==2 && e==c)){
				ans="cw";
			}
			else{
				ans="ccw";
			}
		}
		System.out.println(ans);

	}

	InputStream obj;
	PrintWriter out;
	String check = "";

	public static void main(String[] args) throws IOException {
		new Main().main1();
	}

	void main1() throws IOException {
		out = new PrintWriter(System.out);
		obj = check.isEmpty() ? System.in : new ByteArrayInputStream(check.getBytes());
		howUdoin();
		out.flush();
		out.close();
	}
	byte inbuffer[] = new byte[1024];
	int lenbuffer = 0, ptrbuffer = 0;

	int readByte() {
		if (lenbuffer == -1) {
			throw new InputMismatchException();
		}
		if (ptrbuffer >= lenbuffer) {
			ptrbuffer = 0;
			try {
				lenbuffer = obj.read(inbuffer);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
		}
		if (lenbuffer <= 0) {
			return -1;
		}
		return inbuffer[ptrbuffer++];
	}

	boolean isSpaceChar(int c) {
		return (!(c >= 33 && c <= 126));
	}

	int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b));
		return b;
	}

	String inps() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	String inpsl() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (b!='\n') {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	int inpi() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	long inpl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	float inpf() {
		return Float.parseFloat(inps());
	}

	double inpd() {
		return Double.parseDouble(inps());
	}

	char inpc() {
		return (char) skip();
	}

	int[] inpia(int n) {
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = inpi();
		}
		return a;
	}

	long[] inpla(int n) {
		long a[] = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = inpl();
		}
		return a;
	}

	String[] inpsa(int n) {
		String a[] = new String[n];
		for (int i = 0; i < n; i++) {
			a[i] = inps();
		}
		return a;
	}

}

import java.util.*;
public class Solution {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		String o=in.next(),t=in.next();
		int n=in.nextInt()%4;
		int oi=0,ti=0;
		switch (o){
			case "^":
				oi=0;
				break;
			case ">":
				oi=1;
				break;
			case "v":
				oi=2;
				break;
			default:
				oi=3;
		}
		switch (t){
			case "^":
				ti=0;
				break;
			case ">":
				ti=1;
				break;
			case "v":
				ti=2;
				break;
			default:
				ti=3;
		}
		int cw=ti-oi,ccw=oi-ti;
		if (((cw==-ccw)&&(Math.abs(cw)==2))||(cw==cw)){System.out.println("undefined");return;}
		if ((ti-oi)==n){
			System.out.println("cw");
		}else if ((oi-ti)==n) {
			System.out.println("ccw");
		}
		in.close();
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author captainTurtle
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String a = in.next();
            String b = in.next();
            int n = in.nextInt();
            System.out.print(Ascii(a, b, n));
            in.close();
        }

        public static String Ascii(String x, String y, int time) {
            int a = x.charAt(0);
            int b = y.charAt(0);
            int sonuc = a - b;
            String cikti = "";
            if (a == 62) {
                if (time % 4 == 1) {
                    if (sonuc == 56) {
                        cikti = "cw";
                    }

                } else if (time % 4 == 2) {
                    if (sonuc == 2) {
                        cikti = "cw";
                    }
                } else if (time % 4 == 3) {
                    if (sonuc == (-32)) {
                        cikti = "cw";
                    }
                } else if (time % 4 == 0) {
                    if (sonuc == 0) {
                        cikti = "cw";
                    }
                } else {
                    cikti = "cww";
                }
            }
            if (a == 118) {
                if (time % 4 == 1) {
                    if (sonuc == 58) {
                        cikti = "cw";
                    }
                } else if (time % 4 == 2) {
                    if (sonuc == 24) {
                        cikti = "cw";
                    }
                } else if (time % 4 == 3) {
                    if (sonuc == 56) {
                        cikti = "cw";
                    }
                } else if (time % 4 == 0) {
                    if (sonuc == 0) {
                        cikti = "cw";
                    }
                } else {
                    cikti = "cww";
                }

            }
            if (a == 60) {
                if (time % 4 == 1) {
                    if (sonuc == (-34)) {
                        cikti = "cw";
                    }
                } else if (time % 4 == 2) {
                    if (sonuc == (-2)) {
                        cikti = "cw";
                    }
                } else if (time % 4 == (-58)) {
                    if (sonuc == (-32)) {
                        cikti = "cw";
                    }
                } else if (time % 4 == 0) {
                    if (sonuc == 0) {
                        cikti = "cw";
                    }
                } else {
                    cikti = "cww";
                }
            }
            if (a == 94) {
                if (time % 4 == 1) {
                    if (sonuc == 32) {
                        cikti = "cw";
                    }
                } else if (time % 4 == (-24)) {
                    if (sonuc == 2) {
                        cikti = "cw";
                    }
                } else if (time % 4 == 3) {
                    if (sonuc == 34) {
                        cikti = "cw";
                    }
                } else if (time % 4 == 0) {
                    if (sonuc == 0) {
                        cikti = "cw";
                    }

                } else if (time > 4) {
                    cikti = "undefined";
                } else {
                    cikti = "cww";
                }
            }

            return cikti;
        }

    }
}

import java.io.Console;
import java.util.Scanner;

/**
 * Created by chenshang on 2017/7/14.
 */
public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String firstAndLast = in.nextLine();
        char[] chars = firstAndLast.toCharArray();
        int num = in.nextInt(); //读取数字
        System.out.println(check(chars[0], chars[1], num));
    }

    public static String check(char first, char last, int num) {

        char[] items = {'<', '^', '>', 'v', '<', '^', '>', 'v'};
        int position = num % 4;
        int x = 0;
        for (int i = 0; i < items.length; i++) {
            if (items[i] == first) {
                x = i;
                break;
            }
        }
        if (items[x + position] == last) return "cw";
        if (items[x + 4 - position] == last) return "ccw";
        return "undefined";
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author captainTurtle
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String a = in.next();
            String b = in.next();
            int n = in.nextInt();
            String c = Ascii(a, b, n);
            System.out.println(c);
            System.out.flush();
            in.close();

        }

        public static String Ascii(String x, String y, int time) {
            int a = x.charAt(0);
            int b = y.charAt(0);
            int sonuc = a - b;
            String cikti = "";
            if (a == 62) {
                if (time % 4 == 1) {
                    if (sonuc == (-56)) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }

                } else if (time % 4 == 2 || time % 4 == 0) {
                    cikti = "undefined";
                } else if (time % 4 == 3) {
                    if (sonuc == (-32)) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                }

            }
            if (a == 118) {

                if (time % 4 == 1) {
                    if (sonuc == 58) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }

                } else if (time % 4 == 2 || time % 4 == 0) {
                    cikti = "undefined";
                } else if (time % 4 == 3) {
                    if (sonuc == 56) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                }

            }
            if (a == 60) {
                if (time % 4 == 1) {
                    if (sonuc == (-34)) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                } else if (time % 4 == 2 || time % 4 == 0) {

                    cikti = "undefined";

                } else if (time % 4 == 3) {
                    if (sonuc == (-32)) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                }

            }
            if (a == 94) {
                if (time % 4 == 1) {
                    if (sonuc == 32) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }

                } else if (time % 4 == 2 || time % 4 == 0) {

                    cikti = "undefined";

                } else if (time % 4 == 3) {
                    if (sonuc == 34) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                }

            }

            return cikti;
        }

    }
}

/**
 * Created by chenshang on 2017/7/14.
 */
public class Main {

    public static void main(String[] args) {
        System.out.println(check('<', '^', 1));
    }

    public static String check(char first, char last, int num) {

        char[] items = {'<', '^', '>', 'v', '<', '^', '>', 'v'};
        int position = num % 4;
        int x = 0;
        for (int i = 0; i < items.length; i++) {
            if (items[i] == first)
                x = i;
            break;
        }
        if (items[x + position] == last) return "cw";
        if (items[x + 4 - position] == last) return "ccw";
        return "undefined";
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextChar();
            int b = in.nextChar();

            if (a == 118) a = 1;
            if (a == 60) a = 2;
            if (a == 94) a = 3;
            if (a == 62) a = 4;

            if (b == 118) b = 1;
            if (b == 60) b = 2;
            if (b == 94) b = 3;
            if (b == 62) b = 4;

            int t = in.nextInt();
            t = t % 4;

            int ans = Math.abs(a - b);

            if (ans == t && ans != 2) {
                System.out.println("cw");
                return;
            } else if (ans == 2) {
                System.out.println("undefined");
                return;
            } else {
                System.out.println("ccw");
                return;
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public char nextChar() {
            return next().charAt(0);
        }

    }
}

import java.io.*;
import java.util.StringTokenizer;
public class Useless {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer t = new StringTokenizer(in.readLine());
        String a = t.nextToken();
        String b = t.nextToken();
        int c = 0;
        int d = 0;
        if(a.equals("v"))
            c = 0;
        if(b.equals("v"))
            d = 0;
        if(a.equals(">"))
            c = 1;
        if(b.equals(">"))
            d = 1;
        if(a.equals("^"))
            c = 2;
        if(b.equals("^"))
            d = 2;
        if(a.equals("<"))
            c = 3;
        if(b.equals("<"))
            d = 3;
        if(((c - d) == 1) || ((c - d) == -3))
            System.out.println("cw");
        else if(((c - d) == -1) || ((c - d) == 3))
            System.out.println("ccw");
        else
            System.out.println("undefined");

    }
}

import java.util.*;

public class Symbol
{
	public static void main(String []args)
	{
		Scanner sc = new Scanner(System.in);

		char []a = new char[4];

		a[0] = 'v';
		a[1] = '<';
		a[2] = '^';
		a[3] = '>';

		char b = (sc.next()).charAt(0);
		char c = (sc.next()).charAt(0);

		int n = sc.nextInt()%4;

		sc.close();

		if((b==a[0] && c==a[2]) || (b==a[2] && c==a[0]) || (b==a[1] && c==a[3]) || (b==a[3] && c==a[1]) || n==0 || n==2)
			System.out.println("undefined");
		else if(b==a[0])
		{
			char ans = a[(0+n)%4];
			int temp = Math.abs(0-n)%4;
			if(ans==c)
				System.out.println("cw");
			else if(a[temp]==c)
				System.out.println("ccw");
			else
				System.out.println("undefined");
		}
		else if(b==a[1])
		{
			char ans = a[(1+n)%4];
			int temp = Math.abs(1-n)%4;
			if(ans==c)
				System.out.println("cw");
			else if(a[temp]==c)
				System.out.println("ccw");
			else
				System.out.println("undefined");
		}
		else if(b==a[2])
		{
			char ans = a[(2+n)%4];
			int temp = Math.abs(2-n)%4;
			if(ans==c)
				System.out.println("cw");
			else if(a[temp]==c)
				System.out.println("ccw");
			else
				System.out.println("undefined");
		}
		else if(b==a[3])
		{
			char ans = a[(3+n)%4];
			int temp = Math.abs(3-n)%4;
			if(ans==c)
				System.out.println("cw");
			else if(a[temp]==c)
				System.out.println("ccw");
			else
				System.out.println("undefined");
		}
	}
}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {

	static HashMap<Character, Integer> degrees = new HashMap<Character, Integer>();

	public static char rotate(char start, int dur, boolean dir) {

		int degree = degrees.get(start);
		// System.out.println(degree);
		if (dir) {
			// ccw
			degree += 90 * dur;

		} else {
			degree -= 90 * dur;

		}
		degree = degree % 360;

		if (degree < 0) {
			degree = 360 + degree;
		}

		char ret = 'a';
		Iterator it = degrees.entrySet().iterator();
		while (it.hasNext()) {
			Map.Entry<Character, Integer> pair = (Map.Entry<Character, Integer>) it
					.next();
			if (pair.getValue() == degree) {
				ret = pair.getKey();
			}

		}

		return ret;

	}

	public static void main(String[] args) {

		degrees.put('>', 0);
		degrees.put('<', 180);
		degrees.put('^', 90);
		degrees.put('v', 270);

		Scanner in = new Scanner(System.in);
		String start = in.next();
		String end = in.next();
		int dur = in.nextInt();

		char ccw = rotate(start.toCharArray()[0], dur, true);
		char cw = rotate(start.toCharArray()[0], dur, false);

		if (cw == ccw) {
			System.out.println("undefined");
			return;
		}

		if (cw == end.toCharArray()[0]) {
			System.out.println("cw");
			return;
		}

		if (ccw == end.toCharArray()[0]) {
			System.out.println("ccw");
			return;
		}

		System.out.println("undefined");
		return;

	}
}

import java.io.BufferedReader;
import java.io.PrintWriter;

import java.io.InputStreamReader;

import java.io.IOException;

import java.util.StringTokenizer;

public class Main {

    static Scanner in = new Scanner();
    static PrintWriter out = new PrintWriter(System.out);

    public static int val(char c) {
        switch(c) {
            case 'v':
                return 3;
            case '<':
                return 2;
            case '^':
                return 1;
            case '>':
                return 0;
        }
        return Integer.MAX_VALUE;
    }

    public static void main(String[] args) throws IOException {
        char[] c = in.nextLine().toCharArray();
        int d = (val(c[0]) - val(c[2]) + 4) % 4, n = in.nextInt() % 4;
        out.print((d == 2 ? "undefined" : (d == n ? "cw" : "ccw")));
        out.close();
    }

    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        public Scanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
            st = new StringTokenizer("");
        }

        public String next() throws IOException {
            if(!st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public String nextLine() throws IOException {
            if(!st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            String r = st.nextToken("\n");
            st = new StringTokenizer(br.readLine(), " ");
            return r;
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
    }
}

import java.util.*;
import java.io.*;

public class R426_A {
	FastScanner in;
	PrintWriter out;

	public void solve() {
		String s = in.next();
		String f = in.next();
		int a = -1;
		int b = -1;

		if (s.compareTo("^") == 0) {
			a = 0;
		}
		if (s.compareTo(">") == 0) {
			a = 1;
		}
		if (s.compareTo("v") == 0) {
			a = 2;
		}
		if (s.compareTo("<") == 0) {
			a = 3;
		}

		if (f.compareTo("^") == 0) {
			b = 0;
		}
		if (f.compareTo(">") == 0) {
			b = 1;
		}
		if (f.compareTo("v") == 0) {
			b = 2;
		}
		if (f.compareTo("<") == 0) {
			b = 3;
		}

		int n = in.nextInt();
		n %= 4;

		switch (n) {
		case 0: {
			out.println("undefined");
			return;
		}
		case 1: {
			if ((a-b)%4 == 1) {
				out.println("ccw");
			} else {
				out.println("cw");
			}
			return;
		}
		case 2: {
			out.println("undefined");
			return;
		}
		case 3: {
			if ((a-b)%4 == 1) {
				out.println("cw");
			} else {
				out.println("ccw");
			}
			return;
		}
		}
	}

	public void run() {
		in = new FastScanner();
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		solve();
		out.close();
	}

	class FastScanner {
		StringTokenizer st;
		BufferedReader br;

		FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer (br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main (String[] args) {
		new R426_A().run();
	}
}

import java.util.Scanner;

public class Spinner {
	private static Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		Spinner s = new Spinner();
		String answer = new String();
		SpinPosition initialPosition = s.new SpinPosition(in.next().charAt(0));
		SpinPosition finalPosition = s.new SpinPosition(in.next().charAt(0));
		long time = in.nextLong();
		time %= 4;
		int clockWise = Math.abs(finalPosition.positionOrder - initialPosition.positionOrder);
		int counterCW = 4 -Math.abs(finalPosition.positionOrder - initialPosition.positionOrder);
		if(time == 0 || clockWise == counterCW)
		{
			answer = "undefined";
		}
		else
		{
			if(time - clockWise == 0)
			{
				answer = "cw";
			}
			else if(time - counterCW == 0)
			{
				answer = "ccw";
			}
			else
			{
				answer = "undefined";
			}
		}
		System.out.println(answer);
	}

	public class SpinPosition
	{
		int positionOrder;
		char position;
		public SpinPosition(char x)
		{
			position = x;
			if(position == 'v')
			{
				positionOrder = 1;
			}else if(position == '<') {
				positionOrder = 2;
			}else if (position == '^') {
				positionOrder = 3;
			}else {
				positionOrder = 4;
			}
		}
	}

}

import java .util.*;
public class St
{
	public static void main(String[]args)
	{
     Scanner sc= new Scanner(System.in);
    String [] s1=(sc.nextLine()).split(" ");
	//String x1= s1[0];
	 int x1=(s1[0].equals("v"))?1:(s1[0].equals(">"))?2:(s1[0].equals("<"))?4:3;
	 String x2 =s1[1];
	 x2=(s1[1].equals("v"))?"1":(s1[1].equals(">"))?"2":(s1[1].equals("<"))?"4":"3";
	 int  s2 =sc.nextInt()%4;
     if((x1+s2)%4==Integer.parseInt(x2))
    	 {
    	 if(x1-s2<=0)
    	 {
    		 if(x1-s2+4==Integer.parseInt(x2))
    		 {	 System.out.println("undefined");
    		 }
    		 else
    			 System.out.println("ccw");
    	 }
    	 else
    	 {
    		 if(x1-s2==Integer.parseInt(x2))
    		 {	 System.out.println("undefined");
    		 }
    		 else
    			 System.out.println("ccw");
    	 }
	}
	else
		{
	if(x1-s2<=0)
   	 {
   		 if(x1-s2+4==Integer.parseInt(x2))
   		 {	 System.out.println("cw");
   		 }
  	 }
		 else
    	 {
    		 if(x1-s2==Integer.parseInt(x2))
    		 {	 System.out.println("cw");
    		 }
    		 else
    		 {
    			 System.out.println("undefined");
    	       }
    	 }
	      }
	 }
	}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastInput in = new FastInput(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastInput in, PrintWriter out) {
            char start = in.next().charAt(0);
            char end = in.next().charAt(0);
            int n = in.nextInt();

            char[] positions = {'v', '<', '^', '>'};

            int p = -1;
            for (int i = 0; i < positions.length; ++i) {
                if (start == positions[i]) {
                    p = i;
                    break;
                }
            }

            char cw = positions[(p + n) % positions.length];
            char ccw = positions[Math.abs(p - n) % positions.length];

            if (cw == end && ccw == end) {
                out.print("undefined");
            } else if (cw == end) {
                out.print("cw");
            } else {
                out.print("ccw");
            }
        }

    }

    static class FastInput {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public FastInput(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

import java.io.*;
import java.util.*;
import java.math.*;

/**
 *
 * @author ghost
 */
public class A {

    public static void main(String args[])
    {

        //File file= new File("COMPLETE_FILE_PATH");
        //InputStream is = new FileInputStream(file);

        //InputReader in = new InputReader(is);
        InputReader in = new InputReader(System.in);
        PrintWriter out= new PrintWriter(System.out);

        int t=1;
        Task solver=new Task();
        solver.solve(t,in,out);
        out.flush();

        out.close();

    }

    static class Task {
        long mod = 1000000007;

        public void solve(int testNumber, InputReader in,PrintWriter out){
            int c1=(int)(in.next().charAt(0));
            int c2=(int)(in.next().charAt(0));

            int pos1=position(c1);
            int pos2=position(c2);
            int n=in.nextInt();

            if(pos1%2==0 && pos2%2==0){
                out.println("undefined");
                return ;
            }

            int diff=(pos2-pos1);

            if(diff<0){
                if(Math.abs(diff)%4==n%4){
                    out.println("ccw");
                    }
                else if((diff%4) + 4==n%4)
                    out.println("cw");

            }
            else{
                if(diff%4==n%4) out.println("cw");
                else if((Math.abs(diff%4-4))==n%4) out.println("ccw");
            }

        }
        int position(int num){
            if(num==118) return 0;
            if(num==60) return 1;
            if(num==94) return 2;
            if(num==62) return 3;
            return 0;
        }

        int LOG2(long item){
            int count=0;
            while(item>1){
                item>>=1;count++;
            }
            return count;
        }

        long gcd(long a, long b) {
            a = Math.abs(a);
            b = Math.abs(b);
            return BigInteger.valueOf(a).gcd(BigInteger.valueOf(b)).longValue();
        }
    }

    static class InputReader {

        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int snext() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public String readString() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = snext();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public String next() {
            return readString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }

        private static void pa(Object... o) {
            System.out.println(Arrays.deepToString(o));
        }
    }

}

import java.util.Scanner;

public class R426A {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String c1 = scan.next(), c2 = scan.next(); scan.nextLine();
		int n = scan.nextInt();
		int i1, i2;
		if(c1.equals("^")) i1=1;
		else if(c1.equals(">")) i1=2;
		else if(c1.equals("v")) i1=3;
		else i1=4;

		if(c2.equals("^")) i2=1;
		else if(c2.equals(">")) i2=2;
		else if(c2.equals("v")) i2=3;
		else i2=4;

		if(Math.abs(i2-i1)!=n) {System.out.println("undefined"); return;}
		else if(Math.abs(i2-i1)==2&&n%2==0) {System.out.println("undefined"); return;}

		else if(n==1) System.out.println("cw");
		else System.out.println("ccw");
	}
}

import java.util.Scanner;
public class apa{
    public static void main(String args[]){
        long x,y,z,n;
        x=0;
        y=0;
        Scanner sc=new Scanner(System.in);
        char c1=sc.next().charAt(0);
        char c2=sc.next().charAt(0);
        n=sc.nextLong();
        if(c1=='^'){
            x=1;
        }
        if(c1=='^'){
            x=1;
        }
        if(c1=='>'){
            x=2;
        }
        if(c1=='v'){
            x=3;
        }
        if(c1=='<'){
            x=4;
        }
        if(c2=='^'){
            y=1;
        }
        if(c2=='>'){
            y=2;
        }
        if(c2=='v'){
            y=3;
        }
        if(c2=='<'){
            y=4;
        }
        z=n%4;
        if(z==0){
            z=4;
        }
        if((x-y==2 || y-x==2) && n%4==2){
            System.out.println("undefined");
        }
        else if(x-y==z || 4+x-y==z){
            System.out.println("ccw");
        }
        else{
            System.out.println("cw");
        }
    }
}

import java.util.*;
public class Solution {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		String o=in.next(),t=in.next();
		int n=in.nextInt()%4;
		int oi=0,ti=0;
		switch (o){
			case "^":
				oi=0;
				break;
			case ">":
				oi=1;
				break;
			case "v":
				oi=2;
				break;
			default:
				oi=3;
		}
		switch (t){
			case "^":
				ti=0;
				break;
			case ">":
				ti=1;
				break;
			case "v":
				ti=2;
				break;
			default:
				ti=3;
		}
		int cw=ti-oi,ccw=oi-ti;
		if (((cw==-ccw)&&(Math.abs(cw)==2))||(cw==ccw)){System.out.println("undefined");return;}
		if ((ti-oi)==n){
			System.out.println("cw");
		}else if ((oi-ti)==n) {
			System.out.println("ccw");
		}
		in.close();
	}
}

import java.util.Scanner;

public class First {

	public static void main(String[] args) {

		Scanner input = new Scanner(System.in);

		String[] shape = new String[2];
		for (int i = 0; i < shape.length; i++)
			shape[i]=input.next();
		int num = input.nextInt();
		String[] s = new String[4];
		s[0]="v";
		s[1]="<";
		s[2]="^";
		s[3]=">";
		int j = 0;
		for (; j < s.length; j++) {
			if(s[j].equals(shape[0]))
				break;
		}

		num%=4;

		String targetR = "";
		for (int i = 1; i <=num; i++) {
			if(j+i>3){
				targetR=s[j+i-4];
			}
			else
			targetR=s[j+i];
		}

		String targetL="";
		for (int i = 1; i <=num; i++) {
			if(j-i<0){
				targetL=s[j-i+4];
			}
			else
			targetL=s[j-i];
		}

		System.out.println(targetR);
		System.out.println(targetL);
		if(targetR.equals(shape[1])&&targetL.equals(shape[1]))
			System.out.println("undefined");
		else if(targetR.equals(shape[1]))
			System.out.println("cw");
		else if(targetL.equals(shape[1]))
		System.out.println("ccw");
		else
			System.out.println("undefined");

	}

}

import java.util.*;
public class Test {
    public static void main(String[] args) {
    Scanner input=new Scanner(System . in );
    char []a={'^','>','v','<'};

    char c1=input.next().charAt(0),c2=input.next().charAt(0);
    int n=input.nextInt();
        if (n%2==0) {
            System.out.println("undefined");
        }
        else{
            int i,k,m=0;
            for ( k = 0; k < 4; k++) {
                if (a[k]==c1) {
                    break;
                }
            }
            for ( i = 1; i <=n-(4*(n/4)) ; i+=1) {
                if (k+n-(4*(n/4))>4) {
                    m=k+n-(4*(n/4))-4;
                }
                if (a[m+k]==c2) {
                    System.out.println("cw");
                }else System.out.println("ccw");
            }
        }

    }}

import java.io.*;
import java.util.*;

public class TheUselessToy {

	public static void main(String []args) {

		Scanner in = new Scanner(System.in);
		String str = in.nextLine();
		String s[] = str.split(" ");
		int n = in.nextInt();
		String cw[] = {"v","<","^",">"};
		String ccw[] = {"v",">","^","<"};
		if((s[0].contentEquals("^")||s[0].contentEquals("v")) && (s[1].contentEquals("v")||s[1].contentEquals("^")))
			System.out.println("undefined");
		else if(n%4==0)
			System.out.println("undefined");
		else
		{
			String first = s[0];
			int var1 = 0, var2 = 0;
			for(int i=0;i<=3;i++)
			{
				if(first.equals(cw[i]))
					var1 = i;
				if(first.equals(ccw[i]))
					var2 = i;
			}
			int ans = 0;
			if(n%4==1)
			{
				ans = 1;
			}
			else if(n%4==2)
			{
				ans = 2;
			}
			else if(n%4==3)
			{
				ans = 3;
			}

			int ans1 = ans + var1;
			int ans2 = ans + var2;
			if(cw[ans1%4].contentEquals(s[1]))
				System.out.println("cw");
			else
				System.out.println("ccw");

		}
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author captainTurtle
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String a = in.next();
            String b = in.next();
            int n = in.nextInt();
            System.out.print(Ascii(a, b, n));

        }

        public static String Ascii(String x, String y, int time) {
            int a = x.charAt(0);
            int b = y.charAt(0);
            int sonuc = a - b;
            String cikti = "";
            if (a == 62) {
                if (time % 4 == 1) {
                    if (sonuc == 56) {
                        cikti = "cw";
                    }

                } else if (time % 4 == 2) {
                    if (sonuc == 2) {
                        cikti = "cw";
                    }
                } else if (time % 4 == 3) {
                    if (sonuc == (-32)) {
                        cikti = "cw";
                    }
                } else if (time % 4 == 0) {
                    if (sonuc == 0) {
                        cikti = "cw";
                    }
                } else {
                    cikti = "cww";
                }
            }
            if (a == 118) {
                if (time % 4 == 1) {
                    if (sonuc == 58) {
                        cikti = "cw";
                    }
                } else if (time % 4 == 2) {
                    if (sonuc == 24) {
                        cikti = "cw";
                    }
                } else if (time % 4 == 3) {
                    if (sonuc == 56) {
                        cikti = "cw";
                    }
                } else if (time % 4 == 0) {
                    if (sonuc == 0) {
                        cikti = "cw";
                    }
                } else {
                    cikti = "cww";
                }

            }
            if (a == 60) {
                if (time % 4 == 1) {
                    if (sonuc == (-34)) {
                        cikti = "cw";
                    }
                } else if (time % 4 == 2) {
                    if (sonuc == (-2)) {
                        cikti = "cw";
                    }
                } else if (time % 4 == (-58)) {
                    if (sonuc == (-32)) {
                        cikti = "cw";
                    }
                } else if (time % 4 == 0) {
                    if (sonuc == 0) {
                        cikti = "cw";
                    }
                } else {
                    cikti = "cww";
                }
            }
            if (a == 94) {
                if (time % 4 == 1) {
                    if (sonuc == 32) {
                        cikti = "cw";
                    }
                } else if (time % 4 == (-24)) {
                    if (sonuc == 2) {
                        cikti = "cw";
                    }
                } else if (time % 4 == 3) {
                    if (sonuc == 34) {
                        cikti = "cw";
                    }
                } else if (time % 4 == 0) {
                    if (sonuc == 0) {
                        cikti = "cw";
                    }

                } else if (time > 4) {
                    cikti = "undefined";
                }
            }

            return cikti;
        }

    }
}

import java.util.*;
public class Test {
    public static void main(String[] args) {
    Scanner input=new Scanner(System . in );
    char []a={'^','>','v','<'};

    char c1=input.next().charAt(0),c2=input.next().charAt(0);
    int n=input.nextInt();
        if (n%2==0) {
            System.out.println("undefined");
        }
        else{
            int k ;
        for ( k = 0; k < 4; k++) {
            if (c1==a[k]) {
                break;
            }
        }

            if ((a[k]+=(int)(Math.ceil(n/4.0)))==c2) {
                System.out.println("cw");
            }
            else System.out.println("ccw");
}
 }}

import java.util.*;
import java.io.*;

public class useless{
	public static void main(String[] args) throws IOException {
		BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
		String[] spin = read.readLine().split(" ");
		String[] cosa = {"v",">","^","<"};
		int n = Integer.parseInt(read.readLine());
		if(n%2 == 0)System.out.println("undefined");
		else{
			if(spin[0].equals(cosa[0])){
				if(cosa[n%4].equals(spin[1])) System.out.println("cw");
				else System.out.println("ccw");
			}
			else if(spin[0].equals(cosa[1])){
				if(cosa[(n+1)%4].equals(spin[1])) System.out.println("cw");
				else System.out.println("ccw");
			}
			else if(spin[0].equals(cosa[2])){
				if(cosa[(n+2)%4].equals(spin[1])) System.out.println("cw");
				else System.out.println("ccw");
			}
			else{
				if(cosa[(n+3)%4].equals(spin[1])) System.out.println("cw");
				else System.out.println("ccw");
			}
		}
	}
}

import java.util.Scanner;
public class apa{
    public static void main(String args[]){
        long x,y,z,n;
        x=0;
        y=0;
        Scanner sc=new Scanner(System.in);
        char c1=sc.next().charAt(0);
        char c2=sc.next().charAt(0);
        n=sc.nextLong();
        if(c1=='^'){
            x=1;
        }
        if(c1=='^'){
            x=1;
        }
        if(c1=='>'){
            x=2;
        }
        if(c1=='v'){
            x=3;
        }
        if(c1=='<'){
            x=4;
        }
        if(c2=='^'){
            y=1;
        }
        if(c2=='>'){
            y=2;
        }
        if(c2=='v'){
            y=3;
        }
        if(c2=='<'){
            y=4;
        }
        z=n%4;
        if(z==0){
            z=4;
        }
        if((x-y==2 || y-x==2) && n%4==2){
            System.out.println("undefined");
        }
        else if(x-y==z){
            System.out.println("ccw");
        }
        else{
            System.out.println("cw");
        }
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String in = br.readLine();
		int n = Integer.parseInt(br.readLine());
		switch(in.charAt(0)) {
		case '<':
			switch(in.charAt(1)) {
			case '<': System.out.println("undefined"); break;
			case '^': if(n%4==1)
						System.out.println("cw");
					  else {
						  if(n%4==3)
							  System.out.println("ccw");
						  else
							  System.out.println("undefined");
					  }
			          break;
			case '>': System.out.println("undefined");
			          break;
			case 'v': if(n%4==1)
						System.out.println("ccw");
					  else {
						  if(n%4==3)
							  System.out.println("cw");
						  else
							  System.out.println("undefined");
					  }
			          break;
			}
			break;

		case '^':
			switch(in.charAt(1)) {
			case '^': System.out.println("undefined"); break;
			case '>': if(n%4==1)
						System.out.println("cw");
					  else {
						  if(n%4==3)
							  System.out.println("ccw");
						  else
							  System.out.println("undefined");
					  }
			          break;
			case 'v': System.out.println("undefined");
			          break;
			case '<': if(n%4==1)
						System.out.println("ccw");
					  else {
						  if(n%4==3)
							  System.out.println("cw");
						  else
							  System.out.println("undefined");
					  }
			          break;
			}
			break;

		case '>':
			switch(in.charAt(1)) {
			case '<': System.out.println("undefined"); break;
			case 'v': if(n%4==1)
						System.out.println("cw");
					  else {
						  if(n%4==3)
							  System.out.println("ccw");
						  else
							  System.out.println("undefined");
					  }
			          break;
			case '>': System.out.println("undefined");
			          break;
			case '^': if(n%4==1)
						System.out.println("ccw");
					  else {
						  if(n%4==3)
							  System.out.println("cw");
						  else
							  System.out.println("undefined");
					  }
			          break;
			}
			break;

		case 'v':
			switch(in.charAt(1)) {
			case 'v': System.out.println("undefined"); break;
			case '<': if(n%4==1)
						System.out.println("cw");
					  else {
						  if(n%4==3)
							  System.out.println("ccw");
						  else
							  System.out.println("undefined");
					  }
			          break;
			case '^': System.out.println("undefined");
			          break;
			case '>': if(n%4==1)
						System.out.println("ccw");
					  else {
						  if(n%4==3)
							  System.out.println("cw");
						  else
							  System.out.println("undefined");
					  }
			          break;
			}
			break;
		}
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextChar();
            int b = in.nextChar();
            int ccw = 0;
            int cw = 0;

            if (a == 118) a = 1;
            if (a == 60) a = 2;
            if (a == 94) a = 3;
            if (a == 62) a = 4;

            if (b == 118) b = 1;
            if (b == 60) b = 2;
            if (b == 94) b = 3;
            if (b == 62) b = 4;

            int t = in.nextInt();
            t = t % 4;

            if (a < b) {
                cw = Math.abs(a - b);
                ccw = 4 - cw;
            } else {
                ccw = Math.abs(a - b);
                cw = 4 - ccw;
            }

            if (cw == t) {
                System.out.println("cw");
                return;
            } else if (ccw == cw) {
                System.out.println("undefined");
                return;
            } else if (ccw == t) {
                System.out.println("ccw");
                return;
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public char nextChar() {
            return next().charAt(0);
        }

    }
}

/**
 * Created by Helga on 7/31/2017.
 */
// v - 118, < - 60, ^ - 94, > - 62
import java.util.*;
public class Main {
    public static void main(String... args)
    {
        Scanner input=new Scanner(System.in);
        String buf=input.nextLine();
        int begginingPosition=(int)buf.charAt(0);
        int finalPosition=(int)buf.charAt(2);
        int seconds=input.nextInt();
        int begin=0;int end=0;
         int[] positions=new int[5];
         positions[0]=0;
         positions[1]=118;
         positions[2]=60;
         positions[3]=94;
         positions[4]=62;
         boolean beginDone=false,endDone=false;
         for(int i=1;i<=4;i++)
         {
             if(begginingPosition==positions[i])
             {
                 begin=i;
                 beginDone=true;
             }
             if(finalPosition==positions[i])
             {
                 end=i;
                 endDone=true;
             }
             if(beginDone&&endDone)
             {
                 break;
             }
         }
         int connection=seconds%4;
         if(connection==2||connection==0)
         {
             System.out.println("undefined");
             return;
         }
         int difference=end-begin;
         if(difference<0)
         {
             difference=-1*difference;
         }
         if (difference==connection)
         {
             System.out.println("cw");
         }
         else
         {
             System.out.println("ccw");
         }
        //System.out.println(begginingPosition+" "+finalPosition+" "+seconds+" "+connection+" "+end+" "+begin+" "+(end-begin));

    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class The_Useless_Toy {
	public static void main(String[] args)throws Throwable {
		BufferedReader bf = new BufferedReader(new InputStreamReader (System.in));
		PrintWriter pw = new PrintWriter(System.out, true);
		StringTokenizer st= new StringTokenizer(bf.readLine());
		int moves=Integer.parseInt(bf.readLine());
		String pos=st.nextToken();
		int pos1=pos.equals("^")? 1:pos.equals(">")? 2:pos.equals("v")? 3:4;
		pos=st.nextToken();
		int pos2=pos.equals("^")? 1:pos.equals(">")? 2:pos.equals("v")? 3:4;
		boolean cw=false;
		boolean ccw=false;
//		pw.println((pos1+(moves%4))%4+" "+(abs(pos1-(moves%4))));
		if((pos1+(moves%4))%4==pos2)
			cw=true;
		if(abs(pos1-(moves%4))==pos2)
			ccw=true;
		if(cw && !ccw)
			pw.print("cw");
		else if(ccw && !cw)
			pw.print("ccw");
		else
			pw.print("undefined");
		pw.close();
	}
	static int abs(int a)
	{
		while(a<=0)
			a+=4;
		return a;
	}
}

import java.io.*;
import java.util.*;

public class A {
    FScanner in = new FScanner();
    PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out), true);

    void run() {
        char c1 = in.next().charAt(0);
        char c2 = in.next().charAt(0);
        int x = -1, y = -1;
        if (c1 == '^')
            x = 1;
        else if (c1 == '>')
            x = 2;
        else if (c1 == 'v')
            x = 3;
        else if (c1 == '<')
            x = 4;
        if (c2 == '^')
            y = 1;
        else if (c2 == '>')
            y = 2;
        else if (c2 == 'v')
            y = 3;
        else if (c2 == '<')
            y = 4;
        int n = in.nextInt();
        int res = Math.abs(x % 4 - y % 4);
        String ans = "";
        if (res % n == 0)
            ans = "cw";
        else if ((4 - res ) % n == 0)
            ans = "ccw";
        if (res == 2 && n % 2 == 0)
            ans = "undefined";
        out.print(ans);
        out.close();
    }

    public static void main(String[] args){
        new A().run();
    }

    static class FScanner {
        BufferedReader br;
        StringTokenizer st;

        FScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

import java.util.Scanner;

public class R426A {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String c1 = scan.next(), c2 = scan.next(); scan.nextLine();
		int n = scan.nextInt();
		int i1, i2;
		if(c1.equals("^")) i1=1;
		else if(c1.equals(">")) i1=2;
		else if(c1.equals("v")) i1=3;
		else i1=4;

		if(c2.equals("^")) i2=1;
		else if(c2.equals(">")) i2=2;
		else if(c2.equals("v")) i2=3;
		else i2=4;

		if(Math.abs(i2-i1)==2&&n%2==0) {System.out.println("undefined"); return;}

		else if(n==1) System.out.println("cw");
		else System.out.println("ccw");
	}
}

import java.util.Scanner;

public class R426A {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String c1 = scan.next(), c2 = scan.next(); scan.nextLine();
		int n = scan.nextInt();
		int i1, i2;
		if(c1.equals("^")) i1=1;
		else if(c1.equals(">")) i1=2;
		else if(c1.equals("v")) i1=3;
		else i1=4;

		if(c2.equals("^")) i2=1;
		else if(c2.equals(">")) i2=2;
		else if(c2.equals("v")) i2=3;
		else i2=4;

		if(Math.abs(i2-i1)!=n) {System.out.println("undefined"); return;}
		else if(Math.abs(i2-i1)==2&&n%2==0) {System.out.println("undefined"); return;}

		else if(n==1) System.out.println("cw");
		else System.out.println("ccw");
	}
}

//package year;

import java.io.*;
import java.util.*;

public class prac {
	static PrintWriter out=new PrintWriter(System.out);
	public static void main(String[] args) {

		InputReader in=new InputReader(System.in);
	String str=in.readString();
	String str2=in.readString();
	//System.out.println(str+" "+str2);
	int n=in.nextInt();
	boolean cc=false;
	boolean cw=false;
	int s=0;
	int e=0;
	if((int)str.charAt(0)==118){
		s=0;
	}
	if((int)str.charAt(0)==60){
		s=1;
	}
	if((int)str.charAt(0)==94){
		s=2;
	}
	if((int)str.charAt(0)==62){
		s=3;
	}if((int)str2.charAt(0)==118){
		e=0;
	}
	if((int)str2.charAt(0)==60){
		e=1;
	}if((int)str2.charAt(0)==94){
		e=2;
	}if((int)str2.charAt(0)==62){
		e=3;
	}
	if((s+n)%4==e)
		cc=true;
	if((e+n)%4==s){
		cw=true;
	}
	//System.out.println(s+" "+e);
	if(cc&&cw){
		out.println("undefined");
	}
	else{
		if(cc){
			out.println("cc");
		}
		else{
			out.println("ccw");
		}
	}

	//out.println(t);
	out.close();

	}

	public static class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;

		public InputReader(InputStream st) {
			this.stream = st;
		}

		public int read() {
			/* internless */

			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public double nextDouble() {
			String doub = readString();
			return Double.parseDouble(doub);
		}

		public float nextFloat() {
			String doub = readString();
			return Float.parseFloat(doub);
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] sieve(int n) {
			int ar[] = new int[n + 1];
			ar[0] = 0;
			ar[1] = 1;
			for (int i = 2; i < ar.length; i++) {
				if (ar[i] == 0) {
					for (int k = i; k < ar.length; k = k + i) {
						if (ar[k] == 0) {
							ar[k] = i;
						}
					}
				}
			}
			return ar;
		}

		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}

		public Long[] nextLongArray(int n) {
			Long a[] = new Long[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextLong();
			}
			return a;
		}

		public ArrayList<ArrayList<Integer>> initlist(int n) {
			ArrayList<ArrayList<Integer>> list = new ArrayList<>();
			for (int i = 0; i <= n; i++) {
				list.add(new ArrayList<Integer>());
			}
			return list;
		}

		public int[] initdp(int n) {
			int ar[] = new int[n];
			for (int i = 0; i < n; i++) {
				ar[i] = -1;
			}
			return ar;
		}

		public int[][] initdp(int n, int m) {
			int ar[][] = new int[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++)
					ar[i][j] = -1;
			}
			return ar;
		}

		public char[] constring(String str) {
			char[] ar = new char[str.length()];
			for (int i = 0; i < str.length(); i++) {
				ar[i] = str.charAt(i);

			}
			return ar;
		}

		public static long gcd(long a, long b) {
			a = Math.abs(a);
			b = Math.abs(b);
			while (b != 0) {
				long temp = a % b;
				a = b;
				b = temp;
			}
			return a;
		}

		public static int longCompare(long a, long b) {
			if (a < b) {
				return -1;
			}
			if (a > b) {
				return 1;
			}
			return 0;
		}

		public String readString() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}
}

import java.util.Scanner;
public class apa{
    public static void main(String args[]){
        long x,y,z,n;
        x=0;
        y=0;
        Scanner sc=new Scanner(System.in);
        char c1=sc.next().charAt(0);
        char c2=sc.next().charAt(0);
        n=sc.nextLong();
        if(c1=='^'){
            x=1;
        }
        if(c1=='^'){
            x=1;
        }
        if(c1=='>'){
            x=2;
        }
        if(c1=='v'){
            x=3;
        }
        if(c1=='<'){
            x=4;
        }
        if(c2=='^'){
            y=1;
        }
        if(c2=='>'){
            y=2;
        }
        if(c2=='v'){
            y=3;
        }
        if(c2=='<'){
            y=4;
        }
        z=n%4;
        if(z==0){
            z=4;
        }
        if(x==y && n==0){
            System.out.println("undefined");
        }
        else if((x-y==2 || y-x==2) && n%4==2){
            System.out.println("undefined");
        }
        else if(x-y==z || 4+x-y==z){
            System.out.println("ccw");
        }
        else{
            System.out.println("cw");
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class UselessToys {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] p = in.readLine().split(" ");
		int n = Integer.parseInt(in.readLine());
		char a = p[0].charAt(0);
		char b = p[1].charAt(0);
		int aa = 0;
		int bb = 0;
		if(a=='^') {
			aa = 1;
		} else if(a == '>') {
			aa = 2;
		} else if(a == 'v') {
			aa = 3;
		} else {
			aa = 4;
		}
		if(b=='^') {
			bb = 1;
		} else if(b == '>') {
			bb = 2;
		} else if(b == 'v') {
			bb = 3;
		} else {
			bb = 4;
		}

		int x = Math.abs(aa-bb);
		if(x % 2 == 0) {
			System.out.println("undefined");
		} else {
			if(bb > aa) {
				if(bb -aa == n) {
					System.out.println("cw");
				} else {
					System.out.println("ccw");
				}
			} else {
				if(aa - bb == n) {
					System.out.println("ccw");
				} else {
					System.out.println("cw");
				}
			}
		}

	}
}

import java.util.Scanner;

public class Spinner {
	private static Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		Spinner s = new Spinner();
		String answer = new String();
		SpinPosition initialPosition = s.new SpinPosition(in.next().charAt(0));
		SpinPosition finalPosition = s.new SpinPosition(in.next().charAt(0));
		long time = in.nextLong();
		time %= 4;
		int clockWise = Math.abs(finalPosition.positionOrder - initialPosition.positionOrder);
		int counterCW = 4 -Math.abs(finalPosition.positionOrder - initialPosition.positionOrder);
		if(time == 0 || clockWise == counterCW)
		{
			answer = "undefined";
		}
		else
		{
			if(time - clockWise == 0)
			{
				answer = "cw";
			}
			else if(time - counterCW == 0)
			{
				answer = "ccw";
			}
			else
			{
				answer = "undefined";
			}
		}
		System.out.println(answer);
	}

	public class SpinPosition
	{
		int positionOrder;
		char position;
		public SpinPosition(char x)
		{
			position = x;
			if(position == 'v')
			{
				positionOrder = 1;
			}else if(position == '<') {
				positionOrder = 2;
			}else if (position == '^') {
				positionOrder = 3;
			}else {
				positionOrder = 4;
			}
		}
	}

}

import java.io.*;
import java.util.*;

public class Main {

	void howUdoin() {

		String st=inps();

		char a='^',d='<',b='>',c='v';
		char s=st.charAt(0);
		st=inps();
		char e=st.charAt(0);
		int n=inpi();
		int f=0;
		double x,y;
		String ans="";
		if((s==a || s==c) && (e==a || e==c)){

			System.out.println("undifined");
			return;

		}
		else if((s==b || s==d) && (e==b || e==d)){
			System.out.println("undifined");
			return;
		}
		x=(double)(n+3)/4;
		y=(double)(n+1)/4;
		if(x-Math.floor(x)==0){
			f=1;
		}
		else if(y-Math.floor(y)==0){
			f=2;
		}
		else {
			System.out.println("undifined");
			return;
		}
		if(s==a){
			if((f==1 && e==b) || (f==2 && e==d)){
				ans="cw";
			}
			else{
				ans="ccw";
			}
		}
		else if(s==b){
			if((f==1 && e==c) || (f==2 && e==a)){
				ans="cw";
			}
			else{
				ans="ccw";
			}
		}
		else if(s==c){
			if((f==1 && e==d) || (f==2 && e==b)){
				ans="cw";
			}
			else{
				ans="ccw";
			}
		}
		else{
			if((f==1 && e==a) || (f==2 && e==c)){
				ans="cw";
			}
			else{
				ans="ccw";
			}
		}
		System.out.println(ans);

	}

	InputStream obj;
	PrintWriter out;
	String check = "";

	public static void main(String[] args) throws IOException {
		new Main().main1();
	}

	void main1() throws IOException {
		out = new PrintWriter(System.out);
		obj = check.isEmpty() ? System.in : new ByteArrayInputStream(check.getBytes());
		howUdoin();
		out.flush();
		out.close();
	}
	byte inbuffer[] = new byte[1024];
	int lenbuffer = 0, ptrbuffer = 0;

	int readByte() {
		if (lenbuffer == -1) {
			throw new InputMismatchException();
		}
		if (ptrbuffer >= lenbuffer) {
			ptrbuffer = 0;
			try {
				lenbuffer = obj.read(inbuffer);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
		}
		if (lenbuffer <= 0) {
			return -1;
		}
		return inbuffer[ptrbuffer++];
	}

	boolean isSpaceChar(int c) {
		return (!(c >= 33 && c <= 126));
	}

	int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b));
		return b;
	}

	String inps() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	String inpsl() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (b!='\n') {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	int inpi() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	long inpl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	float inpf() {
		return Float.parseFloat(inps());
	}

	double inpd() {
		return Double.parseDouble(inps());
	}

	char inpc() {
		return (char) skip();
	}

	int[] inpia(int n) {
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = inpi();
		}
		return a;
	}

	long[] inpla(int n) {
		long a[] = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = inpl();
		}
		return a;
	}

	String[] inpsa(int n) {
		String a[] = new String[n];
		for (int i = 0; i < n; i++) {
			a[i] = inps();
		}
		return a;
	}

}

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

    //StringTokenizer st=new StringTokenizer(br.readLine());
    //ArrayList<Integer> list = new ArrayList<Integer>();
    //int n=Integer.parseInt(st.nextToken());
    //Long n=Long.parseLong(st.nextToken());
    //long n=Long.parseLong(br.readLine());
    //int n=Integer.parseInt(br.readLine());
    //int n=scan.scanInt();
    /*int t=Integer.parseInt(br.readLine());
        for(;t!=0;t--){

        }*/

	public static void main (String[] args) throws java.lang.Exception
	{
	    Scan scan=new Scan();
		Print print=new Print();
		String inp1=scan.scanString();
		String inp2=scan.scanString();
		//inp2=scan.scanString();
		System.out.println(inp1+" "+inp2);
		int n=scan.scanInt();
		int start=(int)inp1.charAt(0);
		int end=(int)inp2.charAt(0);
		int p=0,e=0,i;
		if(start==118)p=1;

		if(start==60)p=2;

		if(start==94)p=3;

		if(start==62)p=4;

		if(end==118)e=1;

		if(end==60)e=2;

		if(end==94)e=3;

		if(end==62)e=4;

		int a,b;
		a=b=p;
		for(i=1;i<=n;i++)
		{
		    a++;
		    if(a>4)
		    a=1;
		}

		for(i=1;i<=n;i++)
		{
		    b--;
		    if(b<=0)
		    b=4;
		}
		if(e==a && e==b)
		System.out.println("undefined");

		else
		{
		    if(e==a)
		    System.out.println("cw");

		    else
		    System.out.println("ccw");
		}

	}
}
class Scan
{
	private byte[] buf=new byte[1024];
	private int index;
	private InputStream in;
	private int total;
	public Scan()
	{
		in=System.in;
	}
	public int scan()throws IOException
	{
		if(total<0)
		throw new InputMismatchException();
		if(index>=total)
		{
			index=0;
			total=in.read(buf);
			if(total<=0)
			return -1;
		}
		return buf[index++];
	}
	public int scanInt()throws IOException
	{
		int integer=0;
		int n=scan();
		while(isWhiteSpace(n))
		n=scan();
		int neg=1;
		if(n=='-')
		{
			neg=-1;
			n=scan();
		}
		while(!isWhiteSpace(n))
		{
			if(n>='0'&&n<='9')
			{
				integer*=10;
				integer+=n-'0';
				n=scan();
			}
			else throw new InputMismatchException();
		}
		return neg*integer;
	}
	public double scanDouble()throws IOException
	{
		double doub=0;
		int n=scan();
		while(isWhiteSpace(n))
		n=scan();
		int neg=1;
		if(n=='-')
		{
			neg=-1;
			n=scan();
		}
		while(!isWhiteSpace(n)&&n!='.')
		{
			if(n>='0'&&n<='9')
			{
				doub*=10;
				doub+=n-'0';
				n=scan();
			}
			else throw new InputMismatchException();
		}
		if(n=='.')
		{
			n=scan();
			double temp=1;
			while(!isWhiteSpace(n))
			{
				if(n>='0'&&n<='9')
				{
					temp/=10;
					doub+=(n-'0')*temp;
					n=scan();
				}
				else throw new InputMismatchException();
			}
		}
		return doub*neg;
	}
	public String scanString()throws IOException
	{
		StringBuilder sb=new StringBuilder();
		int n=scan();
		while(isWhiteSpace(n))
		n=scan();
		while(!isWhiteSpace(n))
		{
			sb.append((char)n);
			n=scan();
		}
		return sb.toString();
	}
	private boolean isWhiteSpace(int n)
	{
		if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
		return true;
		return false;
	}
}

class Print
{
	private final OutputStream out;
	/*public Print(OutputStream outputStream)
	{
		writer=new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}*/
	public Print()
	{
		this.out=System.out;
	}
	public void print(String str)throws IOException
	{
		//buf=str.getBytes();
		for (int i = 0; i < str.length(); i++)
		{
			/*if (i != 0)
			out.write(' ');*/
			out.write(str.charAt(i));
		}
	}
	public void printLine(String str)throws IOException
	{
		print(str);
		out.write('\n');
	}
	public void close()throws IOException
	{
		out.close();
	}
}

import java.util.Scanner;
import java.io.*;

public class Ass {
    public static void main(String args[])
    {
        try{
        Scanner sc=new Scanner(System.in);
        System.out.println("enter the initial position");
        String i=sc.nextLine();
        System.out.println("enter the final position");
        String f=sc.nextLine();
        System.out.println("enter the spin time");
        int t=sc.nextInt();
        int j=0,k=0;
        if(i.equals("^"))
        { j=0;}
        if(i.equals(">"))
        {j=1;}
        if(i.equals("v"))
        {   j=2;}
        if(i.equals("<"))
        { j=3;}
        if(f.equals("^"))
        { k=0;}
        if(f.equals(">"))
        { k=1;}
        if(f.equals("v"))
{           k=2;}
        if(f.equals("<"))
{k=3;}

        int sum=(j+t)%4;
         if(t%2==0)
                 {
                     System.err.println("undefined");
                 }
        else if(sum==k||sum==0)
         {
             System.out.println("cw");
         }

       else
             System.out.println("ccw");
        }

   catch(Exception ee){}

    } }

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import java.io.OutputStreamWriter;
import java.util.ArrayList;

public class tenth {

    public static void main(String args[]) throws Exception {
	String sp=br.readLine().trim();
	String ss[]=sp.split(" ");
	int t=input()%4,j=0,k=0;

	if(sp.charAt(0)=='^')
	    j=0;
	if(sp.charAt(0)=='>')
	    j=1;
	if(sp.charAt(0)=='<')
	    j=2;
	if(sp.charAt(0)=='v')
	    j=3;
	if(sp.charAt(2)=='^')
	    k=0;
	if(sp.charAt(2)=='>')
	    k=1;
	if(sp.charAt(2)=='<')
	    k=2;
	if(sp.charAt(2)=='v')
	    k=3;

		if(t==0||t==2){
	        System.out.print("undefined");

		}

		else if((j+t)%4==k){

	        System.out.print("cw");
	    }
	    else{
	      System.out.print("ccw");
	    }

	}

 static BufferedReader br = new BufferedReader(new InputStreamReader(
            System.in));
    private static String s[];

    public static void input(int a[], int p) throws IOException {
        s = br.readLine().split(" ");
        int i;
        for (i = 0; i < p; i++) {
            a[i] = Integer.parseInt(s[i]);
        }

    }

    public static void input(long a[], int p) throws IOException {
        s = br.readLine().split(" ");
        int i;
        for (i = 0; i < p; i++) {
            a[i] = Long.parseLong(s[i]);
        }
    }

    public static void input(double a[], int p) throws IOException {
        s = br.readLine().split(" ");
        int i;
        for (i = 0; i < p; i++) {
            a[i] = Double.parseDouble(s[i]);
        }
    }

    public static int input() throws IOException {
        int a;
        a = Integer.parseInt(br.readLine());
        return a;
    }

}

import java.util.Scanner;
public class P834A
{
	public static void main(String[] args)
	{
	 Scanner scan=new Scanner(System.in);
	 char i,f;
	 int n;
	 i=scan.next().charAt(0);
	 f=scan.next().charAt(0);
	 n=scan.nextInt();
	 n%=4;
	 if(n==0||n==2)
		System.out.println("Undefined");
	 else if(n==1)
		{
		 switch(i)
			{
			 case 'v': if(f=='<')
					System.out.println("cw");
				   else
					System.out.println("ccw");
				   break;
			 case '<': if(f=='^')
					System.out.println("cw");
				   else
					System.out.println("ccw");
				   break;
			 case '^': if(f=='>')
					System.out.println("cw");
				   else
					System.out.println("ccw");
				   break;
			 case '>': if(f=='v')
					System.out.println("cw");
				   else
					System.out.println("ccw");
				   break;
			}
		}
	 else
		{
		 switch(i)
			{
			 case 'v': if(f=='>')
					System.out.println("cw");
				   else
					System.out.println("ccw");
				   break;
			 case '<': if(f=='v')
					System.out.println("cw");
				   else
					System.out.println("ccw");
				   break;
			 case '^': if(f=='<')
					System.out.println("cw");
				   else
					System.out.println("ccw");
				   break;
			 case '>': if(f=='^')
					System.out.println("cw");
				   else
					System.out.println("ccw");
				   break;
			}
		}
	}
}

import java.util.*;
import java.io.*;
import java.lang.*;
public class A834 {
	private static long mod = 1000000007;

	public static void main(String[] args) {
		InputReader in=new InputReader(System.in);
		PrintWriter pw=new PrintWriter(System.out);

		String a=in.nextLine();
		char c1=a.charAt(0);
		char c2=a.charAt(2);
		long l=in.nextLong();
		int[] arr=new int[2];
		//pw.println(c1+" "+c2);
		if(c1=='^')
			arr[0]=0;
		else if(c1=='<')
			arr[0]=3;
		else if(c1=='>')
			arr[0]=1;
		else
			arr[0]=2;
		if(c2=='^')
			arr[1]=0;
		else if(c2=='<')
			arr[1]=3;
		else if(c2=='>')
			arr[1]=1;
		else
			arr[1]=2;
		l=l%4;
	//	pw.println(l);
		//pw.println(arr[1]+" "+arr[0]+" "+l);
		if(arr[1]>arr[0] &&(arr[1]-arr[0])==(4-l))
				pw.println("ccw");
		else if(arr[1]>arr[0] && Math.abs(arr[1]-arr[0])==l)
				pw.print("cw");
		else if(arr[1]<arr[0] && Math.abs(arr[1]-arr[0])==(4-l))
				pw.println("cw");
		else if(arr[1]<arr[0] && Math.abs(arr[1]-arr[0])==l)
			pw.println("ccw");

		else
			pw.println("undefined");

		pw.flush();
		pw.close();
	}

	static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}
		public long[] nextLongArray(int n) {
			long a[] = new long[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextLong();
			}
			return a;
		}

		public String readString() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}

	public static int[] suffle(int[] a,Random gen)
	{
		int n = a.length;
		for(int i=0;i<n;i++)
		{
			int ind = gen.nextInt(n-i)+i;
			int temp = a[ind];
			a[ind] = a[i];
			a[i] = temp;
		}
		return a;
	}

	public static void swap(int a, int b){
		int temp = a;
		a = b;
		b = temp;
	}

	public static ArrayList<Integer> primeFactorization(int n)
	{
		ArrayList<Integer> a =new ArrayList<Integer>();
		for(int i=2;i*i<=n;i++)
		{
			while(n%i==0)
			{
				a.add(i);
				n/=i;
			}
		}
		if(n!=1)
			a.add(n);
		return a;
	}

	public static void sieve(boolean[] isPrime,int n)
	{
		for(int i=1;i<n;i++)
			isPrime[i] = true;

		isPrime[0] = false;
		isPrime[1] = false;

		for(int i=2;i*i<n;i++)
		{
			if(isPrime[i] == true)
			{
				for(int j=(2*i);j<n;j+=i)
					isPrime[j] = false;
			}
		}
	}

	public static int GCD(int a,int b)
	{
		if(b==0)
			return a;
		else
			return GCD(b,a%b);
	}

	public static long GCD(long a,long b)
	{
		if(b==0)
			return a;
		else
			return GCD(b,a%b);
	}

	public static long LCM(long a,long b)
	{
		return (a*b)/GCD(a,b);
	}

	public static int LCM(int a,int b)
	{
		return (a*b)/GCD(a,b);
	}

	public static int binaryExponentiation(int x,int n)
	{
	    int result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=result * x;
	        x=x*x;
	        n=n/2;
	    }
	    return result;
	}

	public static long binaryExponentiation(long x,long n)
	{
	    long result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=result * x;
	        x=x*x;
	        n=n/2;
	    }
	    return result;
	}

	public static int modularExponentiation(int x,int n,int M)
	{
	    int result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=(result * x)%M;
	        x=(x*x)%M;
	        n=n/2;
	    }
	    return result;
	}

	public static long modularExponentiation(long x,long n,long M)
	{
	    long result=1;
	    while(n>0)
	    {
	        if(n % 2 ==1)
	            result=(result * x)%M;
	        x=(x*x)%M;
	        n=n/2;
	    }
	    return result;
	}

	public static int modInverse(int A,int M)
	{
	    return modularExponentiation(A,M-2,M);
	}

	public static long modInverse(long A,long M)
	{
	    return modularExponentiation(A,M-2,M);
	}

	public static boolean isPrime(int n)
	{

	    if (n <= 1)  return false;
	    if (n <= 3)  return true;

	    if (n%2 == 0 || n%3 == 0)
	    	return false;

	    for (int i=5; i*i<=n; i=i+6)
	    {
	        if (n%i == 0 || n%(i+2) == 0)
	           return false;
	    }

	    return true;
	}

	static class pair implements Comparable<pair>
	{
		Integer x, y;
		pair(int x,int y)
		{
			this.x=x;
			this.y=y;
		}

		public int compareTo(pair o) {
			int result = x.compareTo(o.x);
			if(result==0)
				result = y.compareTo(o.y);

			return result;
		}
	}
}

import java.io.*;
import java.util.*;

public class A {
    FScanner in = new FScanner();
    PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out), true);

    void run() {
        char c1 = in.next().charAt(0);
        char c2 = in.next().charAt(0);
        int x = -1, y = -1;
        if (c1 == '^')
            x = 1;
        else if (c1 == '>')
            x = 2;
        else if (c1 == 'v')
            x = 3;
        else if (c1 == '<')
            x = 4;
        if (c2 == '^')
            y = 1;
        else if (c2 == '>')
            y = 2;
        else if (c2 == 'v')
            y = 3;
        else if (c2 == '<')
            y = 4;
        int n = in.nextInt() % 4;
        int res = Math.abs(x % 4 - y % 4);
        String ans = "";
        if (n % 2 == 0)
            ans = "undefined";
        else if (res % n == 0)
            ans = "cw";
        else if ((4 - res) % n == 0)
            ans = "ccw";
        out.print(ans);
        out.close();
    }

    public static void main(String[] args){
        new A().run();
    }

    static class FScanner {
        BufferedReader br;
        StringTokenizer st;

        FScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

import java.util.*;
public class test{
	public static void main(String[] args) {
		Scanner ob=new Scanner(System.in);

		char c1=ob.next(".").charAt(0);
		char c2=ob.next(".").charAt(0);
		ob.nextLine();
		int n=ob.nextInt();
		if(n>3){
			n=n%4;
		}
		int start_position=0;
		char arr[]={'v','<','^','>'};
		for(int i=0;i<arr.length;i++){
			if(c1==arr[i]){
				start_position=i;
				break;
			}
		}
		int clock_position=n+start_position;
		int anticlock_position=Math.abs(n-start_position);

		if(clock_position>=4)
			clock_position=clock_position%4;

		if(arr[clock_position]==c2 && arr[anticlock_position]==c2)
			System.out.println("undefined");
		else if(arr[clock_position]==c2)
			System.out.println("cw");
		else
			System.out.println("ccw");

	}
}

import java.util.Scanner;

public class C426A {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String start = scanner.next();
        int st;
        String end = scanner.next();
        int en;
        int seconds = scanner.nextInt();

        switch (start) {
            case "^":
                st = 0;
                break;
            case ">":
                st = 1;
                break;
            case "v":
                st = 2;
                break;
            default:
                st = 3;
                break;
        }

        switch (end) {
            case "^":
                en = 0;
                break;
            case ">":
                en = 1;
                break;
            case "v":
                en = 2;
                break;
            default:
                en = 3;
                break;
        }

        int enC = (st + seconds) % 4;
        int  enCC = (((st - seconds) % 4) + 4) % 4;

        if (enC == en) System.out.println("cw");
        else if (enCC == en) System.out.println("ccw");
        else System.out.println("undefined");
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class The_Useless_Toy {
	public static void main(String[] args)throws Throwable {
		BufferedReader bf = new BufferedReader(new InputStreamReader (System.in));
		PrintWriter pw = new PrintWriter(System.out, true);
		StringTokenizer st= new StringTokenizer(bf.readLine());
		int moves=Integer.parseInt(bf.readLine());
		String pos=st.nextToken();
		int pos1=pos.equals("^")? 1:pos.equals(">")? 2:pos.equals("v")? 3:4;
		pos=st.nextToken();
		int pos2=pos.equals("^")? 1:pos.equals(">")? 2:pos.equals("v")? 3:4;
		boolean cw=false;
		boolean ccw=false;
//		pw.println((pos1+(moves%4))%4+" "+(abs(pos1-(moves%4))));
		if((pos1+(moves%4))%4==pos2)
			cw=true;
		if(abs(pos1-(moves%4))==pos2)
			ccw=true;
		if(cw && !ccw)
			pw.print("cw");
		else if(ccw && !cw)
			pw.print("ccw");
		else
			pw.print("undefined");
		pw.close();
	}
	static int abs(int a)
	{
		while(a<=0)
			a+=4;
		return a;
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CF426A {
	public static void main(String[] args) {
		char map[] = new char[256];
		map['v'] = 0;
		map['<'] = 1;
		map['^'] = 2;
		map['>'] = 3;
		MyScanner in = new MyScanner();
		char start = in.next().charAt(0);
		char end = in.next().charAt(0);
		int n = in.nextInt();
		if (Math.abs(map[start] - map[end]) == 2) {
			System.out.println("undefined");
		} else {
			if ((map[start] + n) % 4 == map[end]) {
				System.out.println("cw");
			} else {
				System.out.println("ccw");
			}
		}
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Solution {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FastScanner sc = new FastScanner();
		HashMap<Integer, Character> angles = new HashMap<Integer, Character>();
		angles.put(0,'v');
		angles.put(1,'<');
		angles.put(2,'^');
		angles.put(3,'>');

		HashMap<Character,Integer> angles2 = new HashMap<Character,Integer>();
		angles2.put('v',0);
		angles2.put('<',1);
		angles2.put('^',2);
		angles2.put('>',3);
		boolean cw_check = false;
		boolean ccw_check = false;

		char start_pos = sc.nextToken().charAt(0);
		char end_pos = sc.nextToken().charAt(0);
		int sec = sc.nextInt();
		sec = sec%4;

		if(angles2.get(start_pos)+sec<=3 && angles2.get(start_pos)+sec>=0 && end_pos == angles.get(angles2.get(start_pos)+sec)){
			cw_check = true;
		}
		if(angles2.get(start_pos)-sec+4>=0 && angles2.get(start_pos)-sec+4<=3 && end_pos == angles.get(angles2.get(start_pos)-sec+4)){
			ccw_check = true;
		}
		if((cw_check && ccw_check) || (!cw_check && !ccw_check)){
			System.out.println("undefined");
		}
		else if(cw_check){
			System.out.println("cw");
		}
		else
			System.out.println("ccw");

    }
	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}
}

import java.io.BufferedReader;
import java.util.*;
import java.io.InputStreamReader;
import java.util.Arrays;

public class tesst {
	public static void main(String args[])throws Exception {
		Scanner in = new Scanner(System.in);
		char s1 = in.next().charAt(0);
		char s2 = in.next().charAt(0);
		int n = in.nextInt() %4;
		if(n % 4 == 2) {
			System.out.println("undefined");
			return;
		}
		char cw[] = {'^', '>', 'v', '<'};
		char ccw[] = {'^', '<', 'v', '>'};
		int result =0;
		int result2=0;
		for(int i=0; i<4; i++) {
			if(s1 == cw[i]) {
				result = i+n;
				if(result >=4) {
					result -=4;
				}
				if(s2 == cw[result]) {
					System.out.println("cw");
					return;
				}
			}
			if(s1 == ccw[i]) {
				result2 = i+n;
				if(result2 >=4) {
					result2 -=4;
				}
				if(s2 == ccw[result2]) {
					System.out.println("ccw");
					return;
				}
			}
		}
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author kucingterbang
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A834 solver = new A834();
        solver.solve(1, in, out);
        out.close();
    }

    static class A834 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int s = 0;
            int e = 0;
            char start = in.nextCharacter();
            char end = in.nextCharacter();
            int n = in.nextInt();
            switch (start) {
                case '^':
                    s = 1;
                    break;
                case '>':
                    s = 2;
                    break;
                case 'v':
                    s = 3;
                    break;
                case '<':
                    s = 4;
                    break;
            }
            switch (end) {
                case '^':
                    e = 1;
                    break;
                case '>':
                    e = 2;
                    break;
                case 'v':
                    e = 3;
                    break;
                case '<':
                    e = 4;
                    break;
            }
            if (n > 0) {
                if ((4 + e - s) % 4 == n % 4 && 4 - (4 + e - s) % 4 == n % 4) out.print("undefined");
                else if ((4 + e - s) % 4 == n % 4) out.print("cw");
                else if (4 - (4 + e - s) % 4 == n % 4) out.print("ccw");
            } else {
                out.print("cw");
            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public char nextCharacter() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            return (char) c;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

import java.util.Scanner;

public class R426A {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String c1 = scan.next(), c2 = scan.next(); scan.nextLine();
		int n = scan.nextInt();
		int i1, i2;
		if(c1.equals("^")) i1=1;
		else if(c1.equals(">")) i1=2;
		else if(c1.equals("v")) i1=3;
		else i1=4;

		if(c2.equals("^")) i2=1;
		else if(c2.equals(">")) i2=2;
		else if(c2.equals("v")) i2=3;
		else i2=4;

		if(Math.abs(i2-i1)==2&&n%2==0) {System.out.println("undefined"); return;}

		else if(n==1) System.out.println("cw");
		else System.out.println("ccw");
	}
}

import java.util.*;

public class Darshjava
{
    public static void main(String args [])
    {
        Scanner enter = new Scanner (System.in) ;
        char s = enter.next().charAt(0) , e = enter.next().charAt(0) ;
        int n = enter.nextInt();
        if(n % 4 == 2 && s == 118 && e == 94) System.out.println("undefined");
        else if (n % 4 == 2 && s == 94 && e == 118) System.out.println("undefined");
        else if (n % 4 == 2 && s == 60 && e == 62) System.out.println("undefined");
        else if (n % 4 == 2 && s == 62 && e == 60) System.out.println("undefined");
        else if (n % 4 == 1 && s == 94 && e == 60) System.out.println("ccw");
        else if (n % 4 == 1 && s == 94 && e == 62) System.out.println("cw");
        else if (n % 4 == 1 && s == 118 && e == 60) System.out.println("cw");
        else if (n % 4 == 1 && s == 118 && e == 62) System.out.println("ccw");
        else if (n % 4 == 1 && s == 60 && e == 118) System.out.println("ccw");
        else if (n % 4 == 1 && s == 60 && e == 94) System.out.println("cw");
        else if (n % 4 == 1 && s == 62 && e == 118) System.out.println("cw");
        else if (n % 4 == 1 && s == 62 && e == 94) System.out.println("ccw");
        else if (n % 4 == 3 && s == 94 && e == 60) System.out.println("cw");
        else if (n % 4 == 3 && s == 94 && e == 62) System.out.println("ccw");
        else if (n % 4 == 3 && s == 118 && e == 60) System.out.println("ccw");
        else if (n % 4 == 3 && s == 118 && e == 62) System.out.println("cw");
        else if (n % 4 == 3 && s == 60 && e == 118) System.out.println("cw");
        else if (n % 4 == 3 && s == 60 && e == 94) System.out.println("ccw");
        else if (n % 4 == 3 && s == 62 && e == 118) System.out.println("cw");
        else if (n % 4 == 3 && s == 62 && e == 94) System.out.println("ccw");
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author captainTurtle
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String a = in.next();
            String b = in.next();
            int n = in.nextInt();
            String c = Ascii(a, b, n);
            System.out.println(c);
            System.out.flush();
            in.close();

        }

        public static String Ascii(String x, String y, int time) {
            int a = x.charAt(0);
            int b = y.charAt(0);
            int sonuc = a - b;
            String cikti = "";
            if (a == 62) {
                if (time % 4 == 1) {
                    if (sonuc == (-56)) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }

                } else if (time % 4 == 2 || time % 4 == 0) {
                    cikti = "undefined";
                } else if (time % 4 == 3) {
                    if (sonuc == (-32)) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                }

            }
            if (a == 118) {

                if (time % 4 == 1) {
                    if (sonuc == 58) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }

                } else if (time % 4 == 2 || time % 4 == 0) {
                    cikti = "undefined";
                } else if (time % 4 == 3) {
                    if (sonuc == 56) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                }

            }
            if (a == 60) {
                if (time % 4 == 1) {
                    if (sonuc == (-34)) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                } else if (time % 4 == 2 || time % 4 == 0) {

                    cikti = "cw";

                } else if (time % 4 == 3) {
                    if (sonuc == (-32)) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                }

            }
            if (a == 94) {
                if (time % 4 == 1) {
                    if (sonuc == 32) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }

                } else if (time % 4 == 2 || time % 4 == 0) {

                    cikti = "undefined";

                } else if (time % 4 == 3) {
                    if (sonuc == 34) {
                        cikti = "cw";
                    } else {
                        cikti = "ccw";
                    }
                }

            }

            return cikti;
        }

    }
}

import java.util.*;
import java.io.*;

public final class Main {

    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        char firstChar = Character.valueOf(st.nextToken().charAt(0));
        char secondChar = Character.valueOf(st.nextToken().charAt(0));

        st = new StringTokenizer(br.readLine());
        int numRotations = Integer.parseInt(st.nextToken());

        int start = 0;

        switch (firstChar){
            case '^':
                start = 1;
                break;
            case '>':
                start = 2;
                break;
            case 'v':
                start = 3;
                break;
            case '<':
                start = 4;
                break;
        }

        int end = 0;

        switch (secondChar){
            case '^':
                end = 1;
                break;
            case '>':
                end = 2;
                break;
            case 'v':
                end = 3;
                break;
            case '<':
                end = 4;
                break;
        }

        //System.out.println(start + " " + end);
        int clockWiseRotations = 0;
        int cclockWiseRotations = 0;

        int startChar = start;
        int endChar = end;
        for(int i = 0; i<4; i++){
                if(startChar!=endChar){
                    clockWiseRotations++;
                }else{
                    break;
                }
                startChar += 1;
                startChar %= 5;
        }

        //System.out.println(start + " " + end);
        startChar = start;
        for(int i = 0; i<4; i++){
            if(startChar!=endChar){
                cclockWiseRotations++;
            }else{
                break;
            }
            startChar -= 1;
            if(startChar == 0) {
                startChar = 4;
            }
        }

        numRotations %= 4;

        //System.out.println(clockWiseRotations + " "  + cclockWiseRotations);

        if(numRotations != clockWiseRotations && numRotations != cclockWiseRotations || numRotations == 2){
            pw.println("undefined");
            pw.close();
            return;
        }

        if(numRotations == clockWiseRotations){
            pw.println("cw");
            pw.close();
            return;
        }else{
            pw.println("ccw");
            pw.close();
            return;
        }

    }
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class A {
	public static void main(String[] args) throws IOException {
		File inputFile = new File("entrada");
		if (inputFile.exists())
			System.setIn(new FileInputStream(inputFile));
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder out = new StringBuilder();
		String line;
		char[] spin = new char[256];
		spin['^'] = 0; spin['>'] = 1; spin['v'] = 2; spin['<'] = 3;
		spin[0] = '^'; spin[1] = '>'; spin[2] = 'v'; spin[3] = '<';
		while ((line = in.readLine()) != null) {
			String[] w = line.trim().split(" ");
			int n = Integer.parseInt(in.readLine().trim());
			if(n == 0) out.append("undefined\n");
			else{
				int a = spin[w[0].charAt(0)], b = spin[w[1].charAt(0)];
				int dif = 4 + (a + b) % 4;
				boolean cw = true, ccw = true;
				cw &= spin[b] == spin[(a + dif) % 4];
				ccw &= spin[b] == spin[(4 + (a - dif) % 4) % 4];
				out.append((cw && ccw) || (!cw && !ccw) ? "undefined" : cw ? "cw" : "ccw" ).append('\n');
			}
		}
		System.out.print(out);
	}

	public static Integer[] readInts(String line) {
		StringTokenizer st = new StringTokenizer(line.trim());
		Integer a[] = new Integer[st.countTokens()], index = 0;
		while (st.hasMoreTokens())
			a[index++] = Integer.parseInt(st.nextToken());
		return a;
	}

	public static Long[] readLongs(String line) {
		StringTokenizer st = new StringTokenizer(line.trim());
		Long a[] = new Long[st.countTokens()];
		int index = 0;
		while (st.hasMoreTokens())
			a[index++] = Long.parseLong(st.nextToken());
		return a;
	}

	public static Double[] readDoubles(String line) {
		StringTokenizer st = new StringTokenizer(line.trim());
		Double a[] = new Double[st.countTokens()];
		int index = 0;
		while (st.hasMoreTokens())
			a[index++] = Double.parseDouble(st.nextToken());
		return a;
	}
}

import java.io.*;
import java.util.*;

public class A {
    FScanner in = new FScanner();
    PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out), true);

    void run() {
        char c1 = in.next().charAt(0);
        char c2 = in.next().charAt(0);
        int x = -1, y = -1;
        if (c1 == '^')
            x = 1;
        else if (c1 == '>')
            x = 2;
        else if (c1 == 'v')
            x = 3;
        else if (c1 == '<')
            x = 4;
        if (c2 == '^')
            y = 1;
        else if (c2 == '>')
            y = 2;
        else if (c2 == 'v')
            y = 3;
        else if (c2 == '<')
            y = 4;
        int n = in.nextInt() % 4;
        int res = Math.abs(x % 4 - y % 4);
        String ans = "";
        if (res % n == 0)
            ans = "cw";
        else if ((4 - res ) % n == 0)
            ans = "ccw";
        if (res == 2 && n % 2 == 0)
            ans = "undefined";
        out.print(ans);
        out.close();
    }

    public static void main(String[] args){
        new A().run();
    }

    static class FScanner {
        BufferedReader br;
        StringTokenizer st;

        FScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

import java.util.Scanner;

/**
 * Created by ARKA on 03-08-2017.
 */
public class Imperium998 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String art = sc.nextLine();
        char []a = {'v', '<', '^', '>'};

        int spin = sc.nextInt();
        spin = spin%4;

        String ans = "";
        int place = 0;
        int placeb = 0;

        if(spin%2 == 0)
            ans = "undefined";
        else{
            char check = art.charAt(0);
            char blank = art.charAt(2);

            //System.out.println(check + "\n" + blank);

            for(int i=0; i<a.length; i++){
                if(a[i] == check){
                    place=i;
                }
            }

            for(int i=0; i<a.length; i++){
                //System.out.println(a[i]);
                //System.out.println(blank);
                if(a[i] == blank){
                    placeb=i;
                }
            }

            int temp = placeb-place;

            //System.out.println(place);
            //System.out.println(placeb);
            //System.out.println(temp);
            if((temp==1 || temp == -3)&&spin==1)
                ans = "cw";
            else
                ans = "ccw";

        }
        System.out.println(ans);
    }
}

/*
⣿⣿⣿⣿⣿⣿⡷⣯⢿⣿⣷⣻⢯⣿⡽⣻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠸⣿⣿⣆⠹⣿⣿⢾⣟⣯⣿⣿⣿⣿⣿⣿⣽⣻⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣻⣽⡿⣿⣎⠙⣿⣞⣷⡌⢻⣟⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣿⣿⡄⠹⣿⣿⡆⠻⣿⣟⣯⡿⣽⡿⣿⣿⣿⣿⣽⡷⣯⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣟⣷⣿⣿⣿⡀⠹⣟⣾⣟⣆⠹⣯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢠⡘⣿⣿⡄⠉⢿⣿⣽⡷⣿⣻⣿⣿⣿⣿⡝⣷⣯⢿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣯⢿⣾⢿⣿⡄⢄⠘⢿⣞⡿⣧⡈⢷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣧⠘⣿⣷⠈⣦⠙⢿⣽⣷⣻⣽⣿⣿⣿⣿⣌⢿⣯⢿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣟⣯⣿⢿⣿⡆⢸⡷⡈⢻⡽⣷⡷⡄⠻⣽⣿⣿⡿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣏⢰⣯⢷⠈⣿⡆⢹⢷⡌⠻⡾⢋⣱⣯⣿⣿⣿⣿⡆⢻⡿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⡎⣿⢾⡿⣿⡆⢸⣽⢻⣄⠹⣷⣟⣿⣄⠹⣟⣿⣿⣟⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⡇⢸⣯⣟⣧⠘⣷⠈⡯⠛⢀⡐⢾⣟⣷⣻⣿⣿⣿⡿⡌⢿⣻⣿⣿
⣿⣿⣿⣿⣿⣿⣧⢸⡿⣟⣿⡇⢸⣯⣟⣮⢧⡈⢿⣞⡿⣦⠘⠏⣹⣿⣽⢿⣿⣿⣿⣿⣯⣿⣿⣿⡇⢸⣿⣿⣾⡆⠹⢀⣠⣾⣟⣷⡈⢿⣞⣯⢿⣿⣿⣿⢷⠘⣯⣿⣿
⣿⣿⣿⣿⣿⣿⣿⡈⣿⢿⣽⡇⠘⠛⠛⠛⠓⠓⠈⠛⠛⠟⠇⢀⢿⣻⣿⣯⢿⣿⣿⣿⣷⢿⣿⣿⠁⣾⣿⣿⣿⣧⡄⠇⣹⣿⣾⣯⣿⡄⠻⣽⣯⢿⣻⣿⣿⡇⢹⣾⣿
⣿⣿⣿⣿⣿⣿⣿⡇⢹⣿⡽⡇⢸⣿⣿⣿⣿⣿⣞⣆⠰⣶⣶⡄⢀⢻⡿⣯⣿⡽⣿⣿⣿⢯⣟⡿⢀⣿⣿⣿⣿⣿⣧⠐⣸⣿⣿⣷⣿⣿⣆⠹⣯⣿⣻⣿⣿⣿⢀⣿⢿
⣿⣿⣿⣿⣿⣿⣿⣿⠘⣯⡿⡇⢸⣿⣿⣿⣿⣿⣿⣿⣧⡈⢿⣳⠘⡄⠻⣿⢾⣽⣟⡿⣿⢯⣿⡇⢸⣿⣿⣿⣿⣿⣿⡀⢾⣿⣿⣿⣿⣿⣿⣆⠹⣾⣷⣻⣿⡿⡇⢸⣿
⣿⣿⣿⣿⣿⣿⣿⣿⡇⢹⣿⠇⢸⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠻⡇⢹⣆⠹⣟⣾⣽⣻⣟⣿⣽⠁⣾⣿⣿⣿⣿⣿⣿⣇⣿⣿⠿⠛⠛⠉⠙⠋⢀⠁⢘⣯⣿⣿⣧⠘⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⡈⣿⡃⢼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡙⠌⣿⣆⠘⣿⣞⡿⣞⡿⡞⢠⣿⣿⣿⣿⣿⡿⠛⠉⠁⢀⣀⣠⣤⣤⣶⣶⣶⡆⢻⣽⣞⡿⣷⠈⣿
⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠘⠁⠉⠉⠉⠉⠉⠉⠉⠉⠉⠙⠛⠛⢿⣄⢻⣿⣧⠘⢯⣟⡿⣽⠁⣾⣿⣿⣿⣿⣿⡃⢀⢀⠘⠛⠿⢿⣻⣟⣯⣽⣻⣵⡀⢿⣯⣟⣿⢀⣿
⣿⣿⣿⣟⣿⣿⣿⣿⣶⣶⡆⢀⣿⣾⣿⣾⣷⣿⣶⠿⠚⠉⢀⢀⣤⣿⣷⣿⣿⣷⡈⢿⣻⢃⣼⣿⣿⣿⣿⣻⣿⣿⣿⡶⣦⣤⣄⣀⡀⠉⠛⠛⠷⣯⣳⠈⣾⡽⣾⢀⣿
⣿⢿⣿⣿⣻⣿⣿⣿⣿⣿⡿⠐⣿⣿⣿⣿⠿⠋⠁⢀⢀⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣌⣥⣾⡿⣿⣿⣷⣿⣿⢿⣷⣿⣿⣟⣾⣽⣳⢯⣟⣶⣦⣤⡾⣟⣦⠘⣿⢾⡁⢺
⣿⣻⣿⣿⡷⣿⣿⣿⣿⣿⡗⣦⠸⡿⠋⠁⢀⢀⣠⣴⢿⣿⣽⣻⢽⣾⣟⣷⣿⣟⣿⣿⣿⣳⠿⣵⣧⣼⣿⣿⣿⣿⣿⣾⣿⣿⣿⣿⣿⣽⣳⣯⣿⣿⣿⣽⢀⢷⣻⠄⠘
⣿⢷⣻⣿⣿⣷⣻⣿⣿⣿⡷⠛⣁⢀⣀⣤⣶⣿⣛⡿⣿⣮⣽⡻⣿⣮⣽⣻⢯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⢀⢸⣿⢀⡆
⠸⣟⣯⣿⣿⣷⢿⣽⣿⣿⣷⣿⣷⣆⠹⣿⣶⣯⠿⣿⣶⣟⣻⢿⣷⣽⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢀⣯⣟⢀⡇
⣇⠹⣟⣾⣻⣿⣿⢾⡽⣿⣿⣿⣿⣿⣆⢹⣶⣿⣻⣷⣯⣟⣿⣿⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⢀⡿⡇⢸⡇
⣿⣆⠹⣷⡻⣽⣿⣯⢿⣽⣻⣿⣿⣿⣿⣆⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⢸⣿⠇⣼⡇
⡙⠾⣆⠹⣿⣦⠛⣿⢯⣷⢿⡽⣿⣿⣿⣿⣆⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠃⠎⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⢀⣿⣾⣣⡿⡇
⣿⣷⡌⢦⠙⣿⣿⣌⠻⣽⢯⣿⣽⣻⣿⣿⣿⣧⠩⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⢰⢣⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⢀⢀⢿⣞⣷⢿⡇
⣿⣽⣆⠹⣧⠘⣿⣿⡷⣌⠙⢷⣯⡷⣟⣿⣿⣿⣷⡀⡹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣈⠃⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⢀⣴⡧⢀⠸⣿⡽⣿⢀
⢻⣽⣿⡄⢻⣷⡈⢿⣿⣿⢧⢀⠙⢿⣻⡾⣽⣻⣿⣿⣄⠌⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⢁⣰⣾⣟⡿⢀⡄⢿⣟⣿⢀
⡄⢿⣿⣷⢀⠹⣟⣆⠻⣿⣿⣆⢀⣀⠉⠻⣿⡽⣯⣿⣿⣷⣈⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⢀⣠⠘⣯⣷⣿⡟⢀⢆⠸⣿⡟⢸
⣷⡈⢿⣿⣇⢱⡘⢿⣷⣬⣙⠿⣧⠘⣆⢀⠈⠻⣷⣟⣾⢿⣿⣆⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⣠⡞⢡⣿⢀⣿⣿⣿⠇⡄⢸⡄⢻⡇⣼
⣿⣷⡈⢿⣿⡆⢣⡀⠙⢾⣟⣿⣿⣷⡈⠂⠘⣦⡈⠿⣯⣿⢾⣿⣆⠙⠻⠿⠿⠿⠿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⢋⣠⣾⡟⢠⣿⣿⢀⣿⣿⡟⢠⣿⢈⣧⠘⢠⣿
⣿⣿⣿⣄⠻⣿⡄⢳⡄⢆⡙⠾⣽⣿⣿⣆⡀⢹⡷⣄⠙⢿⣿⡾⣿⣆⢀⡀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⣀⣠⣴⡿⣯⠏⣠⣿⣿⡏⢸⣿⡿⢁⣿⣿⢀⣿⠆⢸⣿
⣿⣿⣿⣿⣦⡙⣿⣆⢻⡌⢿⣶⢤⣉⣙⣿⣷⡀⠙⠽⠷⠄⠹⣿⣟⣿⣆⢙⣋⣤⣤⣤⣄⣀⢀⢀⢀⢀⣾⣿⣟⡷⣯⡿⢃⣼⣿⣿⣿⠇⣼⡟⣡⣿⣿⣿⢀⡿⢠⠈⣿
⣿⣿⣿⣿⣿⣷⣮⣿⣿⣿⡌⠁⢤⣤⣤⣤⣬⣭⣴⣶⣶⣶⣆⠈⢻⣿⣿⣆⢻⣿⣿⣿⣿⣿⣿⣷⣶⣤⣌⣉⡘⠛⠻⠶⣿⣿⣿⣿⡟⣰⣫⣴⣿⣿⣿⣿⠄⣷⣿⣿⣿
*/

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class b{

	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		char c1=s.next().charAt(0);
		char c2=s.next().charAt(0);
		int n=s.nextInt();
		if(n%4==1) {
			System.out.println("cw");
		}else if( n%4==3) {
			System.out.println("ccw");
		}else {
			System.out.println("undefined");
		}

	}
}

import java.util.Scanner;

public class C426A {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String start = scanner.next();
        int st;
        String end = scanner.next();
        int en;
        int seconds = scanner.nextInt();

        switch (start) {
            case "^":
                st = 0;
                break;
            case ">":
                st = 1;
                break;
            case "V":
                st = 2;
                break;
            default:
                st = 3;
                break;
        }

        switch (end) {
            case "^":
                en = 0;
                break;
            case ">":
                en = 1;
                break;
            case "V":
                en = 2;
                break;
            default:
                en = 3;
                break;
        }

        int enC = (st + seconds) % 4;
        int  enCC = (((st - seconds) % 4) + 4) % 4;

        if (enC == en) System.out.println("cw");
        else if (enCC == en) System.out.println("ccw");
        else System.out.println("undefined");
    }
}

//package year;

import java.io.*;
import java.util.*;

public class prac {
	static PrintWriter out=new PrintWriter(System.out);
	public static void main(String[] args) {

		InputReader in=new InputReader(System.in);
	String str=in.readString();
	String str2=in.readString();
	//System.out.println(str+" "+str2);
	int n=in.nextInt();
	boolean cc=false;
	boolean cw=false;
	int s=0;
	int e=0;
	if((int)str.charAt(0)==118){
		s=0;
	}
	if((int)str.charAt(0)==60){
		s=1;
	}
	if((int)str.charAt(0)==94){
		s=2;
	}
	if((int)str.charAt(0)==62){
		s=3;
	}if((int)str2.charAt(0)==118){
		e=0;
	}
	if((int)str2.charAt(0)==60){
		e=1;
	}if((int)str2.charAt(0)==94){
		e=2;
	}if((int)str2.charAt(0)==62){
		e=3;
	}
	if((s+n)%4==e)
		cc=true;
	if((e+n)%4==s){
		cw=true;
	}
	//System.out.println(s+" "+e);
	if(cc&&cw){
		System.out.println("undefined");
	}
	else{
		if(cc){
			System.out.println("cw");
return;
		}
		if(cw)
			System.out.println("ccw");
	return;
	}
	System.out.println("undefined");
	out.close();
	}

	//out.println(t);

	public static class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;

		public InputReader(InputStream st) {
			this.stream = st;
		}

		public int read() {
			/* internless */

			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public double nextDouble() {
			String doub = readString();
			return Double.parseDouble(doub);
		}

		public float nextFloat() {
			String doub = readString();
			return Float.parseFloat(doub);
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] sieve(int n) {
			int ar[] = new int[n + 1];
			ar[0] = 0;
			ar[1] = 1;
			for (int i = 2; i < ar.length; i++) {
				if (ar[i] == 0) {
					for (int k = i; k < ar.length; k = k + i) {
						if (ar[k] == 0) {
							ar[k] = i;
						}
					}
				}
			}
			return ar;
		}

		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}

		public Long[] nextLongArray(int n) {
			Long a[] = new Long[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextLong();
			}
			return a;
		}

		public ArrayList<ArrayList<Integer>> initlist(int n) {
			ArrayList<ArrayList<Integer>> list = new ArrayList<>();
			for (int i = 0; i <= n; i++) {
				list.add(new ArrayList<Integer>());
			}
			return list;
		}

		public int[] initdp(int n) {
			int ar[] = new int[n];
			for (int i = 0; i < n; i++) {
				ar[i] = -1;
			}
			return ar;
		}

		public int[][] initdp(int n, int m) {
			int ar[][] = new int[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++)
					ar[i][j] = -1;
			}
			return ar;
		}

		public char[] constring(String str) {
			char[] ar = new char[str.length()];
			for (int i = 0; i < str.length(); i++) {
				ar[i] = str.charAt(i);

			}
			return ar;
		}

		public static long gcd(long a, long b) {
			a = Math.abs(a);
			b = Math.abs(b);
			while (b != 0) {
				long temp = a % b;
				a = b;
				b = temp;
			}
			return a;
		}

		public static int longCompare(long a, long b) {
			if (a < b) {
				return -1;
			}
			if (a > b) {
				return 1;
			}
			return 0;
		}

		public String readString() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}
}

import java.util.Scanner;

public class First {

	public static void main(String[] args) {

		Scanner input = new Scanner(System.in);

		String[] shape = new String[2];
		for (int i = 0; i < shape.length; i++)
			shape[i]=input.next();
		int num = input.nextInt();
		String[] s = new String[4];
		s[0]="v";
		s[1]="<";
		s[2]="^";
		s[3]=">";
		int j = 0;
		for (; j < s.length; j++) {
			if(s[j].equals(shape[0]))
				break;
		}

		num%=4;

		String targetR = "";
		for (int i = 1; i <=num; i++) {
			if(j+i>3){
				targetR=s[j+i-4];
			}
			else
			targetR=s[j+i];
		}

		String targetL="";
		for (int i = 1; i <=num; i++) {
			if(j-i<0){
				targetL=s[j-i+4];
			}
			else
			targetL=s[j-i];
		}

		System.out.println(targetR);
		System.out.println(targetL);
		if(targetR.equals(shape[1])&&targetL.equals(shape[1]))
			System.out.println("undefined");
		else if(targetR.equals(shape[1]))
			System.out.println("cw");
		else if(targetL.equals(shape[1]))
		System.out.println("ccw");
		else
			System.out.println("undefined");

	}

}

import java.util.Scanner;

public class ProblemA {

	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		String[] pos={"^", ">", "v", "<"};
		String[] line=s.nextLine().split(" ");
		int seconds=s.nextInt();
		int initial=indexOf(line[0], pos);
		int finalPos=indexOf(line[1], pos);
		if (seconds%4==2) {
			System.out.println("undefined");
			return;
		}
		if (((finalPos-initial)%4+4)%4==seconds%4) {
			System.out.println("CW");
		}
		else if (((-finalPos+initial)%4+4)%4==seconds%4) {
			System.out.println("CCW");
		}

	}

	public static int indexOf(String s, String[] a) {
		for (int i=0; i<4; i++) {
			if (a[i].equals(s))
				return i;
		}
		return -1;
	}
}

//package year;

import java.io.*;
import java.util.*;

public class prac {
	static PrintWriter out=new PrintWriter(System.out);
	public static void main(String[] args) {

		InputReader in=new InputReader(System.in);
	String str=in.readString();
	String str2=in.readString();
	//System.out.println(str+" "+str2);
	int n=in.nextInt();
	boolean cc=false;
	boolean cw=false;
	int s=0;
	int e=0;
	if((int)str.charAt(0)==118){
		s=0;
	}
	if((int)str.charAt(0)==60){
		s=1;
	}
	if((int)str.charAt(0)==94){
		s=2;
	}
	if((int)str.charAt(0)==62){
		s=3;
	}if((int)str2.charAt(0)==118){
		e=0;
	}
	if((int)str2.charAt(0)==60){
		e=1;
	}if((int)str2.charAt(0)==94){
		e=2;
	}if((int)str2.charAt(0)==62){
		e=3;
	}
	if((s+n)%4==e)
		cc=true;
	if((e+n)%4==s){
		cw=true;
	}
	//System.out.println(s+" "+e);
	if(cc&&cw){
		System.out.println("undefined");
	}
	else{
		if(cc){
			System.out.println("cc");
return;
		}
		if(cw)
			System.out.println("ccw");
	return;
	}
	System.out.println("undefined");
	out.close();
	}

	//out.println(t);

	public static class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;

		public InputReader(InputStream st) {
			this.stream = st;
		}

		public int read() {
			/* internless */

			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public double nextDouble() {
			String doub = readString();
			return Double.parseDouble(doub);
		}

		public float nextFloat() {
			String doub = readString();
			return Float.parseFloat(doub);
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] sieve(int n) {
			int ar[] = new int[n + 1];
			ar[0] = 0;
			ar[1] = 1;
			for (int i = 2; i < ar.length; i++) {
				if (ar[i] == 0) {
					for (int k = i; k < ar.length; k = k + i) {
						if (ar[k] == 0) {
							ar[k] = i;
						}
					}
				}
			}
			return ar;
		}

		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}

		public Long[] nextLongArray(int n) {
			Long a[] = new Long[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextLong();
			}
			return a;
		}

		public ArrayList<ArrayList<Integer>> initlist(int n) {
			ArrayList<ArrayList<Integer>> list = new ArrayList<>();
			for (int i = 0; i <= n; i++) {
				list.add(new ArrayList<Integer>());
			}
			return list;
		}

		public int[] initdp(int n) {
			int ar[] = new int[n];
			for (int i = 0; i < n; i++) {
				ar[i] = -1;
			}
			return ar;
		}

		public int[][] initdp(int n, int m) {
			int ar[][] = new int[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++)
					ar[i][j] = -1;
			}
			return ar;
		}

		public char[] constring(String str) {
			char[] ar = new char[str.length()];
			for (int i = 0; i < str.length(); i++) {
				ar[i] = str.charAt(i);

			}
			return ar;
		}

		public static long gcd(long a, long b) {
			a = Math.abs(a);
			b = Math.abs(b);
			while (b != 0) {
				long temp = a % b;
				a = b;
				b = temp;
			}
			return a;
		}

		public static int longCompare(long a, long b) {
			if (a < b) {
				return -1;
			}
			if (a > b) {
				return 1;
			}
			return 0;
		}

		public String readString() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}
}

import java .util.*;
public class St
{
	public static void main(String[]args)
	{
     Scanner sc= new Scanner(System.in);
    String [] s1=(sc.nextLine()).split(" ");
	//String x1= s1[0];
	 int x1=(s1[0].equals("v"))?1:(s1[0].equals(">"))?2:(s1[0].equals("<"))?4:3;
	 String x2 =s1[1];
	 x2=(s1[1].equals("v"))?"1":(s1[1].equals(">"))?"2":(s1[1].equals("<"))?"4":"3";
	 int  s2 =sc.nextInt()%4;
     if((x1+s2)%4==Integer.parseInt(x2))
    	 {
    	 if(x1-s2<=0)
    	 {
    		 if(x1-s2+4==Integer.parseInt(x2))
    		 {	 System.out.println("undefined");
    		 }
    		 else
    			 System.out.println("ccw");
    	 }
    	 else
    	 {
    		 if(x1-s2==Integer.parseInt(x2))
    		 {	 System.out.println("undefined");
    		 }
    		 else
    			 System.out.println("ccw");
    	 }
	}
	else
		{
	if(x1-s2<=0)
   	 {
   		 if(x1-s2+4==Integer.parseInt(x2))
   		 {	 System.out.println("cw");
   		 }
  	 }
		 else
    	 {
    		 if(x1-s2==Integer.parseInt(x2))
    		 {	 System.out.println("cw");
    		 }
    		 else
    		 {
    			 System.out.println("undefined");
    	       }
    	 }
	      }
	 }
	}

import java.util.*;
public class Test {
    public static void main(String[] args) {
    Scanner input=new Scanner(System . in );
    char []a={'^','>','v','<'};

    char c1=input.next().charAt(0),c2=input.next().charAt(0);
    int n=input.nextInt();
        if (n%2==0) {
            System.out.println("undefined");
        }
        else{
            int k,m;
            for ( k = 0; k < 4; k++) {
                if (a[k]==c1) {
                    break;
                }
            }
           m=n%4;
            if (m+k>4) {
              m=m+k-4;
            }
                if (a[m]==c2) {
                    System.out.println("cw");
                }else System.out.println("ccw");
            }
        }

    }

import java.util.Scanner;

public class C426A {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String start = scanner.next();
        int st;
        String end = scanner.next();
        int en;
        int seconds = scanner.nextInt();

        switch (start) {
            case "^":
                st = 0;
                break;
            case ">":
                st = 1;
                break;
            case "v":
                st = 2;
                break;
            default:
                st = 3;
                break;
        }

        switch (end) {
            case "^":
                en = 0;
                break;
            case ">":
                en = 1;
                break;
            case "v":
                en = 2;
                break;
            default:
                en = 3;
                break;
        }

        int enC = (st + seconds) % 4;
        int  enCC = (((st - seconds) % 4) + 4) % 4;

        if (enC == en) System.out.println("cw");
        else if (enCC == en) System.out.println("ccw");
        else System.out.println("undefined");
    }
}

import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		//DisjointSet set = new DisjointSet(26);

		InputReader sc1 = new InputReader(System.in);
		PrintWriter sc2 = new PrintWriter(System.out);
		char start = sc1.readString().charAt(0);
		char end = sc1.readString().charAt(0);
		int time = sc1.nextInt();
		time = time%4;
		int s=0,e=0;
		char c[] = {'v', '<', '^', '>'};
		for(int i=0;i<4;i++) {
			if(start==c[i]) {
				s = i;
				break;
			}
		}

		for(int i=0;i<4;i++) {
			if(end==c[i]) {
				e = i;
				break;
			}
		}
		boolean cw = false, ccw = false;
		if((s+time)%4==e) {
			cw = true;
		}
		if(s-time<0) {
			if(4-time==e) {
				ccw = true;
			}
		}
		else {
			if(s-time==e) {
				ccw = true;
			}
		}
		if(cw==true && ccw==true) {
			System.out.println("undefined");
		}
		else if(cw==true) {
			sc2.println("cw");
		}
		else {
			sc2.println("ccw");
		}
		sc2.close();
	}
	/*
	 * 	DIVISORS
	 * */
	public static void divsors(int n) {
		for(int i=1;i<=Math.sqrt(n)+1;i++) {
			if(n%i==0) {
				if(n/i==i) {
					System.out.print(i+" ");
				}
				else {
					System.out.print	(i+" "+n/i);
				}
			}
		}
	}

	/*
	 * 	GCD
	 * */

	public static int GCD(int x, int y) {
		if(x==0) {
			return y;
		}
		return GCD(y%x, x);
	}

	/*
	 * 	GCD EXTENDED
	 * */

	public static int gcdExtended(int a, int b, int x, int y) {
		if(a==0) {
			x = 0;
			y = 1;
			return b;
		}

		int x1 = 1, y1 = 1;
		int gcd = gcdExtended(b%a, a, x1, y1);
		x = y1 - (b/a)*x1;
		y = x1;

		return gcd;
	}

	static class DisjointSet{
		static StringBuilder str = new StringBuilder();
		static int count = 0;
		int rank[];
		int parent[];
		int n;
		DisjointSet(int n){
			this.n = n;
			rank = new int[n];
			Arrays.fill(rank, 0);
			parent = new int[n];
			makeSet();

		}
		void makeSet() {
			for(int i=0;i<n;i++) {
				parent[i] = i;
			}
		}

		int find(int x) {
			if(parent[x]!=x) {
				parent[x] = find(parent[x]);
			}
			return parent[x];
		}

		void union(int x, int y) {
			int xRoot = find(x);
			int yRoot = find(y);

			if(xRoot==yRoot) {
				return;
			}

			if(rank[xRoot]>rank[yRoot]) {
				parent[yRoot] = xRoot;
				Append(x,y);
				count++;
			}
			else if(rank[xRoot]<rank[yRoot]) {
				parent[xRoot] = yRoot;
				Append(x,y);
				count++;
			}
			else {
				parent[yRoot] = xRoot;
				rank[xRoot] = rank[xRoot] + 1;
				count++;
				Append(x,y);
			}
		}

		void Append(int x, int y) {
			str.append((char)(x+97)+" "+(char)(y+97)+"\n");
		}
	}
	static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public String readString() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}
}

import java.util.Scanner;

public class CF834A
{
	public static void main(String[] args)
	{
		CF834A task = new CF834A();
		Problem solver = task.new Problem();
		Scanner in = new Scanner(System.in);

		int ans = solver.CalculateResult(in.next(), in.next(), in.nextInt());

		if(ans == -1)
			System.out.println("undefined");
		else
			if(ans == 0)
				System.out.println("cw");
			else
				if(ans == 1)
					System.out.println("ccw ");
	}

	public class Problem
	{
		public Problem()
		{

		}

		public int CalculateResult(String s,String e,int n)
		{
			int ans = -1;

			char sa = s.toCharArray()[0];
			char fa = e.toCharArray()[0];
			char cs = sa;
			int f_c = 0;
			int f_cc = 0;

			for(int i = 1; i <= 4; i++)
			{
				cs = NextState(cs, true);

				if(cs == fa)
				{
					f_c = i;
				}
			}
			cs = sa;
			for(int i = 1; i <= 4; i++)
			{
				cs = NextState(cs, false);

				if(cs == fa)
				{
					f_cc = i;
				}
			}

			int steps_c = n % f_c;
			int steps_cc = n % f_cc;

			// x + 4 * steps
			if((f_c + (4 * steps_c)) == n)
			{
				ans = 0;
			}
			else
				if((f_cc + (4 * steps_cc)) == n)
				{
					ans = 1;
				}

			return ans;
		}

		public char NextState(char s,Boolean clockwise)
		{
			char ans = s;

			if(clockwise)
			{
				if(s == '^')
					ans = '>';
				else
					if(s == '>')
						ans = 'v';
						else
							if(s == 'v')
								ans = '<';
							else
								if(s == '<')
									ans = '^';
			}
			else
			{
				if(s == '^')
					ans = '<';
				else
					if(s == '<')
						ans = 'v';
						else
							if(s == 'v')
								ans = '>';
							else
								if(s == '>')
									ans = '^';
			}

			return ans;
		}
	}
}

import java.io.BufferedReader;
import java.io.PrintWriter;

import java.io.InputStreamReader;

import java.io.IOException;

import java.util.StringTokenizer;

public class Main {

    static Scanner in = new Scanner();
    static PrintWriter out = new PrintWriter(System.out);

    public static int val(char c) {
        switch(c) {
            case 'v':
                return 3;
            case '<':
                return 2;
            case '^':
                return 1;
            case '>':
                return 0;
        }
        return Integer.MAX_VALUE;
    }

    public static void main(String[] args) throws IOException {
        char[] c = in.nextLine().toCharArray();
        int d = (val(c[0]) - val(c[2]) + 4) % 4, n = in.nextInt() % 4;
        out.print((d == 2 ? "undefined" : (d == n ? "cw" : "ccw")));
        out.close();
    }

    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        public Scanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
            st = new StringTokenizer("");
        }

        public String next() throws IOException {
            if(!st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public String nextLine() throws IOException {
            if(!st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            String r = st.nextToken("\n");
            st = new StringTokenizer(br.readLine(), " ");
            return r;
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
    }
}

import java .util.*;
public class St
{
	public static void main(String[]args)
	{
     Scanner sc= new Scanner(System.in);
    String [] s1=(sc.nextLine()).split(" ");
	//String x1= s1[0];
	 int x1=(s1[0].equals("v"))?1:(s1[0].equals(">"))?2:(s1[0].equals("<"))?4:3;
	 String x2 =s1[1];
	 x2=(s1[1].equals("v"))?"1":(s1[1].equals(">"))?"2":(s1[1].equals("<"))?"4":"3";
	 int  s2 =sc.nextInt()%4;
	 if(s2==0&&x1==Integer.parseInt(x2))
	 {
		 System.out.println("undefined");
	 }else
	 {if((x1+s2)%4==Integer.parseInt(x2))
    	 {
    	 if(x1-s2<=0)
    	 {
    		 if(x1-s2+4==Integer.parseInt(x2))
    		 {	 System.out.println("undefined");
    		 }
    		 else
    			 System.out.println("ccw");
    	 }
    	 else
    	 {
    		 if(x1-s2==Integer.parseInt(x2))
    		 {	 System.out.println("undefined");
    		 }
    		 else
    			 System.out.println("ccw");
    	 }
	}
	else
		{
	if(x1-s2<=0)
   	 {
   		 if(x1-s2+4==Integer.parseInt(x2))
   		 {	 System.out.println("cw");
   		 }
  	 }
		 else
    	 {
    		 if(x1-s2==Integer.parseInt(x2))
    		 {	 System.out.println("cw");
    		 }
    		 else
    		 {
    			 System.out.println("undefined");
    	       }
    	 }
	      }
	 }
	}
}

import java.io.*;
import java.util.*;

public class A {
    FScanner in = new FScanner();
    PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out), true);

    void run() {
        char c1 = in.next().charAt(0);
        char c2 = in.next().charAt(0);
        int x = -1, y = -1;
        if (c1 == '^')
            x = 1;
        else if (c1 == '>')
            x = 2;
        else if (c1 == 'v')
            x = 3;
        else if (c1 == '<')
            x = 4;
        if (c2 == '^')
            y = 1;
        else if (c2 == '>')
            y = 2;
        else if (c2 == 'v')
            y = 3;
        else if (c2 == '<')
            y = 4;
        int n = in.nextInt() % 4;
        int res = Math.abs(x % 4 - y % 4);
        String ans = "";
        if (n % 2 == 0)
            ans = "undefined";
        else if (res % n == 0)
            ans = "cw";
        else if ((4 - res) % n == 0)
            ans = "ccw";
        out.print(ans);
        out.close();
    }

    public static void main(String[] args){
        new A().run();
    }

    static class FScanner {
        BufferedReader br;
        StringTokenizer st;

        FScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int start = parse(in.nextCharacter());
            int end = parse(in.nextCharacter());

            int n = in.nextInt() % 4;

            String res = new String();
            if (n % 2 == 0)
                res = "undefined";
            else {
                if (end == 0 || start == 0) {
                    if (start == 0) {
                        if (end == 1 && n == 1)
                            res = "cw";
                        else
                            res = "ccw";
                    }
                    if (end == 0) {
                        if (start == 1 && n == 1)
                            res = "ccw";
                        else
                            res = "cw";
                    }
                } else {
                    int dif = end - start;
                    if (dif == n)
                        res = "cw";
                    else
                        res = "ccw";
                }
            }
            out.println(res);
        }

        public int parse(char c) {
            switch (c) {
                case 'v':
                    return 0;
                case '<':
                    return 1;
                case '^':
                    return 2;
                case '>':
                    return 3;
            }
            return 0;
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public char nextCharacter() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            return (char) c;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}