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

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

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

f = A("f")
m = B("m")
a = C("a")
g = A("g")
l = B("l")
k = A("k")
c = B("c")
e = B("e")
n = C("n")

f.x = c
f.w = k
m.p = a
m.u = k
m.y = c
a.x = k
a.p = l
a.y = n
g.x = e
g.w = f
l.p = a
l.u = f
l.y = e
k.x = l
k.w = g
c.p = n
c.u = k
c.y = m
e.p = n
e.u = g
e.y = c
n.x = g
n.p = l
n.y = a
assert a.x.w.x.p.x.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.w: A = None
        self.txt = txt

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

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

f = A("f")
m = B("m")
a = C("a")
g = A("g")
l = B("l")
k = A("k")
c = B("c")
e = B("e")
n = C("n")

f.x = c
f.w = k
m.p = a
m.u = k
m.y = c
a.x = k
a.p = l
a.y = n
g.x = e
g.w = f
l.p = a
l.u = f
l.y = e
k.x = l
k.w = g
c.p = n
c.u = k
c.y = m
e.p = n
e.u = g
e.y = c
n.x = g
n.p = l
n.y = a
assert a.x.w.x.p.x.x.u.txt == "g"