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

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

e = A("e")
n = B("n")
i = A("i")
f = A("f")
j = B("j")
l = B("l")
k = B("k")
m = A("m")

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

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

e = A("e")
n = B("n")
i = A("i")
f = A("f")
j = B("j")
l = B("l")
k = B("k")
m = A("m")

e.w = j
e.t = i
n.q = e
i.w = k
i.t = m
f.w = l
f.t = m
j.q = e
l.q = m
k.q = e
m.w = n
m.t = e
assert f.w.q.t.txt == "e"