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

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

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

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

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

j.u = i
j.w = m
f.z = j
f.y = m
f.r = l
m.r = l
m.o = f
m.x = i
m.p = i
n.z = l
c.z = j
c.y = m
c.r = n
d.z = i
d.y = m
d.r = l
i.u = j
i.w = m
l.z = n
assert i.w.r.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.w: C = None
        self.txt = txt

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

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

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

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

j.u = i
j.w = m
f.z = j
f.y = m
f.r = l
m.r = l
m.o = f
m.x = i
m.p = i
n.z = l
c.z = j
c.y = m
c.r = n
d.z = i
d.y = m
d.r = l
i.u = j
i.w = m
l.z = n
assert i.w.r.z.z.z.txt == "n"