class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.u: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: A = None
        self.t: B = None
        self.txt = txt

g = A("g")
b = B("b")
c = B("c")
a = A("a")
n = A("n")
i = A("i")

g.r = n
g.u = n
b.u = n
b.t = c
c.u = g
c.t = b
a.r = i
a.u = i
n.r = g
n.u = g
i.r = n
i.u = a
assert n.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.u: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: A = None
        self.t: B = None
        self.txt = txt

g = A("g")
b = B("b")
c = B("c")
a = A("a")
n = A("n")
i = A("i")

g.r = n
g.u = n
b.u = n
b.t = c
c.u = g
c.t = b
a.r = i
a.u = i
n.r = g
n.u = g
i.r = n
i.u = a
assert n.u.u.u.u.txt == "n"