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

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

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

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

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

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

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

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

e.q = h
e.y = n
h.t = f
h.q = g
k.p = f
d.q = f
d.y = l
l.p = h
n.p = h
i.q = h
i.y = l
f.t = h
f.q = g
g.q = f
g.y = n
assert i.y.p.q.y.p.t.t.t.q.txt == "g"