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

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

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

l.x = e
l.t = e
k.w = l
i.w = l
f.w = a
g.w = a
e.w = a
a.x = k
a.t = i
assert e.w.t.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.t: B = None
        self.txt = txt

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

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

l.x = e
l.t = e
k.w = l
i.w = l
f.w = a
g.w = a
e.w = a
a.x = k
a.t = i
assert e.w.t.w.x.txt == "e"