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

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: D = None
        self.r: A = None
        self.v: B = None
        self.txt = txt

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

m = A("m")
e = B("e")
c = C("c")
f = D("f")
a = B("a")
i = D("i")
k = B("k")

m.q = e
e.w = c
e.u = c
e.q = f
c.w = e
c.q = i
c.r = m
c.v = a
f.x = e
f.q = e
a.w = c
a.u = c
a.q = i
i.x = e
i.q = a
k.w = c
k.u = c
k.q = f
assert a.q.q.w.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: D = None
        self.r: A = None
        self.v: B = None
        self.txt = txt

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

m = A("m")
e = B("e")
c = C("c")
f = D("f")
a = B("a")
i = D("i")
k = B("k")

m.q = e
e.w = c
e.u = c
e.q = f
c.w = e
c.q = i
c.r = m
c.v = a
f.x = e
f.q = e
a.w = c
a.u = c
a.q = i
i.x = e
i.q = a
k.w = c
k.u = c
k.q = f
assert a.q.q.w.v.q.txt == "i"