using System;

public class Program
{
	public static void Main()
	{
		string path = Console.ReadLine();
		int h = 0;
		int v = 0;
		int hmin = 0;
		int hmax = 0;
		int vmin = 0;
		int vmax = 0;

		foreach(var item in path)
		{
			if(item == 'L')
			{
				h--;
				if(h < hmin)
				{
					hmin = h;
				}
			}
			else if(item == 'R')
			{
				h++;
				if(h > hmax)
				{
					hmax = h;
				}
			}
			else if(item == 'U')
			{
				v--;
				if(v < vmin)
				{
					vmin = v;
				}
			}
			else
			{
				v++;
				if(v > vmax)
				{
					vmax = v;
				}
			}
		}

		int width = hmax - hmin + 1;
		int height = vmax - vmin + 1;
		bool[,] field = new bool[height, width];

		h = -hmin;
		v = -vmin;
		field[v, h] = true;

		foreach(var item in path)
		{
			if(item == 'L')
			{
				h--;
				if((h != 0 && field[v, h - 1] == true) ||
					(v != 0 && field[v - 1, h] == true) ||
					(v != height - 1 && field[v + 1, h] == true))
				{
					Console.WriteLine("BUG");
					return;
				}
			}
			else if(item == 'R')
			{
				h++;
				if((h != width - 1 && field[v, h + 1] == true) ||
					(v != 0 && field[v - 1, h] == true) ||
					(v != height - 1 && field[v + 1, h] == true))
				{
					Console.WriteLine("BUG");
					return;
				}
			}
			else if(item == 'U')
			{
				v--;
				if((h != 0 && field[v, h - 1] == true) ||
					(h != width - 1 && field[v, h + 1] == true) ||
					(v != 0 && field[v - 1, h] == true))
				{
					Console.WriteLine("BUG");
					return;
				}
			}
			else
			{
				v++;
				if((h != 0 && field[v, h - 1] == true) ||
					(h != width - 1 && field[v, h + 1] == true) ||
					(v != height - 1 && field[v + 1, h] == true))
				{
					Console.WriteLine("BUG");
					return;
				}
			}

			if(field[v, h] == true)
			{
				Console.WriteLine("BUG");
				return;
			}

			field[v, h] = true;
		}

		Console.WriteLine("OK");
	}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest.Codeforces.Round8
{
    class E
    {
        public static void Main()
        {
            int[,] map = new int[500, 500];
            int x = 250;
            int y = 250;
            map[x, y] = 1;
            string s = Console.ReadLine();
            foreach (var c in s)
            {
                if (c == 'L') x--;
                else if (c == 'R') x++;
                else if (c == 'U') y--;
                else if (c == 'D') y++;

                int check = map[x,y]+map[x+1,y]+map[x-1,y]+map[x,y+1]+map[x,y-1];
                if (check != 1)
                {
                    Console.Write("BUG");
                    return;
                }

                map[x,y] = 1;
            }
            Console.Write("OK");
        }
    }
}

/*******************************************************************************
* Author: Nirushuu
*******************************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.IO;
using System.Globalization;
using System.Numerics;

/*******************************************************************************
* IO from Kattio.cs from open.kattis.com/help/csharp                          */
public class NoMoreTokensException : Exception
{
}

public class Tokenizer
{
    string[] tokens = new string[0];
    private int pos;
    StreamReader reader;

    public Tokenizer(Stream inStream)
    {
        var bs = new BufferedStream(inStream);
        reader = new StreamReader(bs);
    }

    public Tokenizer() : this(Console.OpenStandardInput())
    {
        // Nothing more to do
    }

    private string PeekNext()
    {
        if (pos < 0)
            // pos < 0 indicates that there are no more tokens
            return null;
        if (pos < tokens.Length)
        {
            if (tokens[pos].Length == 0)
            {
                ++pos;
                return PeekNext();
            }
            return tokens[pos];
        }
        string line = reader.ReadLine();
        if (line == null)
        {
            // There is no more data to read
            pos = -1;
            return null;
        }
        // Split the line that was read on white space characters
        tokens = line.Split(null);
        pos = 0;
        return PeekNext();
    }

    public bool HasNext()
    {
        return (PeekNext() != null);
    }

    public string Next()
    {
        string next = PeekNext();
        if (next == null)
            throw new NoMoreTokensException();
        ++pos;
        return next;
    }
}

public class Scanner : Tokenizer
{

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public float NextFloat()
    {
        return float.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }
}

public class BufferedStdoutWriter : StreamWriter
{
    public BufferedStdoutWriter() : base(new BufferedStream(Console.OpenStandardOutput()))
    {
    }
}
/******************************************************************************/

/*******************************************************************************
* DisjointSet datastructure                                                   */
public struct DisjointSet {
    public int[] parent;
    public int[] rank;
    public DisjointSet(int n) {
        parent = new int[n];
        for (int i = 0; i < n; ++i) {
            parent[i] = i;
        }
        rank = new int[n];
    }

    public int Find(int i) {
        int idx = i;
        var compress = new List<int>();
        while (idx != parent[idx]) {
            compress.Add(idx);
            idx = parent[idx];
        }

        foreach (var e in compress) {   // path compress
            parent[e] = idx;
        }
        return idx;
    }

    public void Union(int a, int b) {
        int aPar = this.Find(a);
        int bPar = this.Find(b);

        if (rank[aPar] > rank[bPar]) {  // by rank
            parent[bPar] = aPar;
        } else {
            parent[aPar] = bPar;
        }
        if (rank[aPar] == rank[bPar]) {
            ++rank[bPar];
        }
    }
}

class MaxHeap {
    List<int> data;

    public MaxHeap() {
        data = new List<int>();
    }

    public void Add(int a) {
        data.Add(a);
        int idx = data.Count - 1;
        int parent = (int) Math.Floor((double) (idx - 1) / 2);
        while (idx != 0 && (data[idx] > data[parent])) {
            int tmp = data[parent];
            data[parent] = data[idx];
            data[idx] = tmp;

            idx = parent;
            parent = (int) Math.Floor((double) (idx - 1) / 2);
        }
    }

    public int Pop() {
        int res = data[0];
        data[0] = data[data.Count - 1];
        data.RemoveAt(data.Count - 1);

        int idx = 0;
        while (true) {
            int child1 = (2 * idx) + 1;
            int child2 = (2 * idx) + 2;

            if (child1 >= data.Count) { // no children
                break;
            } else if (child2 >= data.Count) {  // one child
                if (data[idx] < data[child1]) {
                    int tmp = data[idx];
                    data[idx] = data[child1];
                    data[child1] = tmp;
                }
                break;
            } else {    // two children
                int maxChild = data[child1] > data[child2] ? child1 : child2;
                if (data[idx] < data[maxChild]) {
                    int tmp = data[idx];
                    data[idx] = data[maxChild];
                    data[maxChild] = tmp;
                    idx = maxChild;
                    continue;
                } else {    // no swap
                    break;
                }
            }
        }

        return res;
    }

}

class Dequeue {
    public Dictionary<int, int> data = new Dictionary<int, int>();
    int firstIdx;
    public int Count;
    public Dequeue() {
        data = new Dictionary<int, int>();
        firstIdx = 1;
        Count = 0;
    }

    public void PushFront(int a) {
        data[firstIdx - 1] = a;
        ++Count;
        --firstIdx;
    }

    public void PushBack(int a) {
        data[firstIdx + Count] = a;
        ++Count;
    }

    public int PopFront() {
        --Count;
        ++firstIdx;
        return data[firstIdx - 1];
    }

    public int PopBack() {
        --Count;
        return data[firstIdx + Count];
    }

    public int Get(int n) {
        return data[firstIdx + n];
    }
}
/******************************************************************************/

class MainClass {

    // Debug functions
    static void debug<T>(IEnumerable<T> a, string s = "") {
        Console.WriteLine($"name: {s}");
        int i = 0;
        foreach (var e in a) {
            Console.WriteLine($"value {i}: {e}");
            ++i;
        }
    }
    static void dbg<T>(T a, string s = "") {
        Console.WriteLine($"name: {s} value: {a}");
    }
    ////////////////////

    static int gcd(int a, int b) {
        while (b != 0) {
            int t = b;
            b = a % b;
            a = t;
        }
        return a;
    }

    // class PairInt{
    //     public int fst;
    //     public int snd;

    //     // void Add(Pair<int> p) {
    //     //     fst += p.fst;
    //     //     snd += p.snd;
    //     // }
    // }

    public static void Main() {

        var sc = new Scanner();
        var wr = new BufferedStdoutWriter();
        var dot = new NumberFormatInfo();
        dot.NumberDecimalSeparator = ".";

        // int T = sc.NextInt();

        // for (int t = 0; t < T; ++t) {
        // }

        string s = sc.Next();

        var visited = new HashSet<Tuple<int, int>>();
        var dir = new Dictionary<char, Tuple<int, int>>{
            {'R', new Tuple<int, int>(1, 0)},
            {'L', new Tuple<int, int>(-1, 0)},
            {'U', new Tuple<int, int>(0, 1)},
            {'D', new Tuple<int, int>(0, -1)}
        };

        var pos = new Tuple<int, int>(0, 0);
        visited.Add(pos);

        foreach (var e in s) {
            var prev = pos;
            pos = new Tuple<int, int>(pos.Item1 + dir[e].Item1, pos.Item2 + dir[e].Item2);

            if (visited.Contains(pos)) {
                wr.Write("BUG");
                wr.Flush();
                return;
            }

            visited.Add(pos);

            foreach (var d in dir.Values) {
                var nbr = new Tuple<int, int>(pos.Item1 + d.Item1, pos.Item2 + d.Item2);
                if (visited.Contains(nbr) && !(nbr.Equals(prev))) {
                    // wr.Write(e);
                    // wr.Write(pos);
                    // wr.Write(nbr);
                    wr.Write("BUG");
                    wr.Flush();
                    return;
                }
            }
        }

        // debug(pos);
        // foreach (var e in visited) {
        //     debug(e);
        // }

        wr.Write("OK");

        wr.Flush();

    }
}

using System;

namespace Beta82
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();

            int[,] coord = new int[101, 2];

            bool flag = false;
            int i = 1;
            coord[0,0] =0; coord[0, 1] = 0;

            int x=0,y=0;
            while (!flag&&i<=line.Length)
            {
                switch (line[i-1])
                {
                    case 'L': coord[i, 0] = x - 1; coord[i, 1] = y; break;
                    case 'R': coord[i, 0] = x + 1; coord[i, 1] = y; break;
                    case 'U': coord[i, 0] = x;     coord[i, 1] = y+1; break;
                    case 'D': coord[i, 0] = x;     coord[i, 1] = y-1; break;
                    default: break;
                }
                x = coord[i, 0];
                y = coord[i, 1];
                int iter=0;
                for (int j = 0; j < i; j++)
                {
                    /*if ((coord[j, 0] + 1 == coord[i, 0]) || (coord[j, 0] - 1 == coord[i, 0]) || (coord[j, 0] == coord[i, 0]))
                    {
                        if ((coord[j, 1] + 1 == coord[i, 1]) || (coord[j, 1] - 1 == coord[i, 1]) || (coord[j, 1] == coord[i, 1]))
                        {
                            if ((coord[j, 0] == coord[i, 0]) && (coord[j, 1] == coord[i, 1]))
                                iter = 10;
                            iter++;
                        }
                    }*/

                    if (((coord[j, 0] + 1 == coord[i, 0]) || (coord[j, 0] - 1 == coord[i, 0])) && (coord[j, 1] == coord[i, 1]))
                    {
                        iter++;
                    }
                    if (((coord[j, 1] + 1 == coord[i, 1]) || (coord[j, 1] - 1 == coord[i, 1])) && (coord[j, 0] == coord[i, 0]))
                    {
                        iter++;
                    }

                    if ((coord[j, 1] == coord[i, 1]) && (coord[j, 0] == coord[i, 0]))
                    {
                        iter++;
                    }
                }
                if (iter > 1)
                    flag = true;
                i++;
            }

            if (flag)
                Console.WriteLine("BUG");
            else
                Console.WriteLine("OK");
        }
    }
}

using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;

class Program
{

    void solve()
    {
        string t = Console.ReadLine();
        int n = t.Length;
        int L = 2 * n + 1;
        bool[,] vis = new bool[L, L];
        int x = n;
        int y = n;
        vis[x, y] = true;

        foreach (char c in t)
        {

            switch (c)
            {
                case 'U':
                    y++;
                    break;
                case 'D':
                    y--;
                    break;
                case 'L':
                    x--;
                    break;
                default:
                    x++;
                    break;
            }
            vis[x, y] = true;

        }
        int ex = x;
        int ey = y;
        x = n;
        y = n;
        Queue<int> q = new Queue<int>();
        q.Enqueue(x); q.Enqueue(y);
        int[,] d = new int[L, L];
        for (int i = 0; i < L; i++)
            for (int j = 0; j < L; j++)
                d[i, j] = -1;
        d[x, y] = 0;
        while (q.Count > 0)
        {
            x = q.Dequeue();
            y = q.Dequeue();
            for(int dx=-1;dx<=1;dx++)
                for (int dy = -1; dy <= 1; dy++)
                {
                    if (Math.Abs(dx) + Math.Abs(dy) != 1)
                        continue;
                    int nx = x + dx;
                    int ny = y + dy;
                    if (nx < 0 || nx >= L || ny < 0 || ny >= L || !vis[nx, ny] || d[nx, ny] != -1)
                        continue;
                    d[nx, ny] = d[x, y] + 1;
                    q.Enqueue(nx); q.Enqueue(ny);
                }
        }
        if (d[ex, ey] != t.Length)
            Console.WriteLine("BUG");
        else
            Console.WriteLine("OK");

    }

