private void Solve_Click(object sender, EventArgs e)
        {
            state first = new state(3);

            string[,] k = new string[3, 3];
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Point pt = new Point(100 * j + 50, 100 * i + 50);
                    k[i, j] = ((Button)firststate.GetChildAtPoint(pt)).Text;
                }
            }
            first.setk(k);
            state goal = new state(3);

            string[,] g = new string[3, 3];
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Point pt = new Point(100 * j + 50, 100 * i + 50);
                    g[i, j] = ((Button)Goalstate.GetChildAtPoint(pt)).Text;
                }
            }
            goal.setk(g);
            p = new problem(first, goal, 3);
            if (p.whichset(first.getk()) != p.whichset(goal.getk()))
            {
                MessageBox.Show("the sets didnt match");
            }
            else
            {
                AStar AS = new AStar(p);
                try
                {
                    state[] solution = AS.AS();
                    MessageBox.Show("I found the solution now i will show it : ");
                    foreach (state s in solution)
                    {
                        showstate(s);
                        this.Refresh();
                        Thread.Sleep(1000);
                    }
                }
                catch (OutOfMemoryException)
                {
                    MessageBox.Show("SYSTEM IS OUT OF MEMORY");
                }
            }
        }