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

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

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

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

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

b = A("b")
h = B("h")
g = C("g")
a = D("a")
d = E("d")

b.p = d
h.o = g
g.s = h
g.z = h
g.x = b
g.r = b
a.p = b
a.z = b
d.t = g
assert h.o.r.p.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

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

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

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

b = A("b")
h = B("h")
g = C("g")
a = D("a")
d = E("d")

b.p = d
h.o = g
g.s = h
g.z = h
g.x = b
g.r = b
a.p = b
a.z = b
d.t = g
assert h.o.r.p.t.x.txt == "b"