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

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

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

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

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

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

d.q = e
l.y = d
l.u = h
e.p = l
e.o = l
h.r = l
h.o = l
h.u = l
f.x = e
f.q = e
f.r = d
f.o = l
assert h.o.y.q.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

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

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

d.q = e
l.y = d
l.u = h
e.p = l
e.o = l
h.r = l
h.o = l
h.u = l
f.x = e
f.q = e
f.r = d
f.o = l
assert h.o.y.q.o.u.txt == "h"