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

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

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

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

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

j.v = l
n.u = j
n.s = l
f.x = n
f.p = l
l.x = m
m.u = j
m.s = l
assert n.s.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

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

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

j.v = l
n.u = j
n.s = l
f.x = n
f.p = l
l.x = m
m.u = j
m.s = l
assert n.s.x.u.txt == "j"