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

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

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

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

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

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

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

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

l.s = m
l.o = m
j.w = h
f.y = h
f.t = l
d.y = l
d.t = h
m.w = h
h.s = j
h.o = m
k.s = j
k.o = j
assert h.s.w.s.w.o.w.txt == "h"