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

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

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

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

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

c = A("c")
l = B("l")
h = C("h")
f = D("f")
a = E("a")

c.y = f
l.z = h
l.p = h
h.o = c
h.r = l
h.y = l
f.r = l
a.t = h
a.r = f
a.x = c
assert a.x.y.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

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

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

c = A("c")
l = B("l")
h = C("h")
f = D("f")
a = E("a")

c.y = f
l.z = h
l.p = h
h.o = c
h.r = l
h.y = l
f.r = l
a.t = h
a.r = f
a.x = c
assert a.x.y.r.z.txt == "h"