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

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

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

b = A("b")
a = B("a")
g = C("g")
c = C("c")
f = A("f")
h = C("h")
l = B("l")
n = A("n")
k = A("k")

b.s = h
b.w = f
a.o = n
a.p = h
g.y = f
c.y = b
f.s = c
f.w = n
h.y = f
l.o = b
l.p = c
n.s = g
n.w = f
k.s = h
k.w = n
assert f.w.s.y.w.w.w.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.w: A = None
        self.txt = txt

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

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

b = A("b")
a = B("a")
g = C("g")
c = C("c")
f = A("f")
h = C("h")
l = B("l")
n = A("n")
k = A("k")

b.s = h
b.w = f
a.o = n
a.p = h
g.y = f
c.y = b
f.s = c
f.w = n
h.y = f
l.o = b
l.p = c
n.s = g
n.w = f
k.s = h
k.w = n
assert f.w.s.y.w.w.w.s.y.txt == "f"