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

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

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

m = A("m")
f = B("f")
h = C("h")
e = A("e")
b = A("b")
n = A("n")
k = C("k")
g = C("g")

m.w = e
f.z = n
h.q = f
h.o = m
e.w = m
b.w = n
n.w = b
k.q = f
k.o = b
g.q = f
g.o = e
assert h.o.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

m = A("m")
f = B("f")
h = C("h")
e = A("e")
b = A("b")
n = A("n")
k = C("k")
g = C("g")

m.w = e
f.z = n
h.q = f
h.o = m
e.w = m
b.w = n
n.w = b
k.q = f
k.o = b
g.q = f
g.o = e
assert h.o.w.w.w.w.w.w.txt == "m"