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

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

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

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

f.w = m
n.p = b
h.o = k
b.w = m
k.o = h
l.p = f
a.p = f
m.w = b
assert f.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.p: A = None
        self.txt = txt

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

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

f.w = m
n.p = b
h.o = k
b.w = m
k.o = h
l.p = f
a.p = f
m.w = b
assert f.w.w.w.w.txt == "b"