    static void Main(string[] args)
    {
        new Program().solve();
    }
}

using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;

class Program
{

    void solve()
    {
        string t = Console.ReadLine();
        int n = t.Length;
        bool[,] vis = new bool[2 * n + 1, 2 * n + 1];
        int x = n;
        int y = n;
        vis[x, y] = true;
        bool ok = true;
        int ex = -1;
        int ey = -1;
        for (int i = 0; i < t.Length; i++)
        {
            int nx, ny;
            nx=x;
            ny=y;
            if (t[i] == 'D')
                ny--;
            if (t[i] == 'U')
                ny++;
            if (t[i] == 'L')
                nx--;
            if (t[i] == 'R')
                nx++;
            vis[nx, ny] = true;
            x = nx;
            y = ny;
            ex = x;
            ey = y;

        }
        if (!ok)
            ;
        else
        {
            int[,] d = new int[2 * n + 1, 2 * n + 1];
            d[n, n] = 0;
            for (int i = 0; i < 2 * n + 1; i++)
                for (int j = 0; j < 2 * n+1; j++)
                    if (i != n || j != n)
                        d[i, j] = -1;
            Queue<int> q = new Queue<int>();
            x = n;
            y = n;
            q.Enqueue(x);
            q.Enqueue(y);
            while (q.Count > 0)
            {
                x = q.Dequeue();
                y = q.Dequeue();
                for (int dx = -1; dx <= 1; dx++)
                    for (int dy = -1; dy <= 1; dy++)
                        if (dx == 0 ^ dy == 0)
                        {
                            int nx = x + dx;
                            int ny = y + dy;
                            if (nx < 0 || nx > 2 * n || ny < 0 || ny > 2 * n || !vis[nx, ny] || d[nx, ny] != -1)
                                continue;
                            d[nx, ny] = 1 + d[x, y];
                            q.Enqueue(nx);
                            q.Enqueue(ny);

                        }
            }
            if (d[ex, ey] == t.Length)
                Console.WriteLine("OK");
            else
                Console.WriteLine("BUG");
        }
       // Console.ReadLine();
    }

    static void Main(string[] args)
    {
        new Program().solve();
    }
}

using System;
using System.IO;
using System.Text;

namespace Obsession_with_Robots
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            string s = reader.ReadLine();

            var nn = new int[205,205];
            int x = 100, y = 100, move = 1;
            nn[x, y] = move++;
            foreach (char c in s)
            {
                switch (c)
                {
                    case 'U':
                        y++;
                        break;
                    case 'D':
                        y--;
                        break;
                    case 'L':
                        x++;
                        break;
                    case 'R':
                        x--;
                        break;
                }

                if (nn[x, y] == 0)
                    nn[x, y] = move++;
                else
                {
                    writer.WriteLine("BUG");
                    writer.Flush();
                    return;
                }
            }

            var dx = new[] {0, 0, -1, 1};
            var dy = new[] {1, -1, 0, 0};
            for (int i = 1; i < 204; i++)
            {
                for (int j = 1; j < 204; j++)
                {
                    if (nn[i, j] == 0)
                        continue;

                    for (int k = 0; k < dx.Length; k++)
                    {
                        if (nn[i + dx[k], j + dy[k]] == 0)
                            continue;

                        if (Math.Abs(nn[i + dx[k], j + dy[k]] - nn[i, j]) > 1)
                        {
                            writer.WriteLine("BUG");
                            writer.Flush();
                            return;
                        }
                    }
                }
            }

            writer.WriteLine("OK");
            writer.Flush();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace acm
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            int pos = 0;
            HashSet<int> vis = new HashSet<int>();
            vis.Add(pos);
            for (int i = 0; i < s.Length; ++i)
            {
                int old = pos;
                if (s[i] == 'U') pos += 1000;
                else if (s[i] == 'D') pos -= 1000;
                else if (s[i] == 'R') ++pos;
                else --pos;
                if (vis.Contains(pos) || pos - 1 != old && vis.Contains(pos - 1) || pos + 1 != old && vis.Contains(pos + 1) || pos - 1000 != old && vis.Contains(pos-1000) || pos + 1000 != old && vis.Contains(pos+1000))
                {
                    Console.WriteLine("BUG");
                    return;
                }
                vis.Add(pos);
            }
            Console.WriteLine("OK");
        }
    }
}

#if DEBUG
using System.Reflection;
using System.Threading.Tasks;
#endif

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Numerics;
using System.Globalization;

namespace _8b
{
    class Program
    {
        static string _inputFilename = "input.txt";
        static string _outputFilename = "output.txt";
        static bool _useFileInput = false;

        static void Main(string[] args)
        {
            StreamWriter file = null;
#if DEBUG
			Console.SetIn(getInput());
#else
            if (_useFileInput)
            {
                Console.SetIn(File.OpenText(_inputFilename));
                file = new StreamWriter(_outputFilename);
                Console.SetOut(file);
            }
#endif

            try
            {
                solution();
            }
            finally
            {
                if (_useFileInput)
                {
                    file.Close();
                }
            }
        }

        static void solution()
        {
            #region SOLUTION
            var s = Console.ReadLine();
            var n = s.Length;
            var t = new int[2 * n + 5, 2 * n + 5];
            var x = n;
            var y = n;
            t[y, x] = 1;
            for (int i = 0; i < n; i++)
            {
                var next = s[i];
                if (next == 'L')
                {
                    y--;
                    if (t[y, x] == 1)
                    {
                        Console.WriteLine("BUG");
                        return;
                    }
                    else
                    {

                        t[y, x] = 1;
                        t[y + 1, x - 1] = 1;
                        t[y + 1, x + 1] = 1;
                        t[y + 1 - 1, x] = 1;
                        t[y + 1 + 1, x] = 1;
                    }
                }
                else if (next == 'R')
                {
                    y++;
                    if (t[y, x] == 1)
                    {
                        Console.WriteLine("BUG");
                        return;
                    }
                    else
                    {

                        t[y, x] = 1;
                        t[y - 1, x - 1] = 1;
                        t[y - 1, x + 1] = 1;
                        t[y - 1 - 1, x] = 1;
                        t[y - 1 + 1, x] = 1;
                    }
                }
                else if (next == 'U')
                {
                    x++;
                    if (t[y, x] == 1)
                    {
                        Console.WriteLine("BUG");
                        return;
                    }
                    else
                    {

                        t[y, x] = 1;
                        t[y, x - 1 - 1] = 1;
                        t[y , x + 1 - 1] = 1;
                        t[y - 1, x - 1] = 1;
                        t[y + 1, x - 1] = 1;
                    }
                }
                else if (next == 'D')
                {
                    x--;
                    if (t[y, x] == 1)
                    {
                        Console.WriteLine("BUG");
                        return;
                    }
                    else
                    {

                        t[y, x] = 1;
                        t[y, x - 1 + 1] = 1;
                        t[y, x + 1 + 1] = 1;
                        t[y - 1, x + 1] = 1;
                        t[y + 1, x + 1] = 1;
                    }
                }
            }

            Console.WriteLine("OK");

            //var n = readInt();
            //var m = readInt();

            //var a = readIntArray();
            //var b = readIntArray();
            #endregion
        }

        static int readInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static long readLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static int[] readIntArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();
        }

        static long[] readLongArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();
        }

#if DEBUG
		static StreamReader getInput()
		{
			var resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];
			var resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);

			return new StreamReader(resource);
		}
#endif
    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace codeforces
{
    class C
    {
        static string _input =
@"
RRRUL
";

        #region test

        static List<string> _lines;

        static string ReadLine()
        {
#if DEBUG
            if (_lines == null)
            {
                _lines = new List<string>();
                string[] ss = _input.Replace("\n", "").Split('\r');
                for (int i = 0; i < ss.Length; i++)
                {
                    if (
                        (i == 0 || i == ss.Length - 1) &&
                        ss[i].Length == 0
                        )
                        continue;

                    _lines.Add(ss[i]);
                }
            }

            string s = null;
            if (_lines.Count > 0)
            {
                s = _lines[0];
                _lines.RemoveAt(0);
            }
            return s;
#else
            return Console.In.ReadLine();
#endif
        }

        static void WriteLine(object o)
        {
#if DEBUG
            System.Diagnostics.Trace.WriteLine(o);
#else
            Console.WriteLine(o);
#endif
        }

        static void Write(object o)
        {
#if DEBUG
            System.Diagnostics.Trace.Write(o);
#else
            Console.Write(o);
#endif
        }
        #endregion

        static void Main(string[] args)
        {
            string s = ReadLine();

            //s = new string('U', 100);

            int x=0;
            int y=0;
            List<string> list = new List<string>();
            list.Add("0.0");

            foreach (char c in s)
            {
                int nx = x;
                int ny = y;

                switch (c)
                {
                    case 'U': ny--; break;
                    case 'D': ny++; break;
                    case 'R': nx++; break;
                    case 'L': nx--; break;
                }

                string key = nx + "." + ny;
                if (list.Contains(key))
                {
                    Write("BUG");
                    return;
                }
                list.Add(key);

                {
                    key = (x+1) + "." + y;
                    if (!list.Contains(key))
                        list.Add(key);
                }
                {
                    key = (x -1) + "." + y;
                    if (!list.Contains(key))
                        list.Add(key);
                }
                {
                    key = x  + "." + (y+1);
                    if (!list.Contains(key))
                        list.Add(key);
                }
                {
                    key = x+ "." + (y-1);
                    if (!list.Contains(key))
                        list.Add(key);
                }

                x = nx;
                y = ny;

            }
            Write("OK");
        }

    }
}

using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        #region constants

        private const int N = 100;
        private const int D = 2 * N + 7;

        #endregion
        static void Main(string[] args)
        {
            var visited = new int[D, D];
            for (int i = 0; i < D; i++)
                for (int j = 0; j < D; j++)
                {
                    visited[i, j] = 0;
                }
            int x = D / 2, y = D / 2;
            visited[x, y] = 1;
            bool isPosible = true;
            string s = Console.ReadLine();
            for (int i = 0; i < s.Length; ++i)
            {
                if (s[i] == 'U') ++y;
                else if (s[i] == 'D') --y;
                else if (s[i] == 'R') ++x;
                else if (s[i] == 'L') --x;
                if (visited[x, y] == 1)
                {
                    isPosible = false;
                    break;
                }
                else if (visited[x, y + 1] + visited[x, y - 1] + visited[x + 1, y] + visited[x - 1, y] > 1)
                {
                    isPosible = false;
                    break;
                }
                visited[x, y] = 1;
            }
            Console.WriteLine(isPosible ? "OK" : "BUG");
            //Console.ReadKey();
        }
    }
}

using System;
using System.Globalization;
using System.IO;
using System.Linq;

namespace CF317
{
	internal class Program
	{
		private static void Main(string[] args)
		{
			var sr = new InputReader(Console.In);
			//var sr = new InputReader(new StreamReader("input.txt"));
			var task = new Task();
			using (var sw = Console.Out)
			//using (var sw = new StreamWriter("output.txt"))
			{
				task.Solve(sr, sw);
				//Console.ReadKey();
			}
		}
	}

	internal class Task
	{
		public void Solve(InputReader sr, TextWriter sw)
		{
			var steps = sr.NextString();
			var matrix = new bool[300, 300];
			var sx = 150;
			var sy = 150;
			matrix[sx, sy] = true;
			for (var i = 0; i < steps.Length; i++) {
				var next = steps[i];
				var dx = 0;
				var dy = 0;
				if (next == 'U')
					dy--;
				if (next == 'D')
					dy++;
				if (next == 'L')
					dx--;
				if (next == 'R')
					dx++;
				sx += dx;
				sy += dy;
				if (matrix[sx, sy]) {
					sw.WriteLine("BUG");
					return;
				}
				matrix[sx, sy] = true;
				var count = 0;
				if (matrix[sx + 1, sy])
					count++;
				if (matrix[sx, sy + 1])
					count++;
				if (matrix[sx - 1, sy])
				{
					count++;
				}
				if (matrix[sx, sy - 1])
				{
					count++;
				}
				if (count > 1)
				{
					sw.WriteLine("BUG");
					return;
				}
			}

			sw.WriteLine("OK");
		}
	}
}

