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

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

j = A("j")
b = B("b")
c = A("c")
n = A("n")
g = B("g")
f = A("f")

j.w = f
b.y = g
c.w = n
n.w = j
g.y = b
f.w = j
assert f.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: B = None
        self.txt = txt

j = A("j")
b = B("b")
c = A("c")
n = A("n")
g = B("g")
f = A("f")

j.w = f
b.y = g
c.w = n
n.w = j
g.y = b
f.w = j
assert f.w.w.w.txt == "j"