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

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

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

g = A("g")
e = B("e")
b = C("b")
k = A("k")
n = A("n")
j = A("j")
i = A("i")

g.p = n
g.s = k
e.z = b
e.p = b
e.v = i
b.s = k
b.w = n
b.r = j
k.p = n
k.s = i
n.p = k
n.s = i
j.p = i
j.s = i
i.p = n
i.s = j
assert g.s.s.p.p.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.s: A = None
        self.txt = txt

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

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

g = A("g")
e = B("e")
b = C("b")
k = A("k")
n = A("n")
j = A("j")
i = A("i")

g.p = n
g.s = k
e.z = b
e.p = b
e.v = i
b.s = k
b.w = n
b.r = j
k.p = n
k.s = i
n.p = k
n.s = i
j.p = i
j.s = i
i.p = n
i.s = j
assert g.s.s.p.p.s.s.s.txt == "i"