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

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

j = A("j")
k = B("k")
b = A("b")
f = B("f")
c = B("c")

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

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

j = A("j")
k = B("k")
b = A("b")
f = B("f")
c = B("c")

j.y = b
j.x = k
k.s = j
b.y = j
b.x = c
f.s = b
c.s = b
assert b.x.s.y.y.y.txt == "j"