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

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

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

e = A("e")
g = B("g")
b = C("b")
a = C("a")
f = B("f")
k = A("k")
n = B("n")
i = B("i")

e.s = n
e.w = n
g.r = k
g.o = k
b.w = a
a.w = b
f.r = e
f.o = k
k.s = n
k.w = g
n.r = k
n.o = k
i.r = k
i.o = k
assert k.s.r.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.w: B = None
        self.txt = txt

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

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

e = A("e")
g = B("g")
b = C("b")
a = C("a")
f = B("f")
k = A("k")
n = B("n")
i = B("i")

e.s = n
e.w = n
g.r = k
g.o = k
b.w = a
a.w = b
f.r = e
f.o = k
k.s = n
k.w = g
n.r = k
n.o = k
i.r = k
i.o = k
assert k.s.r.w.o.txt == "k"