#include <iostream>
#include <string>
class Buffer {
private:
int id;
public:
Buffer(int i) : id(i) {}
// TODO: Implement the assignment operator
Buffer& operator=(const Buffer& other) {
// TODO: Check for self-assignment using 'this' pointer
// Compare the address of the current object (this) with the address of 'other'
if (this == &other){
printf("Self-Assignment Detected\n");
return *this;
}
// TODO: Perform assignment if not self
id=other.id;
printf("Assignment Complete\n");
return *this;
}
void log() {
std::cout << "Buffer ID: " << id << std::endl;
}
};
int main() {
int N;
if (!(std::cin >> N)) return 0;
for (int i = 0; i < N; ++i) {
std::string cmd;
std::cin >> cmd;
if (cmd == "ASSIGN") {
int i1, i2;
std::cin >> i1 >> i2;
Buffer b1(i1);
Buffer b2(i2);
b1 = b2;
b1.log();
} else if (cmd == "SELF") {
int i1;
std::cin >> i1;
Buffer b1(i1);
b1 = b1; // Self-assignment
b1.log();
}
}
return 0;
}