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

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

i = A("i")
j = B("j")
e = A("e")
f = A("f")
a = B("a")
b = B("b")
n = B("n")

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

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

i = A("i")
j = B("j")
e = A("e")
f = A("f")
a = B("a")
b = B("b")
n = B("n")

i.s = n
j.x = b
e.s = a
f.s = j
a.x = b
b.x = a
n.x = j
assert j.x.x.x.txt == "b"