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

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

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

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

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

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

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

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

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

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

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

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

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