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

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

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

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

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

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

d.q = m
d.z = k
d.x = k
m.w = k
m.t = b
m.x = f
b.r = m
k.t = b
k.s = f
k.o = m
f.q = d
f.w = d
f.x = b
assert k.s.x.r.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.z: D = None
        self.x: D = None
        self.txt = txt

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

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

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

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

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

d.q = m
d.z = k
d.x = k
m.w = k
m.t = b
m.x = f
b.r = m
k.t = b
k.s = f
k.o = m
f.q = d
f.w = d
f.x = b
assert k.s.x.r.w.t.txt == "b"