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

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

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

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

l = A("l")
c = B("c")
j = C("j")
a = D("a")

l.v = j
c.w = j
c.r = j
c.s = a
c.x = a
j.p = a
j.r = l
a.y = c
assert j.p.y.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

l = A("l")
c = B("c")
j = C("j")
a = D("a")

l.v = j
c.w = j
c.r = j
c.s = a
c.x = a
j.p = a
j.r = l
a.y = c
assert j.p.y.w.r.txt == "l"