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

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

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

e = A("e")
a = B("a")
j = C("j")
i = A("i")
g = B("g")
h = C("h")
b = A("b")
m = B("m")

e.w = i
a.o = e
a.q = e
j.u = g
i.w = b
g.o = e
g.q = e
h.u = g
b.w = e
m.o = b
m.q = i
assert g.o.w.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.o: A = None
        self.q: A = None
        self.txt = txt

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

e = A("e")
a = B("a")
j = C("j")
i = A("i")
g = B("g")
h = C("h")
b = A("b")
m = B("m")

e.w = i
a.o = e
a.q = e
j.u = g
i.w = b
g.o = e
g.q = e
h.u = g
b.w = e
m.o = b
m.q = i
assert g.o.w.w.w.w.w.w.w.txt == "i"