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

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

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

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

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

c.p = h
c.s = f
c.z = d
k.o = m
k.x = b
m.w = a
m.t = c
h.r = l
h.t = m
h.x = b
e.o = b
e.x = m
f.o = b
f.x = m
d.p = l
d.s = e
d.z = a
l.r = h
l.t = m
l.x = b
a.p = h
a.s = k
a.z = d
b.w = c
b.t = a
assert c.z.s.o.w.p.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.s: B = None
        self.z: A = None
        self.txt = txt

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

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

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

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

c.p = h
c.s = f
c.z = d
k.o = m
k.x = b
m.w = a
m.t = c
h.r = l
h.t = m
h.x = b
e.o = b
e.x = m
f.o = b
f.x = m
d.p = l
d.s = e
d.z = a
l.r = h
l.t = m
l.x = b
a.p = h
a.s = k
a.z = d
b.w = c
b.t = a
assert c.z.s.o.w.p.r.r.txt == "h"