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

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

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

k = A("k")
l = B("l")
g = C("g")
n = B("n")
h = A("h")
e = C("e")
b = B("b")
j = C("j")
m = C("m")

k.x = m
l.s = h
l.o = h
l.w = n
g.x = n
n.s = k
n.o = k
n.w = l
h.x = j
e.x = l
b.s = k
b.o = k
b.w = l
j.x = l
m.x = b
assert n.w.s.x.x.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

k = A("k")
l = B("l")
g = C("g")
n = B("n")
h = A("h")
e = C("e")
b = B("b")
j = C("j")
m = C("m")

k.x = m
l.s = h
l.o = h
l.w = n
g.x = n
n.s = k
n.o = k
n.w = l
h.x = j
e.x = l
b.s = k
b.o = k
b.w = l
j.x = l
m.x = b
assert n.w.s.x.x.w.w.w.w.txt == "l"