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

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

e = A("e")
n = B("n")
m = B("m")
h = B("h")
k = A("k")
g = A("g")
l = B("l")

e.w = n
n.y = g
m.y = k
h.y = e
k.w = l
g.w = h
l.y = e
assert h.y.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

e = A("e")
n = B("n")
m = B("m")
h = B("h")
k = A("k")
g = A("g")
l = B("l")

e.w = n
n.y = g
m.y = k
h.y = e
k.w = l
g.w = h
l.y = e
assert h.y.w.y.txt == "g"