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.r: D = None
        self.o: C = None
        self.u: D = None
        self.txt = txt

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

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

l = A("l")
d = B("d")
j = C("j")
m = D("m")

l.v = j
d.t = l
d.r = m
d.u = m
d.o = j
j.x = m
j.p = l
m.p = d
m.v = j
assert m.v.x.p.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.r: D = None
        self.o: C = None
        self.u: D = None
        self.txt = txt

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

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

l = A("l")
d = B("d")
j = C("j")
m = D("m")

l.v = j
d.t = l
d.r = m
d.u = m
d.o = j
j.x = m
j.p = l
m.p = d
m.v = j
assert m.v.x.p.txt == "d"