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

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

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

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

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

j.o = k
j.s = k
i.o = b
i.x = b
i.w = n
n.v = i
n.y = i
n.u = i
n.s = j
b.o = i
b.y = k
b.w = j
k.o = j
k.s = j
assert k.s.s.s.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.s: A = None
        self.txt = txt

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

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

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

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

j.o = k
j.s = k
i.o = b
i.x = b
i.w = n
n.v = i
n.y = i
n.u = i
n.s = j
b.o = i
b.y = k
b.w = j
k.o = j
k.s = j
assert k.s.s.s.s.o.txt == "j"