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

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

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

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

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

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

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

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

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