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

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

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

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

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

m.u = d
m.o = d
m.v = k
k.o = m
j.q = k
j.u = m
j.z = d
j.t = c
d.o = m
d.v = m
d.q = c
c.q = k
c.u = m
c.z = d
c.t = j
assert j.z.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.v: B = None
        self.o: D = None
        self.txt = txt

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

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

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

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

m.u = d
m.o = d
m.v = k
k.o = m
j.q = k
j.u = m
j.z = d
j.t = c
d.o = m
d.v = m
d.q = c
c.q = k
c.u = m
c.z = d
c.t = j
assert j.z.q.z.txt == "d"