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

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

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

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

n = A("n")
b = B("b")
a = C("a")
j = D("j")
e = B("e")
i = D("i")

n.s = a
n.y = a
n.z = a
b.z = j
b.o = n
a.z = j
j.v = a
e.z = i
e.o = n
i.v = a
assert i.v.z.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.y: C = None
        self.z: C = None
        self.txt = txt

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

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

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

n = A("n")
b = B("b")
a = C("a")
j = D("j")
e = B("e")
i = D("i")

n.s = a
n.y = a
n.z = a
b.z = j
b.o = n
a.z = j
j.v = a
e.z = i
e.o = n
i.v = a
assert i.v.z.v.z.txt == "j"