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

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

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

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

d = A("d")
i = B("i")
l = C("l")
k = D("k")

d.v = l
i.t = d
l.v = k
k.q = l
k.y = i
k.v = d
assert i.t.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

d = A("d")
i = B("i")
l = C("l")
k = D("k")

d.v = l
i.t = d
l.v = k
k.q = l
k.y = i
k.v = d
assert i.t.v.v.txt == "k"