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

class B:
    def __init__(self, txt: str):
        self.q: E = None
        self.w: D = None
        self.t: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.w: C = None
        self.x: C = None
        self.z: C = None
        self.q: B = None
        self.v: C = None
        self.txt = txt

k = A("k")
h = B("h")
f = C("f")
a = D("a")
b = E("b")

k.t = h
k.u = a
h.q = b
h.t = b
h.w = a
f.q = h
f.s = k
a.z = k
b.w = f
b.x = f
b.z = f
b.v = f
b.q = h
assert a.z.t.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.u: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: E = None
        self.w: D = None
        self.t: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.w: C = None
        self.x: C = None
        self.z: C = None
        self.q: B = None
        self.v: C = None
        self.txt = txt

k = A("k")
h = B("h")
f = C("f")
a = D("a")
b = E("b")

k.t = h
k.u = a
h.q = b
h.t = b
h.w = a
f.q = h
f.s = k
a.z = k
b.w = f
b.x = f
b.z = f
b.v = f
b.q = h
assert a.z.t.q.v.txt == "f"