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

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

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

class D:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

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

d = A("d")
e = B("e")
a = C("a")
f = D("f")
h = E("h")

d.p = e
e.z = h
e.t = h
a.p = f
f.r = h
h.o = d
h.y = f
assert a.p.r.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

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

d = A("d")
e = B("e")
a = C("a")
f = D("f")
h = E("h")

d.p = e
e.z = h
e.t = h
a.p = f
f.r = h
h.o = d
h.y = f
assert a.p.r.y.r.txt == "h"