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

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

f = A("f")
b = B("b")
m = A("m")
i = B("i")
l = A("l")
k = B("k")
e = B("e")
a = B("a")
c = A("c")
j = A("j")

f.q = l
f.v = b
b.t = l
m.q = f
m.v = e
i.t = m
l.q = f
l.v = a
k.t = l
e.t = c
a.t = f
c.q = m
c.v = k
j.q = c
j.v = e
assert b.t.v.t.q.v.t.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.v: B = None
        self.txt = txt

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

f = A("f")
b = B("b")
m = A("m")
i = B("i")
l = A("l")
k = B("k")
e = B("e")
a = B("a")
c = A("c")
j = A("j")

f.q = l
f.v = b
b.t = l
m.q = f
m.v = e
i.t = m
l.q = f
l.v = a
k.t = l
e.t = c
a.t = f
c.q = m
c.v = k
j.q = c
j.v = e
assert b.t.v.t.q.v.t.v.t.txt == "l"