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

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

e = A("e")
c = B("c")
i = B("i")
g = B("g")
k = A("k")
l = B("l")
m = A("m")

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

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

e = A("e")
c = B("c")
i = B("i")
g = B("g")
k = A("k")
l = B("l")
m = A("m")

e.w = i
c.t = l
i.t = g
g.t = i
k.w = l
l.t = c
m.w = l
assert e.w.t.t.t.t.t.t.txt == "i"