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

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

i = A("i")
g = B("g")
l = B("l")
a = A("a")
e = A("e")
m = B("m")

i.x = l
g.v = i
l.v = e
a.x = l
e.x = l
m.v = e
assert l.v.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

i = A("i")
g = B("g")
l = B("l")
a = A("a")
e = A("e")
m = B("m")

i.x = l
g.v = i
l.v = e
a.x = l
e.x = l
m.v = e
assert l.v.x.v.txt == "e"