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

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

g = A("g")
j = B("j")
n = A("n")
f = B("f")
k = A("k")

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

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

g = A("g")
j = B("j")
n = A("n")
f = B("f")
k = A("k")

g.y = f
j.s = g
n.y = f
f.s = g
k.y = f
assert g.y.s.y.s.txt == "g"