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

class B:
    def __init__(self, txt: str):
        self.z: C = None
        self.x: C = 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.q: A = None
        self.txt = txt

j = A("j")
c = B("c")
k = C("k")
n = D("n")
l = A("l")

j.w = l
j.o = l
c.z = k
c.x = k
k.z = n
n.v = k
n.q = j
l.w = j
l.o = j
assert j.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.o: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: C = None
        self.x: C = 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.q: A = None
        self.txt = txt

j = A("j")
c = B("c")
k = C("k")
n = D("n")
l = A("l")

j.w = l
j.o = l
c.z = k
c.x = k
k.z = n
n.v = k
n.q = j
l.w = j
l.o = j
assert j.o.o.o.o.txt == "j"