class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

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

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

m = A("m")
e = B("e")
k = C("k")
a = D("a")
j = E("j")
c = B("c")
f = A("f")
d = A("d")
l = D("l")

m.y = l
e.w = c
k.z = d
a.p = d
j.w = c
c.w = e
f.y = l
d.y = l
l.p = f
assert m.y.p.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

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

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

m = A("m")
e = B("e")
k = C("k")
a = D("a")
j = E("j")
c = B("c")
f = A("f")
d = A("d")
l = D("l")

m.y = l
e.w = c
k.z = d
a.p = d
j.w = c
c.w = e
f.y = l
d.y = l
l.p = f
assert m.y.p.y.p.txt == "f"