There are 8 tasks and 8 persons. Task 1 cannot be assigned either to person 1 or to person 2 or to person 8; task 2 must be assigned to either person 3 or person 4 or person 5. Every person is to be assigned one task. In how many ways can the tasks be assigned?