internal class InputReader : IDisposable
{
	private bool isDispose;
	private readonly TextReader sr;

	public InputReader(TextReader stream)
	{
		sr = stream;
	}

	public void Dispose()
	{
		Dispose(true);
		GC.SuppressFinalize(this);
	}

	public string NextString()
	{
		var result = sr.ReadLine();
		return result;
	}

	public int NextInt32()
	{
		return Int32.Parse(NextString());
	}

	public long NextInt64()
	{
		return Int64.Parse(NextString());
	}

	public string[] NextSplitStrings()
	{
		return NextString()
				.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
	}

	public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
	{
		return NextSplitStrings()
				.Select(s => func(s, CultureInfo.InvariantCulture))
				.ToArray();
	}

	public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
	{
		return
				str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
						.Select(s => func(s, CultureInfo.InvariantCulture))
						.ToArray();
	}

	protected void Dispose(bool dispose)
	{
		if (!isDispose)
		{
			if (dispose)
				sr.Close();
			isDispose = true;
		}
	}

	~InputReader()
	{
		Dispose(false);
	}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace code_8_2
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            bool[,] mas = new bool[400, 400];
            int i = 200;
            int j = 200;
            int previ = 200;
            int prevj = 200;
            mas[i,j]=true;
            bool b = false;
            for (int ii = 0; ii < s.Length; ii++)
            {
                if (s[ii] == 'L')
                {
                    j--;
                    if (mas[i + 1, j] || mas[i - 1, j] || mas[i, j - 1])
                    {
                        Console.WriteLine("BUG");
                        b = true;
                        break;
                    }
                }
                else
                if (s[ii] == 'R')
                {
                    j++;
                    if (mas[i + 1, j] || mas[i-1, j ] || mas[i, j + 1])
                    {
                        Console.WriteLine("BUG");
                        b = true;
                        break;
                    }
                }
                else
                if (s[ii] == 'U')
                {
                    i--;
                    if (mas[i - 1, j] || mas[i, j - 1] || mas[i, j + 1])
                    {
                        Console.WriteLine("BUG");
                        b = true;
                        break;
                    }
                }
                else
                if (s[ii] == 'D')
                {
                    i++;
                    if (mas[i+1,j]||mas[i,j-1] ||mas[i,j+1])
                    {
                        Console.WriteLine("BUG");
                        b = true;
                        break;
                    }
                }

                if (mas[i, j])
                {
                    Console.WriteLine("BUG");
                    b = true;
                    break;
                }
                else
                    mas[i, j] = true;

            }
            if (!b)            Console.WriteLine("OK");
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            bool[,] map;

            string s = Console.ReadLine();
            int l, r, u, d;
            int x, X, y, Y;
            x = X = y = Y = 0;
            l = r = u = d = 0;
            foreach (char c in s)
            {
                switch (c)
                {
                    case('L'):
                        l++;
                        break;
                    case('R'):
                        l--;
                        break;
                    case('U'):
                        u++;
                        break;
                    case('D'):
                        u--;
                        break;
                }
                if (l > X)
                {
                    X = l;
                }
                if (l < x) x = l;
                if (u < y) y = u;
                if (u > Y) Y = u;

            }
            map = new bool[Y - y+1, X - x+1];
            int ly=Y-y+1;
            int lx=X-x+1;
            int startx = X;
            int starty = Y;
            int i = starty;
            int j = startx;
            foreach (char c in s)
            {
                map[i, j] = true;
                switch (c)
                {
                    case ('L'):
                        j--;
                        break;
                    case ('R'):
                        j++;
                        break;
                    case ('U'):
                        i--;
                        break;
                    case ('D'):
                        i++;
                        break;
                }
            }
            map[i,j]=true;
            int[,] a = new int[ly, lx];
            for (int k = 0; k<ly; k++)
            {
                for (int m = 0; m < lx; m++)
                {
                    a[k, m] = int.MaxValue;
                }
            }
            a[starty, startx] = 0;
            findRoad(a, map, starty, startx, 0, lx, ly);
            if (a[i, j] == s.Length)
            {
                Console.WriteLine("OK");
            }
            else
            {
                Console.WriteLine("BUG");
            }
        }
        public static void findRoad(int[,] a, bool[,] map, int i, int j, int dist, int lx, int ly)
        {
            if (a[i, j] >= dist)
            {
                a[i, j] = dist;
                if (i + 1 < ly && map[i + 1, j]) findRoad(a, map, i + 1, j, a[i, j] + 1, lx, ly);
                if (i > 0 && map[i - 1, j]) findRoad(a, map, i - 1, j, a[i, j] + 1, lx, ly);
                if (j + 1 < lx && map[i, j + 1]) findRoad(a, map, i, j + 1, a[i, j] + 1, lx, ly);
                if (j > 0 && map[i, j - 1]) findRoad(a, map, i, j - 1, a[i, j] + 1, lx, ly);
            }
        }
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;

class Problem
{
    const int INF = 1987654321;
    const string inFile = "..\\..\\test.in";

    public void Process()
    {
        TextReader reader = Console.In;

#if LOCAL_SITE_SUPERKINHLUAN
        // comment out this line when submit
        reader = new StreamReader(inFile);
#endif

        string s = reader.ReadLine();
        string res = Solve(s);
        Console.WriteLine(res);
    }

    int[] dx = new int[] { -1, 0, 1, 0 };
    int[] dy = new int[] { 0, 1, 0, -1 };

    private string Solve(string s)
    {
        int[,] a = new int[300, 300];
        int x = 150, y = 150;
        a[x, y] = 1;
        for (int i = 0; i < s.Length; i++)
        {
            int count = a[x, y];

            char c = s[i];
            if (c == 'U') x++;
            else if (c == 'D') x--;
            else if (c == 'L') y++;
            else if (c == 'R') y--;

            if (a[x,y] > 0)
                return "BUG";

            a[x, y] = count + 1;

            for (int t = 0; t < 4; t++)
            {
                int u = x + dx[t];
                int v = y + dy[t];

                if (a[u, v] > 0 && a[u, v] != count)
                    return "BUG";
            }
        }
        return "OK";
    }

    public static void Main()
    {
        Problem p = new Problem();
        p.Process();
    }
}

using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
// Powered by caide (code generator, tester, and library code inliner)

class Solution {
    public void solve(TextReader input, TextWriter output) {
        string steps = input.ReadLine();

        int n = steps.Length * 2 + 3;
        int[,] map = new int[n, n];

        int x = n / 2;
        int y = x;
        map[x, y] = 1;
        foreach (char step in steps)
        {
            if (step == 'L')
                x--;
            if (step == 'R')
                x++;
            if (step == 'U')
                y++;
            if (step == 'D')
                y--;
            map[x, y]++;

            int val =           map[x, y - 1] +
                map[x - 1, y] + map[x, y]     + map[x + 1, y]
                              + map[x, y + 1];
            if(val > 2)
            {
                output.WriteLine("BUG");
                return;
            }
        }

        output.WriteLine("OK");
    }
}

