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

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

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

a = A("a")
n = B("n")
i = C("i")
f = C("f")
e = B("e")
m = B("m")
h = B("h")
j = C("j")

a.y = j
a.u = i
n.u = a
n.s = a
n.w = h
i.v = n
i.y = a
f.v = e
f.y = a
e.u = a
e.s = a
e.w = n
m.u = a
m.s = a
m.w = e
h.u = a
h.s = a
h.w = n
j.v = h
j.y = a
assert i.v.w.u.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.u: C = None
        self.txt = txt

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

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

a = A("a")
n = B("n")
i = C("i")
f = C("f")
e = B("e")
m = B("m")
h = B("h")
j = C("j")

a.y = j
a.u = i
n.u = a
n.s = a
n.w = h
i.v = n
i.y = a
f.v = e
f.y = a
e.u = a
e.s = a
e.w = n
m.u = a
m.s = a
m.w = e
h.u = a
h.s = a
h.w = n
j.v = h
j.y = a
assert i.v.w.u.y.v.txt == "h"