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

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

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

j = A("j")
k = B("k")
d = C("d")
a = A("a")
l = B("l")
m = B("m")

j.t = d
j.o = d
j.p = k
k.u = d
d.w = a
a.t = d
a.o = d
a.p = k
l.u = d
m.u = d
assert l.u.w.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.p: B = None
        self.o: C = None
        self.txt = txt

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

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

j = A("j")
k = B("k")
d = C("d")
a = A("a")
l = B("l")
m = B("m")

j.t = d
j.o = d
j.p = k
k.u = d
d.w = a
a.t = d
a.o = d
a.p = k
l.u = d
m.u = d
assert l.u.w.t.w.txt == "a"