class CaideConstants {
    public const string InputFile = null;
    public const string OutputFile = null;
}
public class Program {
    public static void Main(string[] args) {
        Solution solution = new Solution();
        using (System.IO.TextReader input =
                CaideConstants.InputFile == null ? System.Console.In :
                        new System.IO.StreamReader(CaideConstants.InputFile))
        using (System.IO.TextWriter output =
                CaideConstants.OutputFile == null ? System.Console.Out:
                        new System.IO.StreamWriter(CaideConstants.OutputFile))

            solution.solve(input, output);
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static byte[][] matr;

        static void Main(string[] args)
        {
            matr = new byte[300][];
            for (int i = 0; i < 300; i++) matr[i] = new byte[300];
            string path = Console.ReadLine();
            int col = 150;
            int row = 150;
            matr[col][row] = 1;
            char[] pathChar = path.ToCharArray();
            for (int i = 0; i < path.Length; i++)
            {
                if (pathChar[i] == 'U') row++;
                if (pathChar[i] == 'D') row--;
                if (pathChar[i] == 'R') col++;
                if (pathChar[i] == 'L') col--;
                if (matr[col][row] == 0
                    && (matr[col - 1][row] == 0 || pathChar[i] == 'R')
                    && (matr[col + 1][row] == 0 || pathChar[i] == 'L')
                    && (matr[col][row - 1] == 0 || pathChar[i] == 'U')
                    && (matr[col][row + 1] == 0 || pathChar[i] == 'D')
                    ) matr[col][row] = 1;
                else
                {
                    Console.WriteLine("BUG");
                    Console.ReadKey();
                    return;
                }
            }
            Console.WriteLine("OK");
            Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Numerics;
using System.Diagnostics;

namespace Main
{
    class Program
    {
        public static void Main(String[] args)
        {
//            Console.SetIn(new StreamReader("c:\\a.txt"));

            var movementString = Console.ReadLine().ToCharArray();

            HashSet<Tuple<int, int>> pos = new HashSet<Tuple<int, int>>();

            Console.WriteLine(IsShortestPathCandidate(movementString, 0, pos, 0, 0) ? "OK" : "BUG");
        }

        private static bool IsShortestPathCandidate(char[] movementString, int i, HashSet<Tuple<int, int>> pos, int x, int y)
        {
            if (pos.Contains(new Tuple<int, int>(x, y)))
                return false;

            if (AdjacentVisitedPoints(x, y, pos) > 1)
                return false;

            if (i == movementString.Length)
                return true;

            pos.Add(new Tuple<int, int>(x, y));

            switch (movementString[i])
            {
                case 'L':
                    return IsShortestPathCandidate(movementString, i + 1, pos, x, y - 1);
                case 'R':
                    return IsShortestPathCandidate(movementString, i + 1, pos, x, y + 1);
                case 'U':
                    return IsShortestPathCandidate(movementString, i + 1, pos, x - 1, y);
                default:
                    return IsShortestPathCandidate(movementString, i + 1, pos, x + 1, y);
            }
        }

        private static int AdjacentVisitedPoints(int x, int y, HashSet<Tuple<int, int>> pos)
        {
            int vis = 0;

            if (pos.Contains(new Tuple<int, int>(x + 1, y)))
                vis++;

            if (pos.Contains(new Tuple<int, int>(x - 1, y)))
                vis++;

            if (pos.Contains(new Tuple<int, int>(x, y + 1)))
                vis++;

            if (pos.Contains(new Tuple<int, int>(x, y - 1)))
                vis++;

            return vis;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    const int SIZE = 300;
    int[] dr = { 0, 1, 0, -1 };
    int[] dc = { 1, 0, -1, 0 };
    string dir = "RULD";

    public void Solve()
    {
        int r = SIZE / 2;
        int c = SIZE / 2;
        var f = new bool[SIZE, SIZE];
        f[r, c] = true;
        string s = ReadToken();
        foreach (char ch in s)
        {
            r += dr[dir.IndexOf(ch)];
            c += dc[dir.IndexOf(ch)];
            f[r, c] = true;
        }

        var vis = new bool[SIZE, SIZE];
        var q = new Queue<Tuple<int, int>>();
        q.Enqueue(Tuple.Create(SIZE / 2, SIZE / 2));
        vis[SIZE / 2, SIZE / 2] = true;
        int step = 0;
        while (true)
        {
            var nq = new Queue<Tuple<int, int>>();
            while (q.Count > 0)
            {
                var t = q.Dequeue();
                if (t.Item1 == r && t.Item2 == c)
                {
                    Write(step == s.Length ? "OK" : "BUG");
                    return;
                }
                for (int k = 0; k < 4; k++)
                {
                    int nr = t.Item1 + dr[k];
                    int nc = t.Item2 + dc[k];
                    if (f[nr, nc] && !vis[nr, nc])
                    {
                        vis[nr, nc] = true;
                        nq.Enqueue(Tuple.Create(nr, nc));
                    }
                }
            }
            q = nq;
            step++;
        }
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("input.txt");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //thread.Start();
            //thread.Join();
            new Solver().Solve();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
#if DEBUG
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}

using System;
using System.Collections.Generic;
using System.Linq;

namespace NS
{
	class MainClass
	{
		static List<int> xa, ya;
		public static void Main (string[] args)
		{
			var s = Console.ReadLine ();

			xa = new List<int> ();
			ya = new List<int> ();
			int x = 0;
			int y = 0;
			xa.Add(0);
			ya.Add(0);
			foreach (var c in s) {
				if (c=='L')
					x--;
				if (c=='R')
					x++;
				if (c=='U')
					y++;
				if (c=='D')
					y--;

				for(int i = 0; i<xa.Count-1; i++) {
					if ((Math.Abs(xa[i]-x)<=1 && ya[i]-y==0) || (Math.Abs(ya[i]-y)<=1 && xa[i]-x==0)) {
						Console.WriteLine("BUG");
						return;
					}
				}

				xa.Add(x);
				ya.Add(y);
			}

			Console.WriteLine("OK");
		}
	}
}

using System;
using System.Collections.Generic;
using System.Text;

namespace b
{
    class Program
    {

        class Point
        {
            public Point(int x, int y)
            {
                this.x = x;
                this.y = y;
            }

            public bool Eq(Point an)
            {
                return ((this.x == an.x && this.y == an.y)
                        ||(Math.Abs(this.x-an.x)==1 && this.y==an.y)
                        || Math.Abs(this.y-an.y)==1 && this.x==an.x);
            }

            public int x, y;
        }

        static void Main(string[] args)
        {
            string way = Console.ReadLine();
            Point[] pts = new Point[way.Length+1];
            pts[0] = new Point(0, 0);
            bool bug = false;
            for (int i = 0; i < way.Length; i++)
            {

                switch (way[i])
                {
                    case 'L':
                        pts[i + 1] = new Point(pts[i].x-1, pts[i].y);
                        break;
                    case 'R':
                        pts[i + 1] = new Point(pts[i].x+1, pts[i].y);
                        break;
                    case 'U':
                        pts[i + 1] = new Point(pts[i].x, pts[i].y+1);
                        break;
                    case 'D':
                        pts[i + 1] = new Point(pts[i].x, pts[i].y-1);
                        break;
                }

                for (int j = 0; j < i; j++)
                {
                    if (pts[i+1].Eq(pts[j]))
                    {
                        bug = true;
                        break;
                    }
                }
                if (bug) break;
            }
            if (bug) Console.WriteLine("BUG");
            else Console.WriteLine("OK");
        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;

class Program
{
    public static int[] Read(string str)
    {
        string[] tokens = str.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        int[] ret = new int[tokens.Length];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = int.Parse(tokens[i]);
        }

        return ret;
    }

    public static double[] ReadDouble(string str)
    {
        string[] tokens = str.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        double[] ret = new double[tokens.Length];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = double.Parse(tokens[i], CultureInfo.InvariantCulture);
        }

        return ret;
    }

    static string Reverse(string s)
    {
        char[] a = s.ToCharArray();
        Array.Reverse(a);
        return new string(a);
    }

    static void Main(string[] args)
    {
        string s = Console.ReadLine().Trim();

        HashSet<string> hs = new HashSet<string>();
        int x = 0;
        int y = 0;
        hs.Add(string.Format("{0},{1}", x, y));
        for (int i = 0; i < s.Length; i++)
        {
            string key_prev = string.Format("{0},{1}", x, y);
            if (s[i] == 'U') y--;
            else if (s[i] == 'D') y++;
            else if (s[i] == 'L') x--;
            else if (s[i] == 'R') x++;
            string key = string.Format("{0},{1}", x, y);
            string key_u = string.Format("{0},{1}", x, y - 1);
            string key_d = string.Format("{0},{1}", x, y + 1);
            string key_l = string.Format("{0},{1}", x - 1, y);
            string key_r = string.Format("{0},{1}", x + 1, y);
            if (hs.Contains(key))
            {
                Console.WriteLine("BUG");
                return;
            }
            if ((key_prev != key_u && hs.Contains(key_u)) ||
                (key_prev != key_d && hs.Contains(key_d)) ||
                (key_prev != key_l && hs.Contains(key_l)) ||
                (key_prev != key_r && hs.Contains(key_r)))
            {
                Console.WriteLine("BUG");
                return;
            }
            hs.Add(key);
        }
        Console.WriteLine("OK");
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

public class Example
{

    public static void Main()
    {
        string s = Console.ReadLine();

        bool[,] mas = new bool[300, 300];
        mas[150, 150] = true;
        int tekx = 150; int teky = 150;
        bool was = false;
        var vx = tekx; var vy = teky;
        for (int i = 0; i < s.Length; i++)
        {
            var oldx = tekx;
            var oldy = teky;
            if (s[i] == 'U') teky--;
            if (s[i] == 'D') teky++;
            if (s[i] == 'L') tekx--;
            if (s[i] == 'R') tekx++;
            //if(i>0 && ( s[])) was = true;
            for (int x = 0; x < 2;x++ )
                //for (int y = 0; y < 2; y++)
                {
                    var newx = tekx - 1 + 2 * x;
                    var newy = teky;
                    if ((oldx != newx || oldy != newy) && mas[newx, newy]) was = true;
                    newx = tekx;
                    newy = teky - 1 + 2 * x;
                    if ((oldx != newx || oldy != newy) && mas[newx, newy]) was = true;
                }
                //if (mas[tekx, teky]) was = true;
            mas[tekx, teky] = true;
            if (vx == tekx && vy == teky) was = true;
            vx = oldx; vy = oldy;
        }
        if (was) Console.WriteLine("BUG"); else Console.WriteLine("OK");
    }
}

using System;
using System.Collections.Generic;
using System.Text;
//using System.Linq;

namespace consoleTraining
{
    class Program
    {
        static void Main(string[] args)
        {
            string path = Console.ReadLine();

            List<string> coords = new List<string>();
            coords.Add("0;0");
            int lastX = 0, lastY = 0; char lastCh = path[0];
            foreach (char ch in path)
            {
                if (ch == 'L') { lastX--; }
                if (ch == 'R') { lastX++; }
                if (ch == 'U') { lastY++; }
                if (ch == 'D') { lastY--; }
                string[] checkStrs = strs(ch, lastX, lastY);
                foreach (string checkStr in checkStrs) if (coords.Contains(checkStr)) { Console.WriteLine("BUG"); return; }
                if ((ch == 'L' && lastCh == 'R') || (ch == 'R' && lastCh == 'L') || (ch == 'U' && lastCh == 'D') || (ch == 'D' && lastCh == 'U')) { Console.WriteLine("BUG"); return; }
                coords.Add(string.Format("{0};{1}", lastX, lastY)); lastCh = ch;
            }
            Console.WriteLine("OK");
        }

        static string[] strs(char ch, int x, int y)
        {
            List<string> checkCoords = new List<string>();
            string up = string.Format("{0};{1}", x, y + 1);
            string down = string.Format("{0};{1}", x, y - 1);
            string left = string.Format("{0};{1}", x - 1, y);
            string right = string.Format("{0};{1}", x + 1, y);
            if (ch == 'U') { checkCoords.Add(up); checkCoords.Add(right); checkCoords.Add(left); }
            if (ch == 'D') { checkCoords.Add(down); checkCoords.Add(right); checkCoords.Add(left); }
            if (ch == 'L') { checkCoords.Add(up); checkCoords.Add(down); checkCoords.Add(left); }
            if (ch == 'R') { checkCoords.Add(up); checkCoords.Add(right); checkCoords.Add(down); }
            return checkCoords.ToArray();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    private static int[] dp;
    private static int n;
    private static void Fill(int mask, int time)
    {
        if (dp[mask] > 0 && dp[mask] <= time) return;
        dp[mask] = time;

        for (int i = 0; i < n; i++)
            if (((mask >> i) & 1) == 0)
            {
                mask |= (1 << i);
                Fill(mask, time + 2 * Dist(i));
                for (int j = i + 1; j < n; j++)
                    if (((mask >> j) & 1) == 0)
                    {
                        Fill(mask | (1 << j), time + Dist(i) + Dist(j) + Dist(i, j));
                    }

                return;
            }
    }

    private static int Dist(int id)
    {
        return x[id] * x[id] + y[id] * y[id];
    }

    private static int Dist(int id1, int id2)
    {
        int dx = x[id1] - x[id2];
        int dy = y[id1] - y[id2];
        return dx * dx + dy * dy;
    }

    private static int[] x, y;
    private static void Solve()
    {
        int xs = RI();
        int ys = RI();
        n = RI();
        x = new int[n];
        y = new int[n];
        for (int i = 0; i < n; i++)
        {
            x[i] = RI() - xs;
            y[i] = RI() - ys;
        }

        dp = new int[1 << n];

        Fill(0, 0);
    }

    static void Main(string[] args)
    {
        int[,] map = new int[222, 222];

        int x = 105;
        int y = 105;
        map[x, y] = 1;
        foreach (char ch in Console.ReadLine())
        {
            if (ch == 'U') y++;
            if (ch == 'D') y--;
            if (ch == 'L') x--;
            if (ch == 'R') x++;

            int count = map[x - 1, y] + map[x + 1, y] + map[x, y - 1] + map[x, y + 1];
            count += 2 * map[x, y];
            map[x, y] = 1;

            if (count > 1)
            {
                Console.WriteLine("BUG");
                return;
            }
        }

        Console.WriteLine("OK");
    }

    private const int Mod = 1000000000 + 7;

    #region Data Read
    private static char ReadSign()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans == '+' || ans == '-' || ans == '?')
                return (char)ans;
        }
    }

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

    private static List<int>[] ReadGraph(int n, int m)
    {
        List<int>[] g = new List<int>[n];
        for (int i = 0; i < g.Length; i++) g[i] = new List<int>();
        for (int i = 0; i < m; i++)
        {
            int a = RI() - 1;
            int b = RI() - 1;

            g[a].Add(b);
            g[b].Add(a);
        }

        return g;
    }

    private static int[,] ReadGraphAsMatrix(int n, int m)
    {
        int[,] matrix = new int[n + 1, n + 1];
        for (int i = 0; i < m; i++)
        {
            int a = RI();
            int b = RI();
            matrix[a, b] = matrix[b, a] = 1;
        }

        return matrix;
    }

    private static void Sort(ref int a, ref int b)
    {
        if (a > b) Swap(ref a, ref b);
    }

    private static void Swap(ref int a, ref int b)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }

    private const int BufferSize = 1 << 16;
    private static StreamReader consoleReader;
    private static MemoryStream testData;

    private static int RI()
    {
        int ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static ulong RUL()
    {
        ulong ans = 0;
        int chr;
        do
        {
            chr = consoleReader.Read();
            if (chr == -1)
                return 0;
        } while (chr < '0' || chr > '9');

        ans = (uint)(chr - '0');
        while (true)
        {
            chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans;
            ans = ans * 10 + (uint)(chr - '0');
        }
    }

    private static long RL()
    {
        long ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static int[] RIA(int n)
    {
        int[] ans = new int[n];
        for (int i = 0; i < n; i++)
            ans[i] = RI();
        return ans;
    }

    private static long[] RLA(int n)
    {
        long[] ans = new long[n];
        for (int i = 0; i < n; i++)
            ans[i] = RL();
        return ans;
    }

    private static char[] ReadWord()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        List<char> s = new List<char>();
        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s.ToArray();
    }

    private static char[] ReadString(int n)
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        char[] s = new char[n];
        int pos = 0;
        do
        {
            s[pos++] = (char)ans;
            if (pos == n) break;
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s;
    }

    private static char[] ReadStringLine()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (ans == 10 || ans == 13);

        List<char> s = new List<char>();

        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while (ans != 10 && ans != 13);

        return s.ToArray();
    }

    private static char ReadLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))
                return (char)ans;
        }
    }
    private static char ReadNonLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')))
                return (char)ans;
        }
    }

    private static char ReadAnyOf(IEnumerable<char> allowed)
    {
        while (true)
        {
            char ans = (char)consoleReader.Read();
            if (allowed.Contains(ans))
                return ans;
        }
    }

    private static char ReadDigit()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans >= '0' && ans <= '9')
                return (char)ans;
        }
    }

    private static int ReadDigitInt()
    {
        return ReadDigit() - (int)'0';
    }

    private static char ReadAnyChar()
    {
        return (char)consoleReader.Read();
    }

    private static string DoubleToString(double x)
    {
        return x.ToString(CultureInfo.InvariantCulture);
    }

    private static double DoubleFromString(string x)
    {
        return double.Parse(x, CultureInfo.InvariantCulture);
    }

    static Program()
    {
        //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);
    }

    private static void PushTestData(StringBuilder sb)
    {
        PushTestData(sb.ToString());
    }
    private static void PushTestData(string data)
    {
#if TOLYAN_TEST
        if (testData == null)
        {
            testData = new MemoryStream();
            consoleReader = new StreamReader(testData);
        }

        var pos = testData.Position;
        var bytes = Encoding.UTF8.GetBytes(data);
        testData.Write(bytes, 0, bytes.Length);
        testData.Flush();
        testData.Position = pos;
#endif
    }
    #endregion
}

#if DEBUG
using System.Reflection;
using System.Threading.Tasks;
#endif

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Numerics;
using System.Globalization;

namespace _8b
{
    class Program
    {
        static string _inputFilename = "input.txt";
        static string _outputFilename = "output.txt";
        static bool _useFileInput = false;

        static void Main(string[] args)
        {
            StreamWriter file = null;
#if DEBUG
			Console.SetIn(getInput());
#else
            if (_useFileInput)
            {
                Console.SetIn(File.OpenText(_inputFilename));
                file = new StreamWriter(_outputFilename);
                Console.SetOut(file);
            }
#endif

            try
            {
                solution();
            }
            finally
            {
                if (_useFileInput)
                {
                    file.Close();
                }
            }
        }

