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

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

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

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

m.o = k
m.w = l
k.u = f
f.p = e
e.o = k
e.w = l
l.p = e
h.o = k
h.w = l
assert f.p.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.w: C = None
        self.txt = txt

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

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

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

m.o = k
m.w = l
k.u = f
f.p = e
e.o = k
e.w = l
l.p = e
h.o = k
h.w = l
assert f.p.o.u.txt == "f"