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

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

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

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

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

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

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

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

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