Let m be a positive interger, let $p$ be a prime, let $a_1=8p^m$, and let $a_n=(n+1)^{\frac{a_{n-1}}{n}}$, $n=2,3...$. Determine the primes $p$ for which the products $a_n(1-\frac{1}{a_1})(1-\frac{1}{a_2})...(1-\frac{1}{a_n})$, $n=1,2,3...$ are all integral.
1. **Initial Setup and Sequence Definition:**
   Given \( a_1 = 8p^m \) and \( a_n = (n+1)^{\frac{a_{n-1}}{n}} \) for \( n \geq 2 \), we need to determine the primes \( p \) for which the products \( a_n \left(1 - \frac{1}{a_1}\right) \left(1 - \frac{1}{a_2}\right) \cdots \left(1 - \frac{1}{a_n}\right) \) are all integers.

2. **Sequence Calculation:**
   We start by calculating the first few terms of the sequence:
   \[
   a_1 = 8p^m
   \]
   \[
   a_2 = 3^{\frac{8p^m}{2}} = 3^{4p^m}
   \]
   \[
   a_3 = 4^{\frac{3^{4p^m}}{3}} = 4^{3^{4p^m - 1}}
   \]
   and so on.

3. **Divisibility Condition:**
   We need to show that \( a_{n-1} \mid a_n - 1 \) for all \( n \geq 1 \). This ensures that the product \( a_n \left(1 - \frac{1}{a_1}\right) \left(1 - \frac{1}{a_2}\right) \cdots \left(1 - \frac{1}{a_n}\right) \) remains an integer.

4. **Valuation Analysis for Odd Prime \( p \):**
   For \( p \) odd, we analyze the \( p \)-adic valuation:
   \[
   v_p(a_n - 1) = v_p\left((n+1)^{\frac{a_{n-1}}{n}} - 1\right)
   \]
   Using the properties of \( v_p \):
   \[
   v_p(a_n - 1) = v_p(n) + v_p\left(\frac{a_{n-1}}{n}\right) = v_p(n) + v_p(a_{n-1}) - v_p(n) = v_p(a_{n-1})
   \]
   Thus, \( a_{n-1} \mid a_n - 1 \).

5. **Valuation Analysis for \( p = 2 \):**
   For \( p = 2 \), we analyze the 2-adic valuation:
   \[
   v_2(a_n - 1) = v_2\left((n+1)^{\frac{a_{n-1}}{n}} - 1\right)
   \]
   Using the properties of \( v_2 \):
   \[
   v_2(a_n - 1) = v_2(n) + v_2(n+2) + v_2\left(\frac{a_{n-1}}{n}\right) - 1 = v_2(a_{n-1}) + v_2(n+2) - 1 = v_2(a_{n-1})
   \]
   Thus, \( a_{n-1} \mid a_n - 1 \) for \( n \geq 3 \).

6. **Integral Condition:**
   For the product \( a_n \left(1 - \frac{1}{a_1}\right) \left(1 - \frac{1}{a_2}\right) \cdots \left(1 - \frac{1}{a_n}\right) \) to be an integer, we need \( a_1 \mid a_2 - 1 \):
   \[
   8p^m \mid 81^{p^m} - 1
   \]
   This implies \( p \mid 81^{p^m} - 1 \).

7. **Prime Condition Analysis:**
   We need to check when \( 81^{p^m} - 81 \equiv 0 \pmod{p} \):
   - For \( m = 1 \), \( 81^p - 81 \equiv 0 \pmod{p} \) (by Fermat's Little Theorem).
   - Assume \( 81^{p^m} - 81 \equiv 0 \pmod{p} \). We need to show \( 81^{p^{m+1}} - 81 \equiv 0 \pmod{p} \):
     \[
     81^{p^{m+1}} - 81 = (81^{p^m})^p - 81 \equiv 81^p - 81 \equiv 0 \pmod{p}
     \]

8. **Conclusion:**
   Since \( p \mid 81^{p^m} - 1 \) and \( p \mid 81^{p^m} - 81 \), we have \( p \mid 80 \). Therefore, \( p \) must be one of the prime divisors of 80, which are 2 and 5.

The final answer is \( \boxed{ p \in \{2, 5\} } \)