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

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

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

e = A("e")
g = B("g")
i = C("i")
h = B("h")
f = A("f")
a = C("a")
k = B("k")
m = C("m")
l = B("l")

e.x = m
e.q = m
g.o = k
i.w = f
h.o = l
f.x = a
f.q = i
a.w = f
k.o = l
m.w = f
l.o = h
assert i.w.x.w.q.w.x.w.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.q: C = None
        self.txt = txt

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

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

e = A("e")
g = B("g")
i = C("i")
h = B("h")
f = A("f")
a = C("a")
k = B("k")
m = C("m")
l = B("l")

e.x = m
e.q = m
g.o = k
i.w = f
h.o = l
f.x = a
f.q = i
a.w = f
k.o = l
m.w = f
l.o = h
assert i.w.x.w.q.w.x.w.q.w.txt == "f"