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

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

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

a = A("a")
j = B("j")
c = C("c")
m = A("m")
n = A("n")
b = C("b")
g = B("g")
l = C("l")
k = C("k")

a.z = n
a.t = m
a.p = m
j.w = a
j.p = g
j.s = l
c.r = j
m.z = n
m.p = n
m.t = a
n.z = a
n.p = a
n.t = m
b.r = j
g.w = m
g.p = j
g.s = b
l.r = j
k.r = j
assert g.w.t.t.t.p.p.p.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.t: A = None
        self.p: A = None
        self.txt = txt

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

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

a = A("a")
j = B("j")
c = C("c")
m = A("m")
n = A("n")
b = C("b")
g = B("g")
l = C("l")
k = C("k")

a.z = n
a.t = m
a.p = m
j.w = a
j.p = g
j.s = l
c.r = j
m.z = n
m.p = n
m.t = a
n.z = a
n.p = a
n.t = m
b.r = j
g.w = m
g.p = j
g.s = b
l.r = j
k.r = j
assert g.w.t.t.t.p.p.p.z.t.txt == "m"