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

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

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

m = A("m")
g = B("g")
a = C("a")
b = C("b")
e = A("e")

m.u = e
g.w = e
g.o = b
g.y = a
a.y = m
a.t = g
a.o = g
b.y = m
b.t = g
b.o = g
e.u = m
assert g.w.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

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

m = A("m")
g = B("g")
a = C("a")
b = C("b")
e = A("e")

m.u = e
g.w = e
g.o = b
g.y = a
a.y = m
a.t = g
a.o = g
b.y = m
b.t = g
b.o = g
e.u = m
assert g.w.u.u.u.txt == "m"