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

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

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

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

c = A("c")
h = B("h")
m = C("m")
k = D("k")
n = A("n")
i = C("i")
l = D("l")

c.z = h
c.w = n
c.s = k
c.y = m
h.p = m
m.p = i
m.x = i
m.w = l
m.v = l
k.v = n
n.z = h
n.w = c
n.s = l
n.y = m
i.p = m
i.x = m
i.w = k
i.v = l
l.v = c
assert n.y.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.w: A = None
        self.s: D = None
        self.y: C = None
        self.txt = txt

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

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

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

c = A("c")
h = B("h")
m = C("m")
k = D("k")
n = A("n")
i = C("i")
l = D("l")

c.z = h
c.w = n
c.s = k
c.y = m
h.p = m
m.p = i
m.x = i
m.w = l
m.v = l
k.v = n
n.z = h
n.w = c
n.s = l
n.y = m
i.p = m
i.x = m
i.w = k
i.v = l
l.v = c
assert n.y.w.v.txt == "c"