Simple C++ solution with mutex
\nclass Foo {\npublic:\n    mutex a, b;\n    Foo() {\n        a.lock();\n        b.lock();\n    }\n\n    void first(function<void()> printFirst) {\n        \n  
```\nclass Foo {\npublic:\n    mutex a, b;\n    Foo() {\n        a.lock();\n        b.lock();\n    }\n\n    void first(function<void()> printFirst) {\n        \n        // printFirst() outputs "first". Do not change or remove this line.\n        printFirst();\n        a.unlock();\n    }\n\n    void second(function<void()> printSecond) {\n        \n        // printSecond() outputs "second". Do not change or remove this line.\n        a.lock();\n        printSecond();\n        b.unlock();\n    }\n\n    void third(function<void()> printThird) {\n        \n        // printThird() outputs "third". Do not change or remove this line.\n        b.lock();\n        printThird();\n    }\n};\n```
['C']