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

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

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

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

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

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

j.w = n
j.v = n
f.q = j
f.t = n
a.w = n
a.v = n
e.w = i
e.v = f
m.q = j
m.t = i
n.q = e
n.t = i
i.q = e
i.t = f
assert j.v.t.t.q.txt == "j"