How to remove duplicate row in file

Suppose there are two files,

1
2
3
4
5
6
7
8
9
10
11
A
aaa
bbb
ccc
ddd

B
aaa
bbb
eee
fff

How to remove duplicate rows?

1
2
3
4
5
6
aaa
bbb
ccc
ddd
eee
fff
1
cat A B | sort | uniq

How to get intersection?

1
2
aaa
bbb
1
cat A B | sort | uniq -c | awk -F " " '{if($1!=1) print $2;}'