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

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

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

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

j = A("j")
n = B("n")
e = C("e")
d = D("d")
c = B("c")
i = A("i")
m = A("m")

j.y = i
j.v = e
j.s = e
j.w = e
n.z = e
n.x = i
n.y = d
e.y = c
e.v = d
e.w = d
e.s = d
d.s = n
c.z = e
c.x = i
c.y = d
i.y = m
i.v = e
i.s = e
i.w = e
m.y = j
m.v = e
m.s = e
m.w = e
assert j.s.y.x.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.v: C = None
        self.s: C = None
        self.w: C = None
        self.txt = txt

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

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

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

j = A("j")
n = B("n")
e = C("e")
d = D("d")
c = B("c")
i = A("i")
m = A("m")

j.y = i
j.v = e
j.s = e
j.w = e
n.z = e
n.x = i
n.y = d
e.y = c
e.v = d
e.w = d
e.s = d
d.s = n
c.z = e
c.x = i
c.y = d
i.y = m
i.v = e
i.s = e
i.w = e
m.y = j
m.v = e
m.s = e
m.w = e
assert j.s.y.x.v.v.txt == "d"