Here's a short solution using TikZ and its positioning library:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\def\minboxsize{20pt}
\tikzset{boxnode/.style={draw,minimum height=\minboxsize,minimum width=\minboxsize}}
\node (A) {$G_x =$};
\node [boxnode,right of=A] (B) {$-1$};
\begin{scope}[node distance=\minboxsize]
\node [boxnode,right of=B] (C) {$1$};
\end{scope}
\node [right = 20pt of C](D) {$G_y =$};
\node [boxnode,right of=D] (E) {$1$};
\begin{scope}[node distance=\minboxsize]
\node [boxnode,below of=E] (F) {$-1$};
\end{scope}
\end{tikzpicture}
\end{document}
tikzsolution? By the way it usually best to post a complete minimal document rather than a code snippet, see https://tex.meta.stackexchange.com/q/228 – Andrew Swann Jan 09 '21 at 11:19