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

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

j = A("j")
g = B("g")
b = B("b")
d = A("d")
n = B("n")
i = A("i")
l = B("l")

j.w = d
g.y = i
b.y = i
d.w = i
n.y = j
i.w = j
l.y = i
assert g.y.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

j = A("j")
g = B("g")
b = B("b")
d = A("d")
n = B("n")
i = A("i")
l = B("l")

j.w = d
g.y = i
b.y = i
d.w = i
n.y = j
i.w = j
l.y = i
assert g.y.w.w.w.w.w.w.txt == "i"