class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.x: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.y: D = None
        self.t: B = None
        self.txt = txt

a = A("a")
f = B("f")
n = C("n")
d = D("d")
b = E("b")
l = C("l")

a.p = d
a.x = b
f.z = b
n.t = f
d.t = l
b.y = d
b.t = f
l.t = f
assert b.t.z.t.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.x: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.y: D = None
        self.t: B = None
        self.txt = txt

a = A("a")
f = B("f")
n = C("n")
d = D("d")
b = E("b")
l = C("l")

a.p = d
a.x = b
f.z = b
n.t = f
d.t = l
b.y = d
b.t = f
l.t = f
assert b.t.z.t.z.t.txt == "f"