Find number of ways to create sequence $A$ of length $n$ satisfying $m$ conditions


Find number of ways to create sequence $ A$ of length $ n$ satisfying $ m$ conditions. This sequence $ A$ should consist of only non negative numbers. Each condition is described by three integers $ i,j,k$ signifying $ max$ ($ A_{i}$ ,$ A_{j}$ )=$ k$ .
It is guaranteed that each index of the sequence will be there in at least one condition i.e. there will be finite number of such sequences.
The maximum value of $ n$ will not exceed $ 18$ and maximum value of $ k$ will not exceed $ 2*10^4$ .
I tried it using dynamic programming but the time complexity came out to be exponential. Can you suggest me any better approach which will reduce the time complexity?