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

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

e = A("e")
h = B("h")
f = A("f")
n = A("n")
i = A("i")
l = B("l")
b = B("b")
d = B("d")
a = B("a")

e.q = h
h.q = f
h.s = f
f.q = l
n.q = b
i.q = l
l.q = f
l.s = f
b.q = i
b.s = f
d.q = e
d.s = e
a.q = e
a.s = n
assert e.q.q.q.s.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

e = A("e")
h = B("h")
f = A("f")
n = A("n")
i = A("i")
l = B("l")
b = B("b")
d = B("d")
a = B("a")

e.q = h
h.q = f
h.s = f
f.q = l
n.q = b
i.q = l
l.q = f
l.s = f
b.q = i
b.s = f
d.q = e
d.s = e
a.q = e
a.s = n
assert e.q.q.q.s.q.q.q.txt == "l"