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

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

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

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

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

l.v = f
l.u = i
f.t = i
f.r = l
i.u = k
i.q = k
i.w = k
i.p = f
k.w = f
assert k.w.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.u: C = None
        self.txt = txt

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

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

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

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

l.v = f
l.u = i
f.t = i
f.r = l
i.u = k
i.q = k
i.w = k
i.p = f
k.w = f
assert k.w.r.v.txt == "f"