        static void solution()
        {
            #region SOLUTION
            var s = Console.ReadLine();
            var n = s.Length;
            var t = new int[2 * n + 1, 2 * n + 1];
            var x = n;
            var y = n;
            t[y, x] = 1;
            for (int i = 0; i < n; i++)
            {
                var next = s[i];
                if (next == 'L')
                {
                    y--;
                    if (t[y, x] == 1)
                    {
                        Console.WriteLine("BUG");
                        return;
                    }
                    else
                    {

                        t[y, x] = 1;
                    }
                }
                else if (next == 'R')
                {
                    y++;
                    if (t[y, x] == 1)
                    {
                        Console.WriteLine("BUG");
                        return;
                    }
                    else
                    {

                        t[y, x] = 1;
                    }
                }
                else if (next == 'U')
                {
                    x++;
                    if (t[y, x] == 1)
                    {
                        Console.WriteLine("BUG");
                        return;
                    }
                    else
                    {

                        t[y, x] = 1;
                    }
                }
                else if (next == 'D')
                {
                    x--;
                    if (t[y, x] == 1)
                    {
                        Console.WriteLine("BUG");
                        return;
                    }
                    else
                    {

                        t[y, x] = 1;
                    }
                }
            }

            Console.WriteLine("OK");

            //var n = readInt();
            //var m = readInt();

            //var a = readIntArray();
            //var b = readIntArray();
            #endregion
        }

        static int readInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static long readLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static int[] readIntArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();
        }

        static long[] readLongArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();
        }

#if DEBUG
		static StreamReader getInput()
		{
			var resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];
			var resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);

			return new StreamReader(resource);
		}
#endif
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;

namespace CF317
{
	internal class Program
	{
		private static void Main(string[] args)
		{
			var sr = new InputReader(Console.In);
			//var sr = new InputReader(new StreamReader("input.txt"));
			var task = new Task();
			using (var sw = Console.Out)
			//using (var sw = new StreamWriter("output.txt"))
			{
				task.Solve(sr, sw);
				//Console.ReadKey();
			}
		}
	}

	internal class Task
	{
		public void Solve(InputReader sr, TextWriter sw)
		{
			var steps = sr.NextString();
			var matrix = new bool[300, 300];
			var sx = 150;
			var sy = 150;
			matrix[sx, sy] = true;
			for (var i = 0; i < steps.Length; i++) {
				var next = steps[i];
				var dx = 0;
				var dy = 0;
				if (next == 'U')
					dy--;
				if (next == 'D')
					dy++;
				if (next == 'L')
					dx--;
				if (next == 'R')
					dx++;
				sx += dx;
				sy += dy;
				if (matrix[sx, sy]) {
					sw.WriteLine("BUG");
					return;
				}
				matrix[sx, sy] = true;
			}
			var count = 0;
			if (matrix[sx + 1, sy])
				count++;
			if (matrix[sx, sy + 1])
				count++;
			if (matrix[sx -1, sy]) {
				count++;
			}
			if (matrix[sx, sy - 1]) {
				count++;
			}
			if (count > 1) {
				sw.WriteLine("BUG");
				return;
			}

			sw.WriteLine("OK");
		}
	}
}

internal class InputReader : IDisposable
{
	private bool isDispose;
	private readonly TextReader sr;

	public InputReader(TextReader stream)
	{
		sr = stream;
	}

	public void Dispose()
	{
		Dispose(true);
		GC.SuppressFinalize(this);
	}

	public string NextString()
	{
		var result = sr.ReadLine();
		return result;
	}

	public int NextInt32()
	{
		return Int32.Parse(NextString());
	}

	public long NextInt64()
	{
		return Int64.Parse(NextString());
	}

	public string[] NextSplitStrings()
	{
		return NextString()
				.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
	}

	public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
	{
		return NextSplitStrings()
				.Select(s => func(s, CultureInfo.InvariantCulture))
				.ToArray();
	}

	public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
	{
		return
				str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
						.Select(s => func(s, CultureInfo.InvariantCulture))
						.ToArray();
	}

	protected void Dispose(bool dispose)
	{
		if (!isDispose)
		{
			if (dispose)
				sr.Close();
			isDispose = true;
		}
	}

	~InputReader()
	{
		Dispose(false);
	}
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;

namespace CF317
{
	internal class Program
	{
		private static void Main(string[] args)
		{
			var sr = new InputReader(Console.In);
			//var sr = new InputReader(new StreamReader("input.txt"));
			var task = new Task();
			using (var sw = Console.Out)
			//using (var sw = new StreamWriter("output.txt"))
			{
				task.Solve(sr, sw);
				//Console.ReadKey();
			}
		}
	}

	internal class Task
	{
		public void Solve(InputReader sr, TextWriter sw)
		{
			var steps = sr.NextString();
			var matrix = new bool[300, 300];
			var sx = 150;
			var sy = 150;
			matrix[sx, sy] = true;
			for (var i = 0; i < steps.Length; i++) {
				var next = steps[i];
				var dx = 0;
				var dy = 0;
				if (next == 'U')
					dy--;
				if (next == 'D')
					dy++;
				if (next == 'L')
					dx--;
				if (next == 'R')
					dx++;
				sx += dx;
				sy += dy;
				if (matrix[sx, sy]) {
					sw.WriteLine("BUG");
					return;
				}
				matrix[sx, sy] = true;
			}

			sw.WriteLine("OK");
		}
	}
}

internal class InputReader : IDisposable
{
	private bool isDispose;
	private readonly TextReader sr;

	public InputReader(TextReader stream)
	{
		sr = stream;
	}

	public void Dispose()
	{
		Dispose(true);
		GC.SuppressFinalize(this);
	}

	public string NextString()
	{
		var result = sr.ReadLine();
		return result;
	}

	public int NextInt32()
	{
		return Int32.Parse(NextString());
	}

	public long NextInt64()
	{
		return Int64.Parse(NextString());
	}

	public string[] NextSplitStrings()
	{
		return NextString()
				.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
	}

	public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
	{
		return NextSplitStrings()
				.Select(s => func(s, CultureInfo.InvariantCulture))
				.ToArray();
	}

	public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
	{
		return
				str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
						.Select(s => func(s, CultureInfo.InvariantCulture))
						.ToArray();
	}

	protected void Dispose(bool dispose)
	{
		if (!isDispose)
		{
			if (dispose)
				sr.Close();
			isDispose = true;
		}
	}

	~InputReader()
	{
		Dispose(false);
	}
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;

class Program
{
    public static int[] Read(string str)
    {
        string[] tokens = str.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        int[] ret = new int[tokens.Length];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = int.Parse(tokens[i]);
        }

        return ret;
    }

    public static double[] ReadDouble(string str)
    {
        string[] tokens = str.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        double[] ret = new double[tokens.Length];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = double.Parse(tokens[i], CultureInfo.InvariantCulture);
        }

        return ret;
    }

    static string Reverse(string s)
    {
        char[] a = s.ToCharArray();
        Array.Reverse(a);
        return new string(a);
    }

    static void Main(string[] args)
    {
        string s = Console.ReadLine().Trim();

        HashSet<string> hs = new HashSet<string>();
        int x = 0;
        int y = 0;
        hs.Add(string.Format("{0},{1}", x, y));
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == 'U') y--;
            else if (s[i] == 'D') y++;
            else if (s[i] == 'L') x--;
            else if (s[i] == 'R') x++;
            string key = string.Format("{0},{1}", x, y);
            if (hs.Contains(key))
            {
                Console.WriteLine("BUG");
                return;
            }
            hs.Add(key);
        }
        Console.WriteLine("OK");
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

public class Example
{

