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

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

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

c = A("c")
k = B("k")
n = C("n")
g = B("g")

c.y = k
k.p = n
k.s = n
n.x = g
g.p = n
g.s = n
assert c.y.s.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

c = A("c")
k = B("k")
n = C("n")
g = B("g")

c.y = k
k.p = n
k.s = n
n.x = g
g.p = n
g.s = n
assert c.y.s.x.p.txt == "n"