Reference Survives Push Front

std::deque<int> d{1, 2, 3};
int& rd = d[1];
d.push_front(0);
std::cout << rd << " ";        // (1)

std::vector<int> v{1, 2, 3};   // capacity == 3
int& rv = v[1];
v.push_back(4);
std::cout << rv << "\n";       // (2)

Which line, if either, is undefined behaviour?

A

(1) only; push_front reshuffles the deque so every reference dangles

B

(2) only; (1) is well defined and prints 2

C

Both are undefined behaviour

D

Neither; both containers keep references stable across insertion