    public static void Main()
    {
        string s = Console.ReadLine();

        bool[,] mas = new bool[300, 300];
        mas[150, 150] = true;
        int tekx = 150; int teky = 150;
        bool was = false;
        for (int i = 0; i < s.Length; i++)
        {
            var oldx = tekx;
            var oldy = teky;
            if (s[i] == 'U') teky--;
            if (s[i] == 'D') teky++;
            if (s[i] == 'L') tekx--;
            if (s[i] == 'R') tekx++;
            if(i>0 &&s[i-1]==s[i]) was = true;
            for (int x = 0; x < 2;x++ )
                for (int y = 0; y < 2; y++)
                {
                    var newx = tekx - 1 + 2 * x;
                    var newy = teky - 1 + 2 * y;
                    if (oldx != newx && oldy != newy && mas[newx, newy]) was = true;
                }
                //if (mas[tekx, teky]) was = true;
            mas[tekx, teky] = true;
        }
        if (was) Console.WriteLine("BUG"); else Console.WriteLine("OK");
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

public class Example
{

    public static void Main()
    {
        string s = Console.ReadLine();

        bool[,] mas = new bool[300, 300];
        mas[150, 150] = true;
        int tekx = 150; int teky = 150;
        bool was = false;
        var vx = tekx; var vy = teky;
        for (int i = 0; i < s.Length; i++)
        {
            var oldx = tekx;
            var oldy = teky;
            if (s[i] == 'U') teky--;
            if (s[i] == 'D') teky++;
            if (s[i] == 'L') tekx--;
            if (s[i] == 'R') tekx++;
            //if(i>0 && ( s[])) was = true;
            for (int x = 0; x < 2;x++ )
                //for (int y = 0; y < 2; y++)
                {
                    var newx = tekx - 1 + 2 * x;
                    var newy = teky;
                    if (oldx != newx && oldy != newy && mas[newx, newy]) was = true;
                    newx = tekx;
                    newy = teky - 1 + 2 * x;
                    if (oldx != newx && oldy != newy && mas[newx, newy]) was = true;
                }
                //if (mas[tekx, teky]) was = true;
            mas[tekx, teky] = true;
            if (vx == tekx && vy == teky) was = true;
            vx = oldx; vy = oldy;
        }
        if (was) Console.WriteLine("BUG"); else Console.WriteLine("OK");
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

public class Example
{

    public static void Main()
    {
        string s = Console.ReadLine();

        bool[,] mas = new bool[300, 300];
        mas[150, 150] = true;
        int tekx = 150; int teky = 150;
        bool was = false;
        for (int i = 0; i < s.Length; i++)
        {
            var oldx = tekx;
            var oldy = teky;
            if (s[i] == 'U') teky--;
            if (s[i] == 'D') teky++;
            if (s[i] == 'L') tekx--;
            if (s[i] == 'R') tekx++;
            for (int x = 0; x < 2;x++ )
                for (int y = 0; y < 2; y++)
                {
                    var newx = tekx - 1 + 2 * x;
                    var newy = teky - 1 + 2 * y;
                    if (oldx != newx && oldy != newy && mas[newx, newy]) was = true;
                }
                //if (mas[tekx, teky]) was = true;
            mas[tekx, teky] = true;
        }
        if (was) Console.WriteLine("BUG"); else Console.WriteLine("OK");
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

public class Example
{

    public static void Main()
    {
        string s = Console.ReadLine();

        bool[,] mas = new bool[300, 300];
        mas[150, 150] = true;
        int tekx = 150; int teky = 150;
        bool was = false;
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == 'U') teky--;
            if (s[i] == 'D') teky++;
            if (s[i] == 'L') tekx--;
            if (s[i] == 'R') tekx++;
            if (mas[tekx, teky]) was = true;
            mas[tekx, teky] = true;
        }
        if (was) Console.WriteLine("BUG"); else Console.WriteLine("OK");
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

public class Example
{

    public static void Main()
    {
        string s = Console.ReadLine();

        bool[,] mas = new bool[300, 300];
        mas[150, 150] = true;
        int tekx = 150; int teky = 150;
        bool was = false;
        var vx = tekx; var vy = teky;
        for (int i = 0; i < s.Length; i++)
        {
            var oldx = tekx;
            var oldy = teky;
            if (s[i] == 'U') teky--;
            if (s[i] == 'D') teky++;
            if (s[i] == 'L') tekx--;
            if (s[i] == 'R') tekx++;
            //if(i>0 && ( s[])) was = true;
            for (int x = 0; x < 2;x++ )
                for (int y = 0; y < 2; y++)
                {
                    var newx = tekx - 1 + 2 * x;
                    var newy = teky - 1 + 2 * y;
                    if (oldx != newx && oldy != newy && mas[newx, newy]) was = true;
                }
                //if (mas[tekx, teky]) was = true;
            mas[tekx, teky] = true;
            if (vx == tekx && vy == teky) was = true;
            vx = oldx; vy = oldy;
        }
        if (was) Console.WriteLine("BUG"); else Console.WriteLine("OK");
    }
}

using System;
using System.Collections.Generic;
using System.Text;
//using System.Linq;

namespace consoleTraining
{
    class Program
    {
        static void Main(string[] args)
        {
            string path = Console.ReadLine();

            List<string> coords = new List<string>();
            coords.Add("0;0");
            int lastX = 0, lastY = 0;
            foreach (char ch in path)
            {
                if (ch == 'L') lastX--;
                if (ch == 'R') lastX++;
                if (ch == 'U') lastY++;
                if (ch == 'D') lastY--;
                if (coords.Contains(string.Format("{0};{1}", lastX, lastY))) { Console.WriteLine("BUG"); return; }
            }
            Console.WriteLine("OK");
        }

    }
}

using System;
using System.Collections.Generic;
using System.Text;
//using System.Linq;

namespace consoleTraining
{
    class Program
    {
        static void Main(string[] args)
        {
            string path = Console.ReadLine();

            List<string> coords = new List<string>();
            coords.Add("0;0");
            int lastX = 0, lastY = 0; char lastCh = path[0];
            foreach (char ch in path)
            {
                if (ch == 'L') { lastX--; }
                if (ch == 'R') { lastX++; }
                if (ch == 'U') { lastY++; }
                if (ch == 'D') { lastY--; }
                string[] checkStrs = strs(ch, lastX, lastY);
                foreach (string checkStr in checkStrs) if (coords.Contains(checkStr)) { Console.WriteLine("BUG"); return; }
                if ((ch == 'L' && lastCh == 'R') || (ch == 'R' && lastCh == 'L') || (ch == 'U' && lastCh == 'D') || (ch == 'D' && lastCh == 'U')) { Console.WriteLine("BUG"); return; }
                coords.Add(string.Format("{0};{1}", lastX, lastY));
            }
            Console.WriteLine("OK");
        }

        static string[] strs(char ch, int x, int y)
        {
            List<string> checkCoords = new List<string>();
            string up = string.Format("{0};{1}", x, y + 1);
            string down = string.Format("{0};{1}", x, y - 1);
            string left = string.Format("{0};{1}", x - 1, y);
            string right = string.Format("{0};{1}", x + 1, y);
            if (ch == 'U') { checkCoords.Add(up); checkCoords.Add(right); checkCoords.Add(left); }
            if (ch == 'D') { checkCoords.Add(down); checkCoords.Add(right); checkCoords.Add(left); }
            if (ch == 'L') { checkCoords.Add(up); checkCoords.Add(down); checkCoords.Add(left); }
            if (ch == 'R') { checkCoords.Add(up); checkCoords.Add(right); checkCoords.Add(down); }
            return checkCoords.ToArray();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Text;
//using System.Linq;

namespace consoleTraining
{
    class Program
    {
        static void Main(string[] args)
        {
            string path = Console.ReadLine();

            List<string> coords = new List<string>();
            coords.Add("0;0");
            int lastX = 0, lastY = 0;
            foreach (char ch in path)
            {
                if (ch == 'L') { lastX--; }
                if (ch == 'R') { lastX++; }
                if (ch == 'U') { lastY++; }
                if (ch == 'D') { lastY--; }
                string[] checkStrs = strs(ch, lastX, lastY);
                foreach (string checkStr in checkStrs) if (coords.Contains(checkStr)) { Console.WriteLine("BUG"); return; }
                coords.Add(string.Format("{0};{1}", lastX, lastY));
            }
            Console.WriteLine("OK");
        }

        static string[] strs(char ch, int x, int y)
        {
            List<string> checkCoords = new List<string>();
            string up = string.Format("{0};{1}", x, y + 1);
            string down = string.Format("{0};{1}", x, y - 1);
            string left = string.Format("{0};{1}", x - 1, y);
            string right = string.Format("{0};{1}", x + 1, y);
            if (ch == 'U') { checkCoords.Add(up); checkCoords.Add(right); checkCoords.Add(left); }
            if (ch == 'D') { checkCoords.Add(down); checkCoords.Add(right); checkCoords.Add(left); }
            if (ch == 'L') { checkCoords.Add(up); checkCoords.Add(down); checkCoords.Add(left); }
            if (ch == 'R') { checkCoords.Add(up); checkCoords.Add(right); checkCoords.Add(down); }
            return checkCoords.ToArray();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    private static void Solve()
    {
        int xs = RI();
        int ys = RI();
        int n = RI();
        int[] x = new int[n];
        int[] y = new int[n];
        for (int i = 0; i < n; i++)
        {
            x[i] = RI() - xs;
            y[i] = RI() - ys;
        }

    }

    static void Main(string[] args)
    {
        int[,] map = new int[222, 222];

        int x = 105;
        int y = 105;
        map[x, y] = 1;
        foreach (char ch in Console.ReadLine())
        {
            if (ch == 'U') y++;
            if (ch == 'D') y--;
            if (ch == 'L') x--;
            if (ch == 'R') x++;
            map[x, y] = 1;

            int count = map[x - 1, y] + map[x + 1, y] + map[x, y - 1] + map[x, y + 1];

            if (count > 1)
            {
                Console.WriteLine("BUG");
                return;
            }
        }

        Console.WriteLine("OK");
    }

    private const int Mod = 1000000000 + 7;

    #region Data Read
    private static char ReadSign()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans == '+' || ans == '-' || ans == '?')
                return (char)ans;
        }
    }

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

    private static List<int>[] ReadGraph(int n, int m)
    {
        List<int>[] g = new List<int>[n];
        for (int i = 0; i < g.Length; i++) g[i] = new List<int>();
        for (int i = 0; i < m; i++)
        {
            int a = RI() - 1;
            int b = RI() - 1;

            g[a].Add(b);
            g[b].Add(a);
        }

        return g;
    }

    private static int[,] ReadGraphAsMatrix(int n, int m)
    {
        int[,] matrix = new int[n + 1, n + 1];
        for (int i = 0; i < m; i++)
        {
            int a = RI();
            int b = RI();
            matrix[a, b] = matrix[b, a] = 1;
        }

        return matrix;
    }

    private static void Sort(ref int a, ref int b)
    {
        if (a > b) Swap(ref a, ref b);
    }

    private static void Swap(ref int a, ref int b)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }

    private const int BufferSize = 1 << 16;
    private static StreamReader consoleReader;
    private static MemoryStream testData;

    private static int RI()
    {
        int ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static ulong RUL()
    {
        ulong ans = 0;
        int chr;
        do
        {
            chr = consoleReader.Read();
            if (chr == -1)
                return 0;
        } while (chr < '0' || chr > '9');

        ans = (uint)(chr - '0');
        while (true)
        {
            chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans;
            ans = ans * 10 + (uint)(chr - '0');
        }
    }

    private static long RL()
    {
        long ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static int[] RIA(int n)
    {
        int[] ans = new int[n];
        for (int i = 0; i < n; i++)
            ans[i] = RI();
        return ans;
    }

    private static long[] RLA(int n)
    {
        long[] ans = new long[n];
        for (int i = 0; i < n; i++)
            ans[i] = RL();
        return ans;
    }

    private static char[] ReadWord()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        List<char> s = new List<char>();
        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s.ToArray();
    }

    private static char[] ReadString(int n)
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        char[] s = new char[n];
        int pos = 0;
        do
        {
            s[pos++] = (char)ans;
            if (pos == n) break;
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s;
    }

    private static char[] ReadStringLine()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (ans == 10 || ans == 13);

        List<char> s = new List<char>();

        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while (ans != 10 && ans != 13);

        return s.ToArray();
    }

    private static char ReadLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))
                return (char)ans;
        }
    }
    private static char ReadNonLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')))
                return (char)ans;
        }
    }

    private static char ReadAnyOf(IEnumerable<char> allowed)
    {
        while (true)
        {
            char ans = (char)consoleReader.Read();
            if (allowed.Contains(ans))
                return ans;
        }
    }

    private static char ReadDigit()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans >= '0' && ans <= '9')
                return (char)ans;
        }
    }

    private static int ReadDigitInt()
    {
        return ReadDigit() - (int)'0';
    }

    private static char ReadAnyChar()
    {
        return (char)consoleReader.Read();
    }

    private static string DoubleToString(double x)
    {
        return x.ToString(CultureInfo.InvariantCulture);
    }

    private static double DoubleFromString(string x)
    {
        return double.Parse(x, CultureInfo.InvariantCulture);
    }

    static Program()
    {
        //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);
    }

    private static void PushTestData(StringBuilder sb)
    {
        PushTestData(sb.ToString());
    }
    private static void PushTestData(string data)
    {
#if TOLYAN_TEST
        if (testData == null)
        {
            testData = new MemoryStream();
            consoleReader = new StreamReader(testData);
        }

        var pos = testData.Position;
        var bytes = Encoding.UTF8.GetBytes(data);
        testData.Write(bytes, 0, bytes.Length);
        testData.Flush();
        testData.Position = pos;
#endif
    }
    #endregion
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        int[,] map = new int[222, 222];

        int x = 105;
        int y = 105;
        map[x, y] = 1;
        foreach (char ch in Console.ReadLine())
        {
            if (ch == 'U') y++;
            if (ch == 'D') y--;
            if (ch == 'L') x--;
            if (ch == 'R') x++;

            int count = map[x - 1, y] + map[x + 1, y] + map[x, y - 1] + map[x, y + 1];

            if (count > 1)
            {
                Console.WriteLine("BUG");
                return;
            }
        }

        Console.WriteLine("OK");
    }

    private const int Mod = 1000000000 + 7;

    #region Data Read
    private static char ReadSign()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans == '+' || ans == '-' || ans == '?')
                return (char)ans;
        }
    }

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

    private static List<int>[] ReadGraph(int n, int m)
    {
        List<int>[] g = new List<int>[n];
        for (int i = 0; i < g.Length; i++) g[i] = new List<int>();
        for (int i = 0; i < m; i++)
        {
            int a = RI() - 1;
            int b = RI() - 1;

            g[a].Add(b);
            g[b].Add(a);
        }

        return g;
    }

    private static int[,] ReadGraphAsMatrix(int n, int m)
    {
        int[,] matrix = new int[n + 1, n + 1];
        for (int i = 0; i < m; i++)
        {
            int a = RI();
            int b = RI();
            matrix[a, b] = matrix[b, a] = 1;
        }

        return matrix;
    }

    private static void Sort(ref int a, ref int b)
    {
        if (a > b) Swap(ref a, ref b);
    }

    private static void Swap(ref int a, ref int b)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }

    private const int BufferSize = 1 << 16;
    private static StreamReader consoleReader;
    private static MemoryStream testData;

    private static int RI()
    {
        int ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static ulong RUL()
    {
        ulong ans = 0;
        int chr;
        do
        {
            chr = consoleReader.Read();
            if (chr == -1)
                return 0;
        } while (chr < '0' || chr > '9');

        ans = (uint)(chr - '0');
        while (true)
        {
            chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans;
            ans = ans * 10 + (uint)(chr - '0');
        }
    }

    private static long RL()
    {
        long ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static int[] RIA(int n)
    {
        int[] ans = new int[n];
        for (int i = 0; i < n; i++)
            ans[i] = RI();
        return ans;
    }

    private static long[] RLA(int n)
    {
        long[] ans = new long[n];
        for (int i = 0; i < n; i++)
            ans[i] = RL();
        return ans;
    }

    private static char[] ReadWord()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        List<char> s = new List<char>();
        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s.ToArray();
    }

    private static char[] ReadString(int n)
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        char[] s = new char[n];
        int pos = 0;
        do
        {
            s[pos++] = (char)ans;
            if (pos == n) break;
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s;
    }

    private static char[] ReadStringLine()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (ans == 10 || ans == 13);

        List<char> s = new List<char>();

        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while (ans != 10 && ans != 13);

        return s.ToArray();
    }

    private static char ReadLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))
                return (char)ans;
        }
    }
    private static char ReadNonLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')))
                return (char)ans;
        }
    }

    private static char ReadAnyOf(IEnumerable<char> allowed)
    {
        while (true)
        {
            char ans = (char)consoleReader.Read();
            if (allowed.Contains(ans))
                return ans;
        }
    }

    private static char ReadDigit()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans >= '0' && ans <= '9')
                return (char)ans;
        }
    }

    private static int ReadDigitInt()
    {
        return ReadDigit() - (int)'0';
    }

    private static char ReadAnyChar()
    {
        return (char)consoleReader.Read();
    }

    private static string DoubleToString(double x)
    {
        return x.ToString(CultureInfo.InvariantCulture);
    }

    private static double DoubleFromString(string x)
    {
        return double.Parse(x, CultureInfo.InvariantCulture);
    }

    static Program()
    {
        //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);
    }

    private static void PushTestData(StringBuilder sb)
    {
        PushTestData(sb.ToString());
    }
    private static void PushTestData(string data)
    {
#if TOLYAN_TEST
        if (testData == null)
        {
            testData = new MemoryStream();
            consoleReader = new StreamReader(testData);
        }

        var pos = testData.Position;
        var bytes = Encoding.UTF8.GetBytes(data);
        testData.Write(bytes, 0, bytes.Length);
        testData.Flush();
        testData.Position = pos;
#endif
    }
    #endregion
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        bool[,] map = new bool[222, 222];

        int x = 102;
        int y = 102;
        map[x, y] = true;
        foreach(char ch in Console.ReadLine())
        {
            if (ch == 'U') y++;
            if (ch == 'D') y--;
            if (ch == 'L') x--;
            if (ch == 'R') x++;

            if (map[x, y])
            {
                Console.WriteLine("BUG");
                return;
            }
        }

        Console.WriteLine("OK");
    }

    private const int Mod = 1000000000 + 7;

    #region Data Read
    private static char ReadSign()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans == '+' || ans == '-' || ans == '?')
                return (char)ans;
        }
    }

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

    private static List<int>[] ReadGraph(int n, int m)
    {
        List<int>[] g = new List<int>[n];
        for (int i = 0; i < g.Length; i++) g[i] = new List<int>();
        for (int i = 0; i < m; i++)
        {
            int a = RI() - 1;
            int b = RI() - 1;

            g[a].Add(b);
            g[b].Add(a);
        }

        return g;
    }

    private static int[,] ReadGraphAsMatrix(int n, int m)
    {
        int[,] matrix = new int[n + 1, n + 1];
        for (int i = 0; i < m; i++)
        {
            int a = RI();
            int b = RI();
            matrix[a, b] = matrix[b, a] = 1;
        }

        return matrix;
    }

    private static void Sort(ref int a, ref int b)
    {
        if (a > b) Swap(ref a, ref b);
    }

    private static void Swap(ref int a, ref int b)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }

    private const int BufferSize = 1 << 16;
    private static StreamReader consoleReader;
    private static MemoryStream testData;

    private static int RI()
    {
        int ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static ulong RUL()
    {
        ulong ans = 0;
        int chr;
        do
        {
            chr = consoleReader.Read();
            if (chr == -1)
                return 0;
        } while (chr < '0' || chr > '9');

        ans = (uint)(chr - '0');
        while (true)
        {
            chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans;
            ans = ans * 10 + (uint)(chr - '0');
        }
    }

    private static long RL()
    {
        long ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static int[] RIA(int n)
    {
        int[] ans = new int[n];
        for (int i = 0; i < n; i++)
            ans[i] = RI();
        return ans;
    }

    private static long[] RLA(int n)
    {
        long[] ans = new long[n];
        for (int i = 0; i < n; i++)
            ans[i] = RL();
        return ans;
    }

    private static char[] ReadWord()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        List<char> s = new List<char>();
        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s.ToArray();
    }

    private static char[] ReadString(int n)
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        char[] s = new char[n];
        int pos = 0;
        do
        {
            s[pos++] = (char)ans;
            if (pos == n) break;
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s;
    }

    private static char[] ReadStringLine()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (ans == 10 || ans == 13);

        List<char> s = new List<char>();

        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while (ans != 10 && ans != 13);

        return s.ToArray();
    }

    private static char ReadLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))
                return (char)ans;
        }
    }
    private static char ReadNonLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')))
                return (char)ans;
        }
    }

    private static char ReadAnyOf(IEnumerable<char> allowed)
    {
        while (true)
        {
            char ans = (char)consoleReader.Read();
            if (allowed.Contains(ans))
                return ans;
        }
    }

    private static char ReadDigit()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans >= '0' && ans <= '9')
                return (char)ans;
        }
    }

    private static int ReadDigitInt()
    {
        return ReadDigit() - (int)'0';
    }

    private static char ReadAnyChar()
    {
        return (char)consoleReader.Read();
    }

    private static string DoubleToString(double x)
    {
        return x.ToString(CultureInfo.InvariantCulture);
    }

    private static double DoubleFromString(string x)
    {
        return double.Parse(x, CultureInfo.InvariantCulture);
    }

    static Program()
    {
        //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);
    }

    private static void PushTestData(StringBuilder sb)
    {
        PushTestData(sb.ToString());
    }
    private static void PushTestData(string data)
    {
#if TOLYAN_TEST
        if (testData == null)
        {
            testData = new MemoryStream();
            consoleReader = new StreamReader(testData);
        }

        var pos = testData.Position;
        var bytes = Encoding.UTF8.GetBytes(data);
        testData.Write(bytes, 0, bytes.Length);
        testData.Flush();
        testData.Position = pos;
#endif
    }
    #endregion
}

