Hint: First, start off with the constrained maximization problem and then use the Lagrangian method to get the first-order conditions. Then use the Kuhn-Tucker method (see Mathematics for Economist by Simon and Blume) to solve for your optimal demands.
The consumer solves the following maximization problem:
\begin{align*}
\max_{q_1,q_2} \alpha_1q_1 + \alpha_2q_2 - \frac{1}{2}(q_1^2+q_2^2+2\epsilon q_1 q_2) \\
\text{s.t. } p_1 q_1 + p_2q_2 \le m.
\end{align*}
The Lagrangian associated with maximization problem is
\begin{equation*}
\mathcal{L} = \alpha_1q_1 + \alpha_2q_2 - \frac{1}{2}(q_1^2+q_2^2+2\epsilon q_1 q_2) + \lambda[m - p_1 q_1 - p_2q_2]
\end{equation*}
Then take the derivatives of $\mathcal{L}$ wrt to $q_{1}$, $q_{2}$, and $\lambda$ to get the following first-order conditions:
\begin{equation}
\frac{\partial \mathcal{L}}{\partial q_{1}}=\alpha_{1}-q_{1}+\epsilon q_{2} -\lambda p_{1} =0
\end{equation}
\begin{equation}
\frac{\partial \mathcal{L}}{\partial q_{2}}=\alpha_{2}-q_{2}+\epsilon q_{1} -\lambda p_{2}=0
\end{equation}
\begin{equation}
\frac{\partial \mathcal{L}}{\partial \lambda}=m-p_{1}q_{1}-p_{2}q_{2}\geq0
\end{equation}
Then we use the Kuhn-Tucker method:
$\lambda[m-p_{1}q_{1}-p_{2}q_{2}] = 0$ is the complementary slackness condition on $\lambda$
and
$\lambda\geq0$ is the non-negativity constraint on $\lambda$.
We can have two cases: either $\lambda>0$ or $\lambda=0$. I show what happens for $\lambda>0$ and then you can check what happens for $\lambda=0$.
If $\lambda>0$ then $m-p_{1}q_{1}-p_{2}q_{2}=0$ by the complementary slackness condition. In other words, this is the case where the budget constraint is binding, that is, $m=p_{1}q_{1}-p_{2}q_{2}$. Then we check whether the first-order conditions and the non-negativity condition hold.
After doing so we are left with the following set of equations:
\begin{equation}
\frac{\partial \mathcal{L}}{\partial q_{1}}=\alpha_{1}-q_{1}+\epsilon q_{2} -\lambda p_{1} =0
\end{equation}
\begin{equation}
\frac{\partial \mathcal{L}}{\partial q_{2}}=\alpha_{2}-q_{2}+\epsilon q_{1} -\lambda p_{2}=0
\end{equation}
\begin{equation}
m-p_{1}q_{1}-m_{2}q_{2}=0
\end{equation}
Then substitute away $\lambda$ from the first two equations and solve for $q_{1}$ and $q_{2}$ using the binding budget constraint.
Edit: For the unconstrained problem you have no budget constraint so your set up is conceptually wrong. The way you get an unconstrained problem from a constrained problem is that you substitute away your budget constraint in the utility function. Also I haven't imposed non-negative conditions on $q_{1}$ and $q_{2}$, as then the process would be quite tedious.
With the help of the slack variables $\epsilon_i$ and calling
$$
L(p,\mu,\epsilon,\lambda)= p_1 p_2 p_3 p_4 p_5+\mu _5 \left(p_1-p_2-\epsilon _5^2\right)+\mu _4 \left(p_2-p_3-\epsilon _4^2\right)+\mu _3 \left(p_3-p_4-\epsilon _3^2\right)+\mu _2
\left(p_4-p_5-\epsilon _2^2\right)+\mu _1 \left(p_5-\epsilon _1^2\right)+\lambda \left(p_1 x_1+p_2 \left(x_2-x_1\right)+p_3
\left(x_3-x_2\right)+p_4 \left(x_4-x_3\right)+p_5 \left(x_5-x_4\right)-1\right)
$$
and solving the sationary conditions
$$
\nabla L = 0
$$
we obtain a set of solutions jointly with a set of conditions $\epsilon_i^2\ge 0$ to qualify those solutions. To be feasible the solution requires that $\epsilon_i^2\ge 0$ Also when $\epsilon_i^2 = 0$ it means that the corresponding restriction is active.
Due to the length of the symbolic response, we leave a script in MATHEMATICA that summarizes the results. There are sixteen non trivial solutions in res0 with structure $\{p_i,\epsilon_i^2,p_1p_2p_3p_4p_5\}$
n = 5;
X = Table[Subscript[x, k], {k, 1, n}];
P = Table[Subscript[p, k], {k, 1, n}];
EE = Table[Subscript[epsilon, k], {k, 1, n}];
M = Table[Subscript[mu, k], {k, 1, n}];
vars = Join[Join[Join[P, M], EE], {lambda}]
prod = Product[P[[k]], {k, 1, n}]
L = prod
L += lambda (Sum[P[[k]] (X[[k]] - X[[k - 1]]), {k, 2, n}] + P[[1]] X[[1]] - 1)
L += Sum[M[[k]] (P[[n - k + 1]] - P[[n - k + 2]] + EE[[k]]^2), {k, 2, n}] + M[[1]] (P[[n]] - EE[[1]]^2)
grad = Grad[L, vars]
equs = Thread[grad == 0];
E2 = EE^2;
results = Join[Join[P, E2], {prod}];
sols = Quiet[Solve[equs, vars]];
results0 = results /. sols // FullSimplify;
For[i = 1; res = {}, i <= Length[results0], i++,
If[NumberQ[results0[[i]][[2 n + 1]]] == False, AppendTo[res,results0[[i]]]]
]
res0 = Union[res];
res0 // MatrixForm
Results for $n = 3$
$$
\left[
\begin{array}{ccccccc}
p_1&p_2&p_3&\epsilon_1^2&\epsilon_2^2&\epsilon_3^2&p_1p_2p_3\\
\frac{1}{3 x_1} & \frac{1}{3 \left(x_2-x_1\right)} & \frac{1}{3 \left(x_3-x_2\right)} & \frac{1}{3 \left(x_3-x_2\right)} & \frac{1}{3 x_2-3
x_3}+\frac{1}{3 \left(x_2-x_1\right)} & \frac{1}{3} \left(\frac{1}{x_1-x_2}+\frac{1}{x_1}\right) & \frac{1}{27 \left(x_1^2-x_1 x_2\right)
\left(x_2-x_3\right)} \\
\frac{1}{3 x_1} & \frac{2}{3 \left(x_3-x_1\right)} & \frac{2}{3 \left(x_3-x_1\right)} & \frac{2}{3 \left(x_3-x_1\right)} & 0 & \frac{1}{3}
\left(\frac{2}{x_1-x_3}+\frac{1}{x_1}\right) & \frac{4}{27 x_1 \left(x_1-x_3\right){}^2} \\
\frac{2}{3 x_2} & \frac{2}{3 x_2} & \frac{1}{3 \left(x_3-x_2\right)} & \frac{1}{3 \left(x_3-x_2\right)} & \frac{1}{3 x_2-3 x_3}+\frac{2}{3
x_2} & 0 & \frac{4}{27 x_2^2 \left(x_3-x_2\right)} \\
\frac{1}{x_3} & \frac{1}{x_3} & \frac{1}{x_3} & \frac{1}{x_3} & 0 & 0 & \frac{1}{x_3^3} \\
\end{array}
\right]
$$
Results for $n = 4$
$$
\left[
\begin{array}{ccccccccc}
p_1 & p_2 & p_3 & p_4 & \epsilon_1^2&\epsilon_2^2&\epsilon_3^2&\epsilon_4^2&p_1p_2p_3p_4\\
\frac{1}{4 x_1} & \frac{1}{4 \left(x_2-x_1\right)} & \frac{1}{4 \left(x_3-x_2\right)} & \frac{1}{4 \left(x_4-x_3\right)} & \frac{1}{4
\left(x_4-x_3\right)} & \frac{1}{4 x_3-4 x_4}+\frac{1}{4 \left(x_3-x_2\right)} & \frac{1}{4 x_2-4 x_3}+\frac{1}{4 \left(x_2-x_1\right)} &
\frac{1}{4} \left(\frac{1}{x_1-x_2}+\frac{1}{x_1}\right) & -\frac{1}{256 \left(x_1^2-x_1 x_2\right) \left(x_2-x_3\right)
\left(x_3-x_4\right)} \\
\frac{1}{4 x_1} & \frac{1}{4 \left(x_2-x_1\right)} & \frac{1}{2 \left(x_4-x_2\right)} & \frac{1}{2 \left(x_4-x_2\right)} & \frac{1}{2
\left(x_4-x_2\right)} & 0 & \frac{1}{2 x_2-2 x_4}+\frac{1}{4 \left(x_2-x_1\right)} & \frac{1}{4}
\left(\frac{1}{x_1-x_2}+\frac{1}{x_1}\right) & -\frac{1}{64 x_1 \left(x_1-x_2\right) \left(x_2-x_4\right){}^2} \\
\frac{1}{4 x_1} & \frac{1}{2 \left(x_3-x_1\right)} & \frac{1}{2 \left(x_3-x_1\right)} & \frac{1}{4 \left(x_4-x_3\right)} & \frac{1}{4
\left(x_4-x_3\right)} & \frac{1}{4 x_3-4 x_4}+\frac{1}{2 \left(x_3-x_1\right)} & 0 & \frac{1}{4}
\left(\frac{2}{x_1-x_3}+\frac{1}{x_1}\right) & \frac{1}{64 x_1 \left(x_1-x_3\right){}^2 \left(x_4-x_3\right)} \\
\frac{1}{4 x_1} & \frac{3}{4 \left(x_4-x_1\right)} & \frac{3}{4 \left(x_4-x_1\right)} & \frac{3}{4 \left(x_4-x_1\right)} & \frac{3}{4
\left(x_4-x_1\right)} & 0 & 0 & \frac{1}{4} \left(\frac{3}{x_1-x_4}+\frac{1}{x_1}\right) & \frac{27}{256 x_1 \left(x_4-x_1\right){}^3} \\
\frac{1}{2 x_2} & \frac{1}{2 x_2} & \frac{1}{4 \left(x_3-x_2\right)} & \frac{1}{4 \left(x_4-x_3\right)} & \frac{1}{4 \left(x_4-x_3\right)} &
\frac{1}{4 x_3-4 x_4}+\frac{1}{4 \left(x_3-x_2\right)} & \frac{1}{4 x_2-4 x_3}+\frac{1}{2 x_2} & 0 & \frac{1}{64 x_2^2
\left(x_2-x_3\right) \left(x_3-x_4\right)} \\
\frac{1}{2 x_2} & \frac{1}{2 x_2} & \frac{1}{2 \left(x_4-x_2\right)} & \frac{1}{2 \left(x_4-x_2\right)} & \frac{1}{2 \left(x_4-x_2\right)} &
0 & \frac{1}{2} \left(\frac{1}{x_2-x_4}+\frac{1}{x_2}\right) & 0 & \frac{1}{16 x_2^2 \left(x_2-x_4\right){}^2} \\
\frac{3}{4 x_3} & \frac{3}{4 x_3} & \frac{3}{4 x_3} & \frac{1}{4 \left(x_4-x_3\right)} & \frac{1}{4 \left(x_4-x_3\right)} & \frac{1}{4 x_3-4
x_4}+\frac{3}{4 x_3} & 0 & 0 & \frac{27}{256 x_3^3 \left(x_4-x_3\right)} \\
\frac{1}{x_4} & \frac{1}{x_4} & \frac{1}{x_4} & \frac{1}{x_4} & \frac{1}{x_4} & 0 & 0 & 0 & \frac{1}{x_4^4} \\\end{array}
\right]
$$
and for $n = 5$
$$
\left[
\begin{array}{ccccccccccc}
p_1&p_2&p_3&p_4&p_5&\epsilon_1^2&\epsilon_2^2&\epsilon_3^2&\epsilon_4^2&\epsilon_5^2&p_1p_2p_3p_4p_5\\
\frac{1}{5 x_1} & -\frac{1}{5 \left(x_1-x_2\right)} & -\frac{1}{5 \left(x_2-x_3\right)} & -\frac{1}{5 \left(x_3-x_4\right)} & -\frac{1}{5
\left(x_4-x_5\right)} & -\frac{1}{5 \left(x_4-x_5\right)} & \frac{x_3-2 x_4+x_5}{5 \left(x_3-x_4\right) \left(x_4-x_5\right)} &
\frac{x_2-2 x_3+x_4}{5 \left(x_2-x_3\right) \left(x_3-x_4\right)} & \frac{x_1-2 x_2+x_3}{5 \left(x_1-x_2\right) \left(x_2-x_3\right)} &
\frac{2 x_1-x_2}{5 x_1 \left(x_1-x_2\right)} & \frac{1}{3125 x_1 \left(x_1-x_2\right) \left(x_2-x_3\right) \left(x_3-x_4\right)
\left(x_4-x_5\right)} \\
\frac{1}{5 x_1} & -\frac{1}{5 \left(x_1-x_2\right)} & -\frac{1}{5 \left(x_2-x_3\right)} & -\frac{2}{5 \left(x_3-x_5\right)} & -\frac{2}{5
\left(x_3-x_5\right)} & -\frac{2}{5 \left(x_3-x_5\right)} & 0 & \frac{2 x_2-3 x_3+x_5}{5 \left(x_2-x_3\right) \left(x_3-x_5\right)} &
\frac{x_1-2 x_2+x_3}{5 \left(x_1-x_2\right) \left(x_2-x_3\right)} & \frac{2 x_1-x_2}{5 x_1 \left(x_1-x_2\right)} & \frac{4}{3125 x_1
\left(x_1-x_2\right) \left(x_2-x_3\right) \left(x_3-x_5\right){}^2} \\
\frac{1}{5 x_1} & -\frac{1}{5 \left(x_1-x_2\right)} & -\frac{2}{5 \left(x_2-x_4\right)} & -\frac{2}{5 \left(x_2-x_4\right)} & -\frac{1}{5
\left(x_4-x_5\right)} & -\frac{1}{5 \left(x_4-x_5\right)} & \frac{x_2-3 x_4+2 x_5}{5 \left(x_2-x_4\right) \left(x_4-x_5\right)} & 0 &
\frac{2 x_1-3 x_2+x_4}{5 \left(x_1-x_2\right) \left(x_2-x_4\right)} & \frac{2 x_1-x_2}{5 x_1 \left(x_1-x_2\right)} & \frac{4}{3125 x_1
\left(x_1-x_2\right) \left(x_2-x_4\right){}^2 \left(x_4-x_5\right)} \\
\frac{1}{5 x_1} & -\frac{1}{5 \left(x_1-x_2\right)} & -\frac{3}{5 \left(x_2-x_5\right)} & -\frac{3}{5 \left(x_2-x_5\right)} & -\frac{3}{5
\left(x_2-x_5\right)} & -\frac{3}{5 \left(x_2-x_5\right)} & 0 & 0 & \frac{3 x_1-4 x_2+x_5}{5 \left(x_1-x_2\right) \left(x_2-x_5\right)} &
\frac{2 x_1-x_2}{5 x_1 \left(x_1-x_2\right)} & \frac{27}{3125 x_1 \left(x_1-x_2\right) \left(x_2-x_5\right){}^3} \\
\frac{1}{5 x_1} & -\frac{2}{5 \left(x_1-x_3\right)} & -\frac{2}{5 \left(x_1-x_3\right)} & -\frac{1}{5 \left(x_3-x_4\right)} & -\frac{1}{5
\left(x_4-x_5\right)} & -\frac{1}{5 \left(x_4-x_5\right)} & \frac{x_3-2 x_4+x_5}{5 \left(x_3-x_4\right) \left(x_4-x_5\right)} &
\frac{x_1-3 x_3+2 x_4}{5 \left(x_1-x_3\right) \left(x_3-x_4\right)} & 0 & \frac{3 x_1-x_3}{5 x_1 \left(x_1-x_3\right)} & \frac{4}{3125 x_1
\left(x_1-x_3\right){}^2 \left(x_3-x_4\right) \left(x_4-x_5\right)} \\
\frac{1}{5 x_1} & -\frac{2}{5 \left(x_1-x_3\right)} & -\frac{2}{5 \left(x_1-x_3\right)} & -\frac{2}{5 \left(x_3-x_5\right)} & -\frac{2}{5
\left(x_3-x_5\right)} & -\frac{2}{5 \left(x_3-x_5\right)} & 0 & \frac{2 \left(x_1-2 x_3+x_5\right)}{5 \left(x_1-x_3\right)
\left(x_3-x_5\right)} & 0 & \frac{3 x_1-x_3}{5 x_1 \left(x_1-x_3\right)} & \frac{16}{3125 x_1 \left(x_1-x_3\right){}^2
\left(x_3-x_5\right){}^2} \\
\frac{1}{5 x_1} & -\frac{3}{5 \left(x_1-x_4\right)} & -\frac{3}{5 \left(x_1-x_4\right)} & -\frac{3}{5 \left(x_1-x_4\right)} & -\frac{1}{5
\left(x_4-x_5\right)} & -\frac{1}{5 \left(x_4-x_5\right)} & \frac{x_1-4 x_4+3 x_5}{5 \left(x_1-x_4\right) \left(x_4-x_5\right)} & 0 & 0 &
\frac{4 x_1-x_4}{5 x_1 \left(x_1-x_4\right)} & \frac{27}{3125 x_1 \left(x_1-x_4\right){}^3 \left(x_4-x_5\right)} \\
\frac{1}{5 x_1} & -\frac{4}{5 \left(x_1-x_5\right)} & -\frac{4}{5 \left(x_1-x_5\right)} & -\frac{4}{5 \left(x_1-x_5\right)} & -\frac{4}{5
\left(x_1-x_5\right)} & -\frac{4}{5 \left(x_1-x_5\right)} & 0 & 0 & 0 & \frac{5 x_1-x_5}{5 x_1 \left(x_1-x_5\right)} & \frac{256}{3125 x_1
\left(x_1-x_5\right){}^4} \\
\frac{2}{5 x_2} & \frac{2}{5 x_2} & -\frac{1}{5 \left(x_2-x_3\right)} & -\frac{1}{5 \left(x_3-x_4\right)} & -\frac{1}{5
\left(x_4-x_5\right)} & -\frac{1}{5 \left(x_4-x_5\right)} & \frac{x_3-2 x_4+x_5}{5 \left(x_3-x_4\right) \left(x_4-x_5\right)} &
\frac{x_2-2 x_3+x_4}{5 \left(x_2-x_3\right) \left(x_3-x_4\right)} & \frac{3 x_2-2 x_3}{5 x_2 \left(x_2-x_3\right)} & 0 & -\frac{4}{3125
x_2^2 \left(x_2-x_3\right) \left(x_3-x_4\right) \left(x_4-x_5\right)} \\
\frac{2}{5 x_2} & \frac{2}{5 x_2} & -\frac{1}{5 \left(x_2-x_3\right)} & -\frac{2}{5 \left(x_3-x_5\right)} & -\frac{2}{5
\left(x_3-x_5\right)} & -\frac{2}{5 \left(x_3-x_5\right)} & 0 & \frac{2 x_2-3 x_3+x_5}{5 \left(x_2-x_3\right) \left(x_3-x_5\right)} &
\frac{3 x_2-2 x_3}{5 x_2 \left(x_2-x_3\right)} & 0 & -\frac{16}{3125 x_2^2 \left(x_2-x_3\right) \left(x_3-x_5\right){}^2} \\
\frac{2}{5 x_2} & \frac{2}{5 x_2} & -\frac{2}{5 \left(x_2-x_4\right)} & -\frac{2}{5 \left(x_2-x_4\right)} & -\frac{1}{5
\left(x_4-x_5\right)} & -\frac{1}{5 \left(x_4-x_5\right)} & \frac{x_2-3 x_4+2 x_5}{5 \left(x_2-x_4\right) \left(x_4-x_5\right)} & 0 &
\frac{2 \left(2 x_2-x_4\right)}{5 x_2 \left(x_2-x_4\right)} & 0 & -\frac{16}{3125 x_2^2 \left(x_2-x_4\right){}^2 \left(x_4-x_5\right)} \\
\frac{2}{5 x_2} & \frac{2}{5 x_2} & -\frac{3}{5 \left(x_2-x_5\right)} & -\frac{3}{5 \left(x_2-x_5\right)} & -\frac{3}{5
\left(x_2-x_5\right)} & -\frac{3}{5 \left(x_2-x_5\right)} & 0 & 0 & \frac{5 x_2-2 x_5}{5 x_2 \left(x_2-x_5\right)} & 0 & -\frac{108}{3125
x_2^2 \left(x_2-x_5\right){}^3} \\
\frac{3}{5 x_3} & \frac{3}{5 x_3} & \frac{3}{5 x_3} & -\frac{1}{5 \left(x_3-x_4\right)} & -\frac{1}{5 \left(x_4-x_5\right)} & -\frac{1}{5
\left(x_4-x_5\right)} & \frac{x_3-2 x_4+x_5}{5 \left(x_3-x_4\right) \left(x_4-x_5\right)} & \frac{4 x_3-3 x_4}{5 x_3 \left(x_3-x_4\right)}
& 0 & 0 & \frac{27}{3125 x_3^3 \left(x_3-x_4\right) \left(x_4-x_5\right)} \\
\frac{3}{5 x_3} & \frac{3}{5 x_3} & \frac{3}{5 x_3} & -\frac{2}{5 \left(x_3-x_5\right)} & -\frac{2}{5 \left(x_3-x_5\right)} & -\frac{2}{5
\left(x_3-x_5\right)} & 0 & \frac{5 x_3-3 x_5}{5 x_3 \left(x_3-x_5\right)} & 0 & 0 & \frac{108}{3125 x_3^3 \left(x_3-x_5\right){}^2} \\
\frac{4}{5 x_4} & \frac{4}{5 x_4} & \frac{4}{5 x_4} & \frac{4}{5 x_4} & -\frac{1}{5 \left(x_4-x_5\right)} & -\frac{1}{5
\left(x_4-x_5\right)} & \frac{5 x_4-4 x_5}{5 x_4 \left(x_4-x_5\right)} & 0 & 0 & 0 & -\frac{256}{3125 x_4^4 \left(x_4-x_5\right)} \\
\frac{1}{x_5} & \frac{1}{x_5} & \frac{1}{x_5} & \frac{1}{x_5} & \frac{1}{x_5} & \frac{1}{x_5} & 0 & 0 & 0 & 0 & \frac{1}{x_5^5} \\
\end{array}
\right]
$$
Best Answer
Introduce a variable $v$ to represent $\min\{x,2y\}$ and solve two linear programming problems:
Maximize $v+3z$ subject to \begin{align} v &\le x \\ v &\le 2y \\ 3z &\ge 4w \\ p_1 x + p_2 y + p_3 z + p_4 w &\le I \\ \end{align}
Maximize $v+4w$ subject to \begin{align} v &\le x \\ v &\le 2y \\ 3z &\le 4w \\ p_1 x + p_2 y + p_3 z + p_4 w &\le I \\ \end{align}
Take whichever solution yields the larger of the two resulting objective values.