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

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

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

g = A("g")
b = B("b")
a = C("a")
c = C("c")
k = B("k")
n = B("n")
h = A("h")
i = A("i")

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

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

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

g = A("g")
b = B("b")
a = C("a")
c = C("c")
k = B("k")
n = B("n")
h = A("h")
i = A("i")

g.s = a
b.p = c
a.y = h
a.p = g
a.s = g
c.y = g
c.p = g
c.s = h
k.p = c
n.p = a
h.s = c
i.s = a
assert c.s.s.p.s.s.txt == "g"