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

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

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

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

g.o = k
g.y = n
h.o = k
h.q = k
n.t = l
n.z = h
f.o = k
f.y = n
e.t = g
e.z = h
l.o = h
l.y = e
k.o = h
k.q = h
b.o = h
b.y = e
assert f.o.o.q.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.y: C = None
        self.txt = txt

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

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

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

g.o = k
g.y = n
h.o = k
h.q = k
n.t = l
n.z = h
f.o = k
f.y = n
e.t = g
e.z = h
l.o = h
l.y = e
k.o = h
k.q = h
b.o = h
b.y = e
assert f.o.o.q.o.o.o.o.txt == "k"