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

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

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

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

h = A("h")
i = B("i")
n = C("n")
a = D("a")

h.y = i
h.v = n
h.x = a
h.z = a
i.s = n
i.p = n
i.y = h
n.x = a
n.q = i
a.r = h
a.y = h
a.q = h
assert a.r.v.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: C = None
        self.x: D = None
        self.z: D = None
        self.txt = txt

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

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

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

h = A("h")
i = B("i")
n = C("n")
a = D("a")

h.y = i
h.v = n
h.x = a
h.z = a
i.s = n
i.p = n
i.y = h
n.x = a
n.q = i
a.r = h
a.y = h
a.q = h
assert a.r.v.q.s.txt == "n"