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

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

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

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

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

f.v = i
f.r = l
m.s = l
e.v = j
e.x = i
e.z = m
i.q = f
j.s = e
l.v = j
l.x = i
l.z = m
assert i.q.r.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.r: C = None
        self.txt = txt

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

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

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

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

f.v = i
f.r = l
m.s = l
e.v = j
e.x = i
e.z = m
i.q = f
j.s = e
l.v = j
l.x = i
l.z = m
assert i.q.r.v.s.txt == "e"