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

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

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

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

j = A("j")
a = B("a")
n = C("n")
l = D("l")
d = B("d")
k = D("k")

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

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

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

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

j = A("j")
a = B("a")
n = C("n")
l = D("l")
d = B("d")
k = D("k")

j.x = n
j.z = l
j.u = k
a.x = d
a.w = n
a.o = n
n.x = d
l.q = n
l.v = j
d.x = a
d.w = n
d.o = n
k.q = n
k.v = j
assert k.q.x.x.o.x.txt == "d"