#!/bin/bash

sed '/^1/cAB
/1$/cACD
cACE'