class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.t: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.y: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.u: C = None
        self.y: C = None
        self.txt = txt

b = A("b")
c = B("c")
e = C("e")
n = A("n")
d = B("d")
g = C("g")
i = A("i")

b.o = n
b.t = g
c.x = n
c.y = d
e.u = g
e.y = g
n.o = i
n.t = e
d.x = n
d.y = c
g.u = e
g.y = e
i.o = b
i.t = g
assert g.u.u.y.y.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.t: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.y: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.u: C = None
        self.y: C = None
        self.txt = txt

b = A("b")
c = B("c")
e = C("e")
n = A("n")
d = B("d")
g = C("g")
i = A("i")

b.o = n
b.t = g
c.x = n
c.y = d
e.u = g
e.y = g
n.o = i
n.t = e
d.x = n
d.y = c
g.u = e
g.y = e
i.o = b
i.t = g
assert g.u.u.y.y.u.y.txt == "g"