#include <iostream>
#include <vector>
using namespace std;

int sum(const vector<vector<int>>& matrix)
{
  int total = 0;
  for (unsigned int row = 0; row < matrix.size(); row++)
  {
    for (unsigned column = 0; column < matrix[row].size(); column++)
    {
      total += matrix[row][column];
    }
  }

  return total;
}

int main()
{
  vector<vector<int>> matrix{
    {1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}};

  cout << "Sum of all elements is " << sum(matrix) << endl;

  return 0;
}