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

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

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

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

k = A("k")
l = B("l")
a = C("a")
b = D("b")
i = B("i")

k.x = i
l.o = k
l.x = a
a.u = k
a.z = k
a.o = b
a.s = b
b.v = a
i.o = k
i.x = a
assert k.x.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

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

k = A("k")
l = B("l")
a = C("a")
b = D("b")
i = B("i")

k.x = i
l.o = k
l.x = a
a.u = k
a.z = k
a.o = b
a.s = b
b.v = a
i.o = k
i.x = a
assert k.x.x.u.txt == "k"