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

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

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

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

l = A("l")
j = B("j")
n = C("n")
f = D("f")

l.u = f
l.q = n
l.r = n
j.v = l
j.t = f
n.r = j
f.s = n
assert l.q.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.q: C = None
        self.r: C = None
        self.txt = txt

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

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

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

l = A("l")
j = B("j")
n = C("n")
f = D("f")

l.u = f
l.q = n
l.r = n
j.v = l
j.t = f
n.r = j
f.s = n
assert l.q.r.v.txt == "l"