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

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

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

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

h = A("h")
m = B("m")
c = C("c")
l = D("l")
j = B("j")
i = B("i")
f = A("f")
g = B("g")
k = B("k")
d = D("d")

h.s = m
h.u = f
h.p = f
m.s = c
m.v = l
c.x = d
c.y = h
c.v = h
c.z = f
l.y = c
l.x = h
l.r = h
j.s = c
j.v = l
i.s = c
i.v = d
f.s = m
f.u = h
f.p = h
g.s = c
g.v = l
k.s = c
k.v = d
d.y = c
d.x = h
d.r = h
assert j.v.y.v.p.p.s.s.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.u: A = None
        self.p: A = None
        self.txt = txt

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

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

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

h = A("h")
m = B("m")
c = C("c")
l = D("l")
j = B("j")
i = B("i")
f = A("f")
g = B("g")
k = B("k")
d = D("d")

h.s = m
h.u = f
h.p = f
m.s = c
m.v = l
c.x = d
c.y = h
c.v = h
c.z = f
l.y = c
l.x = h
l.r = h
j.s = c
j.v = l
i.s = c
i.v = d
f.s = m
f.u = h
f.p = h
g.s = c
g.v = l
k.s = c
k.v = d
d.y = c
d.x = h
d.r = h
assert j.v.y.v.p.p.s.s.z.s.txt == "m"