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

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

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

e = A("e")
c = B("c")
b = C("b")
a = B("a")
m = A("m")
d = C("d")
j = A("j")

e.q = a
e.o = b
e.y = d
c.t = j
b.p = c
b.s = d
a.t = m
m.q = a
m.o = d
m.y = b
d.p = c
d.s = b
j.q = c
j.o = b
j.y = d
assert b.p.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.o: C = None
        self.y: C = None
        self.txt = txt

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

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

e = A("e")
c = B("c")
b = C("b")
a = B("a")
m = A("m")
d = C("d")
j = A("j")

e.q = a
e.o = b
e.y = d
c.t = j
b.p = c
b.s = d
a.t = m
m.q = a
m.o = d
m.y = b
d.p = c
d.s = b
j.q = c
j.o = b
j.y = d
assert b.p.t.y.txt == "d"