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

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

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

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

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

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

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

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

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

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

n.w = i
n.r = i
d.u = f
d.o = l
d.z = n
i.o = d
i.t = f
i.z = n
l.v = d
l.o = i
f.o = d
f.t = i
f.z = n
assert f.z.r.t.txt == "f"