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

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

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

f = A("f")
m = B("m")
l = C("l")
a = A("a")
g = A("g")
d = B("d")
c = C("c")
i = A("i")
h = B("h")
n = C("n")

f.x = c
f.p = c
f.w = l
m.s = g
l.w = c
a.x = l
a.w = l
a.p = n
g.x = c
g.w = c
g.p = l
d.s = g
c.w = l
i.x = l
i.w = l
i.p = n
h.s = i
n.w = l
assert c.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.p: C = None
        self.w: C = None
        self.txt = txt

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

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

f = A("f")
m = B("m")
l = C("l")
a = A("a")
g = A("g")
d = B("d")
c = C("c")
i = A("i")
h = B("h")
n = C("n")

f.x = c
f.p = c
f.w = l
m.s = g
l.w = c
a.x = l
a.w = l
a.p = n
g.x = c
g.w = c
g.p = l
d.s = g
c.w = l
i.x = l
i.w = l
i.p = n
h.s = i
n.w = l
assert c.w.w.w.w.w.txt == "l"