/*******************************************************************************
* Author: Nirushuu
*******************************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.IO;
using System.Globalization;
using System.Numerics;

/*******************************************************************************
* IO from Kattio.cs from open.kattis.com/help/csharp                          */
public class NoMoreTokensException : Exception
{
}

public class Tokenizer
{
    string[] tokens = new string[0];
    private int pos;
    StreamReader reader;

    public Tokenizer(Stream inStream)
    {
        var bs = new BufferedStream(inStream);
        reader = new StreamReader(bs);
    }

    public Tokenizer() : this(Console.OpenStandardInput())
    {
        // Nothing more to do
    }

    private string PeekNext()
    {
        if (pos < 0)
            // pos < 0 indicates that there are no more tokens
            return null;
        if (pos < tokens.Length)
        {
            if (tokens[pos].Length == 0)
            {
                ++pos;
                return PeekNext();
            }
            return tokens[pos];
        }
        string line = reader.ReadLine();
        if (line == null)
        {
            // There is no more data to read
            pos = -1;
            return null;
        }
        // Split the line that was read on white space characters
        tokens = line.Split(null);
        pos = 0;
        return PeekNext();
    }

    public bool HasNext()
    {
        return (PeekNext() != null);
    }

    public string Next()
    {
        string next = PeekNext();
        if (next == null)
            throw new NoMoreTokensException();
        ++pos;
        return next;
    }
}

public class Scanner : Tokenizer
{

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public float NextFloat()
    {
        return float.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }
}

public class BufferedStdoutWriter : StreamWriter
{
    public BufferedStdoutWriter() : base(new BufferedStream(Console.OpenStandardOutput()))
    {
    }
}
/******************************************************************************/

/*******************************************************************************
* DisjointSet datastructure                                                   */
public struct DisjointSet {
    public int[] parent;
    public int[] rank;
    public DisjointSet(int n) {
        parent = new int[n];
        for (int i = 0; i < n; ++i) {
            parent[i] = i;
        }
        rank = new int[n];
    }

    public int Find(int i) {
        int idx = i;
        var compress = new List<int>();
        while (idx != parent[idx]) {
            compress.Add(idx);
            idx = parent[idx];
        }

        foreach (var e in compress) {   // path compress
            parent[e] = idx;
        }
        return idx;
    }

    public void Union(int a, int b) {
        int aPar = this.Find(a);
        int bPar = this.Find(b);

        if (rank[aPar] > rank[bPar]) {  // by rank
            parent[bPar] = aPar;
        } else {
            parent[aPar] = bPar;
        }
        if (rank[aPar] == rank[bPar]) {
            ++rank[bPar];
        }
    }
}

class MaxHeap {
    List<int> data;

    public MaxHeap() {
        data = new List<int>();
    }

    public void Add(int a) {
        data.Add(a);
        int idx = data.Count - 1;
        int parent = (int) Math.Floor((double) (idx - 1) / 2);
        while (idx != 0 && (data[idx] > data[parent])) {
            int tmp = data[parent];
            data[parent] = data[idx];
            data[idx] = tmp;

            idx = parent;
            parent = (int) Math.Floor((double) (idx - 1) / 2);
        }
    }

    public int Pop() {
        int res = data[0];
        data[0] = data[data.Count - 1];
        data.RemoveAt(data.Count - 1);

        int idx = 0;
        while (true) {
            int child1 = (2 * idx) + 1;
            int child2 = (2 * idx) + 2;

            if (child1 >= data.Count) { // no children
                break;
            } else if (child2 >= data.Count) {  // one child
                if (data[idx] < data[child1]) {
                    int tmp = data[idx];
                    data[idx] = data[child1];
                    data[child1] = tmp;
                }
                break;
            } else {    // two children
                int maxChild = data[child1] > data[child2] ? child1 : child2;
                if (data[idx] < data[maxChild]) {
                    int tmp = data[idx];
                    data[idx] = data[maxChild];
                    data[maxChild] = tmp;
                    idx = maxChild;
                    continue;
                } else {    // no swap
                    break;
                }
            }
        }

        return res;
    }

}

class Dequeue {
    public Dictionary<int, int> data = new Dictionary<int, int>();
    int firstIdx;
    public int Count;
    public Dequeue() {
        data = new Dictionary<int, int>();
        firstIdx = 1;
        Count = 0;
    }

    public void PushFront(int a) {
        data[firstIdx - 1] = a;
        ++Count;
        --firstIdx;
    }

    public void PushBack(int a) {
        data[firstIdx + Count] = a;
        ++Count;
    }

    public int PopFront() {
        --Count;
        ++firstIdx;
        return data[firstIdx - 1];
    }

    public int PopBack() {
        --Count;
        return data[firstIdx + Count];
    }

    public int Get(int n) {
        return data[firstIdx + n];
    }
}
/******************************************************************************/

class MainClass {

    // Debug functions
    static void debug<T>(IEnumerable<T> a, string s = "") {
        Console.WriteLine($"name: {s}");
        int i = 0;
        foreach (var e in a) {
            Console.WriteLine($"value {i}: {e}");
            ++i;
        }
    }
    static void dbg<T>(T a, string s = "") {
        Console.WriteLine($"name: {s} value: {a}");
    }
    ////////////////////

    static int gcd(int a, int b) {
        while (b != 0) {
            int t = b;
            b = a % b;
            a = t;
        }
        return a;
    }

    // class PairInt{
    //     public int fst;
    //     public int snd;

    //     // void Add(Pair<int> p) {
    //     //     fst += p.fst;
    //     //     snd += p.snd;
    //     // }
    // }

    public static void Main() {

        var sc = new Scanner();
        var wr = new BufferedStdoutWriter();
        var dot = new NumberFormatInfo();
        dot.NumberDecimalSeparator = ".";

        // int T = sc.NextInt();

        // for (int t = 0; t < T; ++t) {
        // }

        string s = sc.Next();

        var visited = new HashSet<Tuple<int, int>>();
        var dir = new Dictionary<char, Tuple<int, int>>{
            {'R', new Tuple<int, int>(1, 0)},
            {'L', new Tuple<int, int>(-1, 0)},
            {'U', new Tuple<int, int>(0, 1)},
            {'D', new Tuple<int, int>(0, -1)}
        };

        var pos = new Tuple<int, int>(0, 0);
        visited.Add(pos);

        foreach (var e in s) {
            var prev = pos;
            pos = new Tuple<int, int>(pos.Item1 + dir[e].Item1, pos.Item2 + dir[e].Item2);

            visited.Add(pos);

            foreach (var d in dir.Values) {
                var nbr = new Tuple<int, int>(pos.Item1 + d.Item1, pos.Item2 + d.Item2);
                if (visited.Contains(nbr) && !(nbr.Equals(prev))) {
                    // wr.Write(e);
                    // wr.Write(pos);
                    // wr.Write(nbr);
                    wr.Write("BUG");
                    wr.Flush();
                    return;
                }
            }
        }

        // debug(pos);
        // foreach (var e in visited) {
        //     debug(e);
        // }

        wr.Write("OK");

        wr.Flush();

    }
}

using System;

namespace Beta82
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();

            int[,] coord = new int[100, 2];

            bool flag = false;
            int i = 0;
            int x=0,y=0;
            while (!flag&&i<line.Length)
            {
                switch (line[i])
                {
                    case 'L': coord[i, 0] = x - 1; coord[i, 1] = y; break;
                    case 'R': coord[i, 0] = x + 1; coord[i, 1] = y; break;
                    case 'U': coord[i, 0] = x;     coord[i, 1] = y+1; break;
                    case 'D': coord[i, 0] = x;     coord[i, 1] = y-1; break;
                    default: break;
                }
                x = coord[i, 0];
                y = coord[i, 1];
                int iter=0;
                for (int j = 0; j < i; j++)
                {
                    if ((coord[j,0]+1==coord[i,0])||(coord[j,0]-1==coord[i,0]))
                    {
                        if ((coord[j, 1] + 1 == coord[i, 1]) || (coord[j, 1] - 1 == coord[i, 1]))
                            iter++;
                    }
                }
                if (iter > 1)
                    flag = true;
                i++;
            }

            if (flag)
                Console.WriteLine("BUG");
            else
                Console.WriteLine("OK");
        }
    }
}

using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;

class Program
{

