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

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

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

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

j = A("j")
l = B("l")
i = C("i")
k = D("k")
m = C("m")
d = D("d")

j.p = d
j.o = l
j.z = l
j.x = i
l.v = j
i.o = l
k.u = d
k.o = i
k.q = i
m.o = l
d.u = k
d.o = m
d.q = i
assert m.o.v.p.q.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.o: B = None
        self.x: C = None
        self.z: B = None
        self.txt = txt

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

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

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

j = A("j")
l = B("l")
i = C("i")
k = D("k")
m = C("m")
d = D("d")

j.p = d
j.o = l
j.z = l
j.x = i
l.v = j
i.o = l
k.u = d
k.o = i
k.q = i
m.o = l
d.u = k
d.o = m
d.q = i
assert m.o.v.p.q.o.v.txt == "j"