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

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

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

l = A("l")
m = B("m")
k = C("k")
h = A("h")
b = C("b")
d = A("d")
f = A("f")
j = B("j")
i = B("i")

l.w = f
m.o = i
m.s = j
m.w = h
k.w = b
h.w = f
b.w = k
d.w = l
f.w = l
j.o = i
j.s = m
j.w = l
i.o = j
i.s = m
i.w = l
assert j.o.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

l = A("l")
m = B("m")
k = C("k")
h = A("h")
b = C("b")
d = A("d")
f = A("f")
j = B("j")
i = B("i")

l.w = f
m.o = i
m.s = j
m.w = h
k.w = b
h.w = f
b.w = k
d.w = l
f.w = l
j.o = i
j.s = m
j.w = l
i.o = j
i.s = m
i.w = l
assert j.o.w.w.w.w.w.w.txt == "f"