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

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

e = A("e")
m = B("m")
b = A("b")
f = A("f")
g = A("g")
i = B("i")
k = B("k")
a = B("a")

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

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

e = A("e")
m = B("m")
b = A("b")
f = A("f")
g = A("g")
i = B("i")
k = B("k")
a = B("a")

e.v = m
m.s = f
m.t = e
b.v = i
f.v = a
g.v = a
i.s = b
i.t = b
k.s = b
k.t = b
a.s = e
a.t = e
assert i.s.v.s.txt == "b"