Oh, another point. You should run the
alter sequence m increment 5000;
select nextval('m');
alter sequence m increment 1;
one right after the other to reduce the number of 5000 wide holes in
your sequence.
Or, given the size of bigint, you could just set the increment to 5000
and leave it there, and then any insert could grab nextval('m') and
insert up to 5000 more ids with monotonically increasing ids safely.
Note you wouldn't use defaults or nextvals for the rest, you'd have to
calculate them in your application.