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

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

j = A("j")
f = B("f")
a = B("a")
n = A("n")

j.y = n
f.s = n
f.x = a
a.s = j
a.x = f
n.y = j
assert j.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

j = A("j")
f = B("f")
a = B("a")
n = A("n")

j.y = n
f.s = n
f.x = a
a.s = j
a.x = f
n.y = j
assert j.y.y.y.y.txt == "j"