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

class B:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

i = A("i")
c = B("c")
k = C("k")
b = D("b")

i.v = b
i.r = b
i.o = c
c.q = k
k.q = c
b.t = i
b.p = c
b.s = c
b.z = c
assert k.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.r: D = None
        self.o: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

i = A("i")
c = B("c")
k = C("k")
b = D("b")

i.v = b
i.r = b
i.o = c
c.q = k
k.q = c
b.t = i
b.p = c
b.s = c
b.z = c
assert k.q.q.q.q.txt == "k"