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

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

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

f = A("f")
b = B("b")
d = C("d")
m = C("m")
k = B("k")
e = A("e")

f.o = e
f.r = d
f.u = m
b.y = d
d.u = e
d.q = k
m.u = f
m.q = b
k.y = d
e.o = f
e.r = d
e.u = m
assert b.y.q.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.r: C = None
        self.u: C = None
        self.txt = txt

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

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

f = A("f")
b = B("b")
d = C("d")
m = C("m")
k = B("k")
e = A("e")

f.o = e
f.r = d
f.u = m
b.y = d
d.u = e
d.q = k
m.u = f
m.q = b
k.y = d
e.o = f
e.r = d
e.u = m
assert b.y.q.y.u.txt == "e"