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

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

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

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

l = A("l")
c = B("c")
j = C("j")
n = D("n")
k = C("k")

l.s = n
c.r = l
c.x = k
c.y = n
c.p = n
j.v = k
j.z = l
n.o = c
n.y = c
n.q = k
k.v = j
k.z = l
assert l.s.y.r.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

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

l = A("l")
c = B("c")
j = C("j")
n = D("n")
k = C("k")

l.s = n
c.r = l
c.x = k
c.y = n
c.p = n
j.v = k
j.z = l
n.o = c
n.y = c
n.q = k
k.v = j
k.z = l
assert l.s.y.r.s.o.txt == "c"