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

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

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

class D:
    def __init__(self, txt: str):
        self.t: A = None
        self.y: D = None
        self.r: C = None
        self.txt = txt

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.t: A = None
        self.y: D = None
        self.r: C = None
        self.txt = txt

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

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