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

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

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

j = A("j")
n = B("n")
l = C("l")
m = A("m")
e = A("e")
b = C("b")

j.z = m
j.t = l
j.x = l
n.r = e
l.p = m
m.z = j
m.t = b
m.x = b
e.z = j
e.t = b
e.x = b
b.p = m
assert b.p.x.p.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.t: C = None
        self.x: C = None
        self.txt = txt

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

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

j = A("j")
n = B("n")
l = C("l")
m = A("m")
e = A("e")
b = C("b")

j.z = m
j.t = l
j.x = l
n.r = e
l.p = m
m.z = j
m.t = b
m.x = b
e.z = j
e.t = b
e.x = b
b.p = m
assert b.p.x.p.z.x.txt == "l"