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

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

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

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

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

c.q = i
c.v = i
a.v = e
i.v = e
e.v = a
e.x = b
e.o = b
b.v = e
k.v = e
m.q = i
m.v = i
assert k.v.v.v.x.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.v: C = None
        self.txt = txt

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

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

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

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

c.q = i
c.v = i
a.v = e
i.v = e
e.v = a
e.x = b
e.o = b
b.v = e
k.v = e
m.q = i
m.v = i
assert k.v.v.v.x.v.v.txt == "a"