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

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

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

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

i = A("i")
b = B("b")
e = C("e")
a = D("a")
m = A("m")

i.q = b
i.p = b
i.y = e
i.z = e
b.t = i
b.o = a
b.u = a
b.v = e
e.x = a
e.v = a
a.s = b
m.q = b
m.p = b
m.y = e
m.z = e
assert a.s.v.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.y: C = None
        self.p: B = None
        self.z: C = None
        self.txt = txt

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

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

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

i = A("i")
b = B("b")
e = C("e")
a = D("a")
m = A("m")

i.q = b
i.p = b
i.y = e
i.z = e
b.t = i
b.o = a
b.u = a
b.v = e
e.x = a
e.v = a
a.s = b
m.q = b
m.p = b
m.y = e
m.z = e
assert a.s.v.x.s.txt == "b"