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

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

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

g = A("g")
i = B("i")
a = C("a")
e = B("e")
k = B("k")
m = A("m")
n = A("n")

g.p = m
g.x = n
g.y = a
i.s = e
a.x = n
e.s = k
k.s = i
m.p = n
m.x = n
m.y = a
n.p = m
n.x = m
n.y = a
assert a.x.p.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.x: A = None
        self.y: C = None
        self.txt = txt

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

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

g = A("g")
i = B("i")
a = C("a")
e = B("e")
k = B("k")
m = A("m")
n = A("n")

g.p = m
g.x = n
g.y = a
i.s = e
a.x = n
e.s = k
k.s = i
m.p = n
m.x = n
m.y = a
n.p = m
n.x = m
n.y = a
assert a.x.p.p.y.txt == "a"