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

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

i = A("i")
e = B("e")
m = B("m")
l = B("l")
a = B("a")
c = B("c")
k = A("k")
n = A("n")
d = B("d")
h = B("h")

i.t = e
i.q = m
e.r = n
e.q = i
m.r = n
m.q = k
l.r = k
l.q = i
a.r = k
a.q = i
c.r = i
c.q = i
k.t = l
k.q = a
n.t = l
n.q = a
d.r = k
d.q = i
h.r = n
h.q = i
assert m.q.q.q.t.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.q: B = None
        self.txt = txt

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

i = A("i")
e = B("e")
m = B("m")
l = B("l")
a = B("a")
c = B("c")
k = A("k")
n = A("n")
d = B("d")
h = B("h")

i.t = e
i.q = m
e.r = n
e.q = i
m.r = n
m.q = k
l.r = k
l.q = i
a.r = k
a.q = i
c.r = i
c.q = i
k.t = l
k.q = a
n.t = l
n.q = a
d.r = k
d.q = i
h.r = n
h.q = i
assert m.q.q.q.t.r.t.txt == "l"