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

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

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

m = A("m")
k = B("k")
i = C("i")
c = A("c")
f = C("f")
b = A("b")
g = A("g")
e = B("e")

m.w = c
m.p = g
k.w = e
i.u = g
i.p = f
c.w = b
c.p = m
f.u = g
f.p = i
b.w = g
b.p = m
g.w = b
g.p = m
e.w = k
assert f.u.p.w.p.w.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.p: A = None
        self.txt = txt

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

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

m = A("m")
k = B("k")
i = C("i")
c = A("c")
f = C("f")
b = A("b")
g = A("g")
e = B("e")

m.w = c
m.p = g
k.w = e
i.u = g
i.p = f
c.w = b
c.p = m
f.u = g
f.p = i
b.w = g
b.p = m
g.w = b
g.p = m
e.w = k
assert f.u.p.w.p.w.w.p.txt == "m"