This relies on a multi-line pattern space and discards the top-most line as soon a match is not found and the search is then started over. Lines are added after each match. A group is fully matched when all pieces are matched in turn:
sed '/^A/!D; /\n/!N; /\nB/!D; N; /\nC/!D'
The solution can be generalised to match an arbitrary number of lines, and using a bit more care to isolate search terms. The script below will match a 4-line group (e.g. A|B|A|B), simply substitute successive lines for each "X":
sed '
# If X does not begin pattern space, delete first line,
# return to script start, read a line if none remain
/^X/!D
# Append next line if pattern space holds 1 line
/\n/!N
# If X does not begin line 2+ of pattern space, delete first line,
# return to script start, read a line if none remain
/\nX/!D
# Append next line if pattern space holds < 3 lines
/\n.*\n/!N
# If X does not begin line 3+ of pattern space, delete first line,
# return to script start, read a line if none remain
/\n.*\nX/!D
# Append next line if pattern space holds < 4 lines
/\n.*\n.*\n/!N
# If X does not begin line 4+ of pattern space, delete first line,
# return to script start, read a line if none remain
/\n.*\n.*\nX/!D
# After here, output pattern space then discard and start again
'