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

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

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

a = A("a")
e = B("e")
k = C("k")
i = C("i")
f = B("f")
d = B("d")
n = C("n")
c = A("c")

a.x = d
a.z = c
e.o = c
e.w = k
e.t = f
k.o = f
k.q = e
i.o = d
i.q = f
f.o = c
f.w = n
f.t = d
d.o = c
d.w = n
d.t = e
n.o = f
n.q = e
c.x = f
c.z = a
assert i.o.w.q.w.o.w.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.z: A = None
        self.txt = txt

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

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

a = A("a")
e = B("e")
k = C("k")
i = C("i")
f = B("f")
d = B("d")
n = C("n")
c = A("c")

a.x = d
a.z = c
e.o = c
e.w = k
e.t = f
k.o = f
k.q = e
i.o = d
i.q = f
f.o = c
f.w = n
f.t = d
d.o = c
d.w = n
d.t = e
n.o = f
n.q = e
c.x = f
c.z = a
assert i.o.w.q.w.o.w.o.o.txt == "c"