class A:
    def __init__(self, txt: str):
        self.z: A = 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.t: B = None
        self.p: A = None
        self.s: A = None
        self.txt = txt

f = A("f")
n = B("n")
k = C("k")
g = A("g")
d = C("d")
m = C("m")
i = A("i")
j = B("j")

f.z = i
n.s = j
k.t = j
k.p = g
k.s = g
g.z = f
d.t = n
d.p = g
d.s = g
m.t = j
m.p = i
m.s = i
i.z = g
j.s = n
assert g.z.z.z.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = 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.t: B = None
        self.p: A = None
        self.s: A = None
        self.txt = txt

f = A("f")
n = B("n")
k = C("k")
g = A("g")
d = C("d")
m = C("m")
i = A("i")
j = B("j")

f.z = i
n.s = j
k.t = j
k.p = g
k.s = g
g.z = f
d.t = n
d.p = g
d.s = g
m.t = j
m.p = i
m.s = i
i.z = g
j.s = n
assert g.z.z.z.z.z.z.z.z.txt == "i"