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

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

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

a = A("a")
m = B("m")
g = C("g")
b = B("b")
h = A("h")
n = B("n")
f = C("f")
c = A("c")
i = A("i")
k = C("k")

a.z = m
a.q = c
a.o = g
m.x = n
m.w = n
m.r = b
g.w = k
b.x = n
b.r = n
b.w = m
h.z = n
h.q = c
h.o = f
n.x = b
n.r = m
n.w = m
f.w = k
c.z = m
c.q = h
c.o = g
i.z = b
i.q = h
i.o = g
k.w = g
assert i.o.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.q: A = None
        self.o: C = None
        self.txt = txt

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

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

a = A("a")
m = B("m")
g = C("g")
b = B("b")
h = A("h")
n = B("n")
f = C("f")
c = A("c")
i = A("i")
k = C("k")

a.z = m
a.q = c
a.o = g
m.x = n
m.w = n
m.r = b
g.w = k
b.x = n
b.r = n
b.w = m
h.z = n
h.q = c
h.o = f
n.x = b
n.r = m
n.w = m
f.w = k
c.z = m
c.q = h
c.o = g
i.z = b
i.q = h
i.o = g
k.w = g
assert i.o.w.w.w.w.w.w.txt == "g"