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

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

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

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

m = A("m")
c = B("c")
i = C("i")
d = D("d")
l = B("l")
a = D("a")
j = A("j")
e = D("e")
b = D("b")

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

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

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

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

m = A("m")
c = B("c")
i = C("i")
d = D("d")
l = B("l")
a = D("a")
j = A("j")
e = D("e")
b = D("b")

m.q = i
c.v = b
c.o = l
i.x = j
d.x = i
d.y = c
l.v = b
l.o = c
a.x = i
a.y = l
j.q = i
e.x = i
e.y = l
b.x = i
b.y = l
assert b.y.v.x.x.q.x.q.txt == "i"