std::getline(istream&,std::string&) doesn't work the same way cin>>var works.
When you use cin>>var the right input is absorbed to the var correctly and if there is a space before it it is ignored but std::getline doesn't ignore the space, so we used std::cin.ignore() to ignore the \n. If you don't ignore it, the string will encouter it and then won't absorb your line because std::getline() stops on encountering a \n.
#include <iostream>
#include <string>
using namespace std;
int main() {
unsigned n {}, m {};
cin >> n >> m;
string set;
cin.ignore();
getline(cin, set);
cout<<set<<endl;
return 0;
}