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

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

g = A("g")
j = B("j")
a = A("a")
e = B("e")
b = A("b")
f = A("f")

g.w = b
j.x = e
a.w = g
e.x = j
b.w = a
f.w = b
assert f.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.x: B = None
        self.txt = txt

g = A("g")
j = B("j")
a = A("a")
e = B("e")
b = A("b")
f = A("f")

g.w = b
j.x = e
a.w = g
e.x = j
b.w = a
f.w = b
assert f.w.w.w.w.w.w.txt == "g"