    void solve()
    {
        string t = Console.ReadLine();
        int n = t.Length;
        bool[,] vis = new bool[2 * n + 1, 2 * n + 1];
        int x = n;
        int y = n;
        vis[x, y] = true;
        bool ok = true;
        int ex = -1;
        int ey = -1;
        for (int i = 0; i < t.Length; i++)
        {
            int nx, ny;
            nx=x;
            ny=y;
            if (t[i] == 'D')
                ny--;
            if (t[i] == 'U')
                ny++;
            if (t[i] == 'L')
                nx--;
            if (t[i] == 'R')
                nx++;
            vis[nx, ny] = true;
            x = nx;
            y = ny;
            ex = x;
            ey = y;

        }
        if (!ok)
            ;
        else
        {
            int[,] d = new int[2 * n + 1, 2 * n + 1];
            d[n, n] = 0;
            for (int i = 0; i < 2 * n + 1; i++)
                for (int j = 0; j < 2 * n; j++)
                    if (i != n || j != n)
                        d[i, j] = -1;
            Queue<int> q = new Queue<int>();
            x = n;
            y = n;
            q.Enqueue(x);
            q.Enqueue(y);
            while (q.Count > 0)
            {
                x = q.Dequeue();
                y = q.Dequeue();
                for (int dx = -1; dx <= 1; dx++)
                    for (int dy = -1; dy <= 1; dy++)
                        if (dx == 0 ^ dy == 0)
                        {
                            int nx = x + dx;
                            int ny = y + dy;
                            if (nx < 0 || nx >= 2 * n || ny < 0 || ny >= 2 * n || !vis[nx, ny] || d[nx, ny] != -1)
                                continue;
                            d[nx, ny] = 1 + d[x, y];
                            q.Enqueue(nx);
                            q.Enqueue(ny);

                        }
            }
            if (d[ex, ey] == t.Length)
                Console.WriteLine("OK");
            else
                Console.WriteLine("BUG");
        }
       // Console.ReadLine();
    }

    static void Main(string[] args)
    {
        new Program().solve();
    }
}

using System;
using System.Text;

class Program
{

    void solve()
    {
        string t = Console.ReadLine();
        int n = t.Length;
        bool[,] vis = new bool[2 * n + 1, 2 * n + 1];
        int r = n;
        int c = n;
        vis[r, c] = true;
        bool ok = true;
        for (int i = 0; i < t.Length; i++)
        {
            int nr, nc;
            nr=r;
            nc=c;
            switch (t[i])
            {
                case 'D':
                    nr--;
                    break;
                case 'U':
                    nr++;
                    break;
                case 'L':
                    nc--;
                    break;
                default:
                    nc++;
                    break;
            }
            if (vis[nr, nc])
            {
                ok = false;
                break;
            }
            vis[nr, nc] = true;

        }
        if (ok)
            Console.WriteLine("OK");
        else
            Console.WriteLine("BUG");
    }

    static void Main(string[] args)
    {
        new Program().solve();
    }
}

using System;
using System.Text;

class Program
{

    void solve()
    {
        string t = Console.ReadLine();
        int n = t.Length;
        bool[,] vis = new bool[2 * n + 1, 2 * n + 1];
        int x = n;
        int y = n;
        vis[x, y] = true;
        bool ok = true;
        for (int i = 0; i < t.Length; i++)
        {
            int nx, ny;
            nx=x;
            ny=y;
            if (t[i] == 'D')
                ny--;
            if (t[i] == 'U')
                ny++;
            if (t[i] == 'L')
                nx--;
            if (t[i] == 'R')
                nx++;
            if (vis[nx, ny])
            {
                ok = false;
                break;
            }
            vis[nx, ny] = true;
            x = nx;
            y = ny;

        }
        if (ok)
            Console.WriteLine("OK");
        else
            Console.WriteLine("BUG");
        Console.ReadLine();
    }

    static void Main(string[] args)
    {
        new Program().solve();
    }
}

using System;
using System.Text;

class Program
{

    void solve()
    {
        string t = Console.ReadLine();
        int n = t.Length;
        bool[,] vis = new bool[2 * n + 1, 2 * n + 1];
        int r = n;
        int c = n;
        vis[r, c] = true;
        bool ok = true;
        for (int i = 0; i < t.Length; i++)
        {
            int nr, nc;
            nr=r;
            nc=c;
            switch (t[i])
            {
                case 'D':
                    nr--;
                    break;
                case 'U':
                    nr++;
                    break;
                case 'L':
                    nc--;
                    break;
                default:
                    nc++;
                    break;
            }
            if (vis[nr, nc])
            {
                ok = false;
                break;
            }
            vis[nr, nc] = true;
            r = nr;
            c = nc;

        }
        if (ok)
            Console.WriteLine("OK");
        else
            Console.WriteLine("BUG");
    }

    static void Main(string[] args)
    {
        new Program().solve();
    }
}

using System;
using System.Text;

class Program
{

    void solve()
    {
        string t = Console.ReadLine();
        int n = t.Length;
        bool[,] vis = new bool[2 * n + 1, 2 * n + 1];
        int r = n;
        int c = n;
        vis[r, c] = true;
        bool ok = true;
        for (int i = 0; i < t.Length; i++)
        {
            int nr, nc;
            nr=r;
            nc=c;
            switch (t[i])
            {
                case 'D':
                    nr++;
                    break;
                case 'U':
                    nr--;
                    break;
                case 'L':
                    nc--;
                    break;
                default:
                    nc++;
                    break;
            }
            if (vis[nr, nc])
            {
                ok = false;
                break;
            }
            vis[nr, nc] = true;
            r = nr;
            c = nc;

        }
        if (ok)
            Console.WriteLine("OK");
        else
            Console.WriteLine("BUG");
    }

    static void Main(string[] args)
    {
        new Program().solve();
    }
}

using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;

class Program
{

    void solve()
    {
        string t = Console.ReadLine();
        int n = t.Length;
        bool[,] vis = new bool[2 * n + 1, 2 * n + 1];
        int x = n;
        int y = n;
        vis[x, y] = true;
        bool ok = true;
        int ex = -1;
        int ey = -1;
        for (int i = 0; i < t.Length; i++)
        {
            int nx, ny;
            nx=x;
            ny=y;
            if (t[i] == 'D')
                ny--;
            if (t[i] == 'U')
                ny++;
            if (t[i] == 'L')
                nx--;
            if (t[i] == 'R')
                nx++;
            vis[nx, ny] = true;
            x = nx;
            y = ny;
            ex = x;
            ey = y;

        }
        if (!ok)
            ;
        else
        {
            int[,] d = new int[2 * n + 1, 2 * n + 1];
            d[n, n] = 0;
            for (int i = 0; i < 2 * n + 1; i++)
                for (int j = 0; j < 2 * n+1; j++)
                    if (i != n || j != n)
                        d[i, j] = -1;
            Queue<int> q = new Queue<int>();
            x = n;
            y = n;
            q.Enqueue(x);
            q.Enqueue(y);
            while (q.Count > 0)
            {
                x = q.Dequeue();
                y = q.Dequeue();
                for (int dx = -1; dx <= 1; dx++)
                    for (int dy = -1; dy <= 1; dy++)
                        if (dx == 0 ^ dy == 0)
                        {
                            int nx = x + dx;
                            int ny = y + dy;
                            if (nx < 0 || nx >= 2 * n || ny < 0 || ny >= 2 * n || !vis[nx, ny] || d[nx, ny] != -1)
                                continue;
                            d[nx, ny] = 1 + d[x, y];
                            q.Enqueue(nx);
                            q.Enqueue(ny);

                        }
            }
            if (d[ex, ey] == t.Length)
                Console.WriteLine("OK");
            else
                Console.WriteLine("BUG");
        }
       // Console.ReadLine();
    }

    static void Main(string[] args)
    {
        new Program().solve();
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace acm
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            int pos = 0;
            HashSet<int> vis = new HashSet<int>();
            vis.Add(pos);
            for (int i = 0; i < s.Length; ++i)
            {
                if (s[i] == 'U') pos += 1000;
                else if (s[i] == 'D') pos -= 1000;
                else if (s[i] == 'R') ++pos;
                else --pos;
                if (vis.Contains(pos))
                {
                    Console.WriteLine("BUG");
                    return;
                }
            }
            Console.WriteLine("OK");
        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace codeforces
{
    class C
    {
        static string _input =
@"
LLUUUR
";

        #region test

        static List<string> _lines;

        static string ReadLine()
        {
#if DEBUG
            if (_lines == null)
            {
                _lines = new List<string>();
                string[] ss = _input.Replace("\n", "").Split('\r');
                for (int i = 0; i < ss.Length; i++)
                {
                    if (
                        (i == 0 || i == ss.Length - 1) &&
                        ss[i].Length == 0
                        )
                        continue;

                    _lines.Add(ss[i]);
                }
            }

            string s = null;
            if (_lines.Count > 0)
            {
                s = _lines[0];
                _lines.RemoveAt(0);
            }
            return s;
#else
            return Console.In.ReadLine();
#endif
        }

        static void WriteLine(object o)
        {
#if DEBUG
            System.Diagnostics.Trace.WriteLine(o);
#else
            Console.WriteLine(o);
#endif
        }

        static void Write(object o)
        {
#if DEBUG
            System.Diagnostics.Trace.Write(o);
#else
            Console.Write(o);
#endif
        }
        #endregion

        static void Main(string[] args)
        {
            string s = ReadLine();

            //s = new string('U', 100);

            int x=0;
            int y=0;
            List<string> list = new List<string>();
            list.Add("0.0");

            foreach (char c in s)
            {
                switch (c)
                {
                    case 'U': y--; break;
                    case 'D': y++; break;
                    case 'R': x++; break;
                    case 'L': x--; break;
                }
                string key = x + "." + y;
                if (list.Contains(key))
                {
                    Write("BUG");
                    return;
                }
                list.Add(key);
            }
            Write("OK");
        }

    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;

class Problem
{
    const int INF = 1987654321;
    const string inFile = "..\\..\\test.in";

    public void Process()
    {
        TextReader reader = Console.In;

#if LOCAL_SITE_SUPERKINHLUAN
        // comment out this line when submit
        reader = new StreamReader(inFile);
#endif

        string s = reader.ReadLine();
        string res = Solve(s);
        Console.WriteLine(res);
    }

    private string Solve(string s)
    {
        bool[,] a = new bool[300, 300];
        int x = 150, y = 150;
        for (int i = 0; i < s.Length; i++)
        {
            a[x,y] = true;
            char c = s[i];
            if (c == 'U') x++;
            else if (c == 'D') x--;
            else if (c == 'L') y++;
            else if (c == 'R') y--;

            if (a[x, y])
                return "BUG";
        }
        return "OK";
    }

    public static void Main()
    {
        Problem p = new Problem();
        p.Process();
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static byte[][] matr;

        static void Main(string[] args)
        {
            matr = new byte[300][];
            for (int i = 0; i < 300; i++) matr[i] = new byte[300];
            string path = Console.ReadLine();
            int col = 150;
            int row = 150;
            matr[col][row] = 1;
            char[] pathChar = path.ToCharArray();
            for (int i = 0; i < path.Length; i++)
            {
                if (pathChar[i] == 'U') row++;
                if (pathChar[i] == 'D') row--;
                if (pathChar[i] == 'R') col++;
                if (pathChar[i] == 'L') col--;
                if (matr[col][row] == 0) matr[col][row] = 1;
                else
                {
                    Console.WriteLine("BUG");
                    Console.ReadKey();
                    return;
                }
            }
            Console.WriteLine("OK");
            Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static byte[][] matr;

        static void Main(string[] args)
        {
            matr = new byte[300][];
            for (int i = 0; i < 300; i++) matr[i] = new byte[300];
            string path = Console.ReadLine();
            int col = 150;
            int row = 150;
            matr[col][row] = 1;
            char[] pathChar = path.ToCharArray();
            for (int i = 0; i < path.Length; i++)
            {
                if (pathChar[i] == 'U') row++;
                if (pathChar[i] == 'D') row--;
                if (pathChar[i] == 'R') col++;
                if (pathChar[i] == 'L') col--;
                if (matr[col][row] == 0
                    && matr[col - 1][row] == 0
                    && matr[col + 1][row] == 0
                    && matr[col][row - 1] == 0
                    && matr[col][row + 1] == 0
                    ) matr[col][row] = 1;
                else
                {
                    Console.WriteLine("BUG");
                    Console.ReadKey();
                    return;
                }
            }
            Console.WriteLine("OK");
            Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace b
{
    class Program
    {

        class Point
        {
            public Point(int x, int y)
            {
                this.x = x;
                this.y = y;
            }

            public bool Eq(Point an)
            {
                return (this.x == an.x && this.y == an.y);
            }

            public int x, y;
        }

        static void Main(string[] args)
        {
            string way = Console.ReadLine();
            Point[] pts = new Point[way.Length+1];
            pts[0] = new Point(0, 0);
            bool bug = false;
            for (int i = 0; i < way.Length; i++)
            {

                switch (way[i])
                {
                    case 'L':
                        pts[i + 1] = new Point(pts[i].x-1, pts[i].y);
                        break;
                    case 'R':
                        pts[i + 1] = new Point(pts[i].x+1, pts[i].y);
                        break;
                    case 'U':
                        pts[i + 1] = new Point(pts[i].x, pts[i].y+1);
                        break;
                    case 'D':
                        pts[i + 1] = new Point(pts[i].x, pts[i].y-1);
                        break;
                }

                for (int j = 0; j < i + 1; j++)
                {
                    if (pts[i+1].Eq(pts[j]))
                    {
                        bug = true;
                        break;
                    }
                }
                if (bug) break;
            }
            if (bug) Console.WriteLine("BUG");
            else Console.WriteLine("OK");
        }
    }
}