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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: C = None
        self.w: A = None
        self.t: A = None
        self.z: C = None
        self.q: A = None
        self.txt = txt

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

f.x = h
f.y = d
h.z = f
k.y = l
m.x = f
l.y = k
l.z = k
l.w = f
l.t = f
l.q = f
d.y = k
d.z = k
d.w = f
d.t = f
d.q = f
assert m.x.x.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.y: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: C = None
        self.w: A = None
        self.t: A = None
        self.z: C = None
        self.q: A = None
        self.txt = txt

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

f.x = h
f.y = d
h.z = f
k.y = l
m.x = f
l.y = k
l.z = k
l.w = f
l.t = f
l.q = f
d.y = k
d.z = k
d.w = f
d.t = f
d.q = f
assert m.x.x.z.x.txt == "h"