class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.z: B = None
        self.txt = txt

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

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

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

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

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

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

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

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

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

h.r = c
h.z = f
f.v = m
f.w = i
i.w = b
i.z = l
i.p = k
i.v = k
d.s = i
d.v = b
d.w = k
b.s = l
b.w = l
b.v = d
c.r = h
c.z = f
l.w = d
l.z = i
l.p = i
l.v = i
m.v = f
m.w = k
k.w = b
k.z = i
k.p = i
k.v = i
assert k.w.s.p.txt == "i"