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

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

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

n = A("n")
b = B("b")
j = C("j")
k = A("k")
e = C("e")
d = A("d")
f = A("f")
i = B("i")
h = C("h")

n.s = k
n.p = f
n.w = j
b.t = n
b.o = i
b.r = j
j.z = i
k.s = n
k.p = f
k.w = h
e.z = i
d.s = k
d.p = f
d.w = h
f.s = k
f.p = k
f.w = e
i.t = d
i.o = b
i.r = h
h.z = i
assert d.p.s.w.z.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.p: A = None
        self.w: C = None
        self.txt = txt

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

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

n = A("n")
b = B("b")
j = C("j")
k = A("k")
e = C("e")
d = A("d")
f = A("f")
i = B("i")
h = C("h")

n.s = k
n.p = f
n.w = j
b.t = n
b.o = i
b.r = j
j.z = i
k.s = n
k.p = f
k.w = h
e.z = i
d.s = k
d.p = f
d.w = h
f.s = k
f.p = k
f.w = e
i.t = d
i.o = b
i.r = h
h.z = i
assert d.p.s.w.z.t.s.txt == "k"