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

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

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

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

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

j.r = i
j.u = f
j.z = n
m.z = f
m.w = f
m.s = l
m.o = i
n.t = i
n.z = i
n.v = m
i.q = l
f.r = i
f.u = l
f.z = n
l.r = i
l.u = f
l.z = n
assert l.r.q.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.u: A = None
        self.z: C = None
        self.txt = txt

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

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

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

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

j.r = i
j.u = f
j.z = n
m.z = f
m.w = f
m.s = l
m.o = i
n.t = i
n.z = i
n.v = m
i.q = l
f.r = i
f.u = l
f.z = n
l.r = i
l.u = f
l.z = n
assert l.r.q.u.r.txt == "i"