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

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

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

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

f = A("f")
k = B("k")
h = C("h")
l = D("l")

f.u = l
k.y = f
h.t = l
h.q = k
l.v = f
assert k.y.u.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

f = A("f")
k = B("k")
h = C("h")
l = D("l")

f.u = l
k.y = f
h.t = l
h.q = k
l.v = f
assert k.y.u.v.u.txt == "l"