#include <iostream>
#include <string>
#include <regex>
using namespace std;

int main() {
	// your code goes here
	try
	{
		regex pattern("^([\\w]+) ([\\w]+) ([\\w]+)$");
		smatch m;
		string s = "ti re que";
		regex_match(s, m, pattern);
		cout << "Matches found: ";
		for (int i = 0; i < m.size(); i++)
		{
			cout << "[" << m[i] << "] ";
		}
		return 0;
	}
	catch (regex_error& e)
	{
		cout << e.what();
		return 1;
	}
	return 0;
}