#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;
const double inf=12345678901234567890;
const int nmax=555;
double dp[nmax][nmax][2], b[nmax], t[nmax], mint[nmax][nmax];
double a, w, d, v;
int n, ind[nmax], list[nmax], r, s[nmax][nmax][2][3];
bool used[nmax][nmax][2];
double min(double x, double y){return x<y?x:y;}
void Solve(int i, int j, int k);
double Time(double x, double y);
void Update(double &oldv, double newv, int i, int j, int k, int i1, int j1, int k1);
int main()
{
cin>>a>>w>>n;
for(int i=1;i<=n;i++)
{
cin>>b[i]>>d>>v;
ind[i]=i;
b[i]-=a;
if(b[i]<0) b[i]+=360.0;
t[i]=(d-1.0)*60.0*(360.0*w);
}
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n;j++)
if(b[j]<b[i])
{
double c;
c=b[i], b[i]=b[j], b[j]=c;
c=t[i], t[i]=t[j], t[j]=c;
int q;
q=ind[i], ind[i]=ind[j], ind[j]=q;
}
for(int i=1;i<=n;i++)
for(int j=i;j<=n;j++)
{
used[i][j][0]=used[i][j][1]=false;
mint[i][j]=t[i];
for(int k=i+1;k<=j;k++) mint[i][j]=min(mint[i][j], t[k]);
}
for(int i=1;i<=n;i++)
{
Solve(i,i,0);
Solve(i,i,1);
}
int i=1, j=1, k=0;
double ans=dp[1][1][0];
for(j=2;j<=n;j++)
if(ans>dp[j][j][0]) ans=dp[j][j][0], i=j;
if(ans==inf) cout<<"Impossible";
else
{
printf("%.5lf",ans/(v*(360.0*w)));
r=1, list[r]=ind[i], j=i;
while(i>1 || j<n)
{
int i1=s[i][j][k][0];
int j1=s[i][j][k][1];
int k1=s[i][j][k][2];
if(i1!=i) list[++r]=ind[i1];
else list[++r]=ind[j1];
i=i1, j=j1, k=k1;
}
for(int i=n;i>=1;i--) cout<<endl<<list[i];
}
return 0;
}
void Solve(int i, int j, int k)
{
if(i==1 && j==n)
{
dp[i][j][k]=inf, used[i][j][k]=true;
if(k==0)
{
if(Time(0,b[1])<=mint[1][n]) dp[i][j][k]=Time(0,b[1]);
}
else
{
if(Time(0,b[n])<=mint[1][n]) dp[i][j][k]=Time(0,b[n]);
}
return;
}
//1<i || j<n
if(k==0)
{
dp[i][j][k]=inf, used[i][j][k]=true;
if(i>1)
{
if(!used[i-1][j][0]) Solve(i-1,j,0);
if(dp[i-1][j][0]<inf && dp[i-1][j][0]+Time(b[i-1],b[i])<=mint[i][j])
Update(dp[i][j][k], dp[i-1][j][0]+Time(b[i-1],b[i]), i,j,k,i-1,j,0);
}
if(j<n)
{
if(!used[i][j+1][1]) Solve(i,j+1,1);
if(dp[i][j+1][1]<inf && dp[i][j+1][1]+Time(b[j+1],b[i])<=mint[i][j])
Update(dp[i][j][k], dp[i][j+1][1]+Time(b[j+1],b[i]), i,j,k,i,j+1,1);
}
}
else
{
dp[i][j][k]=inf, used[i][j][k]=true;
if(i>1)
{
if(!used[i-1][j][0]) Solve(i-1,j,0);
if(dp[i-1][j][0]<inf && dp[i-1][j][0]+Time(b[i-1],b[j])<=mint[i][j])
Update(dp[i][j][k], dp[i-1][j][0]+Time(b[i-1],b[j]), i,j,k,i-1,j,0);
}
if(j<n)
{
if(!used[i][j+1][1]) Solve(i,j+1,1);
if(dp[i][j+1][1]<inf && dp[i][j+1][1]+Time(b[j+1],b[j])<=mint[i][j])
Update(dp[i][j][k], dp[i][j+1][1]+Time(b[j+1],b[j]), i,j,k,i,j+1,1);
}
}
}
double Time(double x, double y)
{
if(x>y) return Time(y,x);
else return min(x+360.0-y,y-x)*v;
}
void Update(double &oldv, double newv, int i, int j, int k, int i1, int j1, int k1)
{
if(oldv>newv) oldv=newv, s[i][j][k][0]=i1, s[i][j][k][1]=j1, s[i][j][k][2]=k1;
}
I2RlZmluZSBfQ1JUX1NFQ1VSRV9OT19XQVJOSU5HUwojaW5jbHVkZSA8aW9zdHJlYW0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBkb3VibGUgaW5mPTEyMzQ1Njc4OTAxMjM0NTY3ODkwOwpjb25zdCBpbnQgbm1heD01NTU7Cgpkb3VibGUgZHBbbm1heF1bbm1heF1bMl0sIGJbbm1heF0sIHRbbm1heF0sIG1pbnRbbm1heF1bbm1heF07CmRvdWJsZSBhLCB3LCBkLCB2OwppbnQgbiwgaW5kW25tYXhdLCBsaXN0W25tYXhdLCByLCBzW25tYXhdW25tYXhdWzJdWzNdOwpib29sIHVzZWRbbm1heF1bbm1heF1bMl07CgoKZG91YmxlIG1pbihkb3VibGUgeCwgZG91YmxlIHkpe3JldHVybiB4PHk/eDp5O30Kdm9pZCBTb2x2ZShpbnQgaSwgaW50IGosIGludCBrKTsKZG91YmxlIFRpbWUoZG91YmxlIHgsIGRvdWJsZSB5KTsKdm9pZCBVcGRhdGUoZG91YmxlICZvbGR2LCBkb3VibGUgbmV3diwgaW50IGksIGludCBqLCBpbnQgaywgaW50IGkxLCBpbnQgajEsIGludCBrMSk7CgppbnQgbWFpbigpCnsKICAgY2luPj5hPj53Pj5uOwogICAKICAgZm9yKGludCBpPTE7aTw9bjtpKyspCiAgIHsKICAgICAgY2luPj5iW2ldPj5kPj52OwogICAgICBpbmRbaV09aTsKICAgICAgYltpXS09YTsKICAgICAgaWYoYltpXTwwKSBiW2ldKz0zNjAuMDsKICAgICAgdFtpXT0oZC0xLjApKjYwLjAqKDM2MC4wKncpOwogICB9CiAgIAogICBmb3IoaW50IGk9MTtpPD1uO2krKykKICAgICAgZm9yKGludCBqPWkrMTtqPD1uO2orKykKICAgICAgICAgaWYoYltqXTxiW2ldKQogICAgICAgICB7CiAgICAgICAgICAgIGRvdWJsZSBjOwogICAgICAgICAgICBjPWJbaV0sIGJbaV09YltqXSwgYltqXT1jOwogICAgICAgICAgICBjPXRbaV0sIHRbaV09dFtqXSwgdFtqXT1jOwogICAgICAgICAgICBpbnQgcTsKICAgICAgICAgICAgcT1pbmRbaV0sIGluZFtpXT1pbmRbal0sIGluZFtqXT1xOwogICAgICAgICB9CgogICBmb3IoaW50IGk9MTtpPD1uO2krKykKICAgICAgZm9yKGludCBqPWk7ajw9bjtqKyspCiAgICAgIHsKICAgICAgICAgdXNlZFtpXVtqXVswXT11c2VkW2ldW2pdWzFdPWZhbHNlOwogICAgICAgICBtaW50W2ldW2pdPXRbaV07CiAgICAgICAgIGZvcihpbnQgaz1pKzE7azw9ajtrKyspIG1pbnRbaV1bal09bWluKG1pbnRbaV1bal0sIHRba10pOwogICAgICB9CiAgIAogICBmb3IoaW50IGk9MTtpPD1uO2krKykKICAgewogICAgICBTb2x2ZShpLGksMCk7CiAgICAgIFNvbHZlKGksaSwxKTsKICAgfQogICAKICAgaW50IGk9MSwgaj0xLCBrPTA7CiAgIGRvdWJsZSBhbnM9ZHBbMV1bMV1bMF07CiAgIGZvcihqPTI7ajw9bjtqKyspCiAgICAgIGlmKGFucz5kcFtqXVtqXVswXSkgYW5zPWRwW2pdW2pdWzBdLCBpPWo7CiAgIAoKICAgaWYoYW5zPT1pbmYpIGNvdXQ8PCJJbXBvc3NpYmxlIjsKICAgZWxzZQogICB7CiAgICAgIHByaW50ZigiJS41bGYiLGFucy8odiooMzYwLjAqdykpKTsKICAgICAgcj0xLCBsaXN0W3JdPWluZFtpXSwgaj1pOwogICAgICB3aGlsZShpPjEgfHwgajxuKQogICAgICB7CiAgICAgICAgIGludCBpMT1zW2ldW2pdW2tdWzBdOwogICAgICAgICBpbnQgajE9c1tpXVtqXVtrXVsxXTsKICAgICAgICAgaW50IGsxPXNbaV1bal1ba11bMl07CiAgICAgICAgIGlmKGkxIT1pKSBsaXN0Wysrcl09aW5kW2kxXTsKICAgICAgICAgZWxzZSBsaXN0Wysrcl09aW5kW2oxXTsKICAgICAgICAgaT1pMSwgaj1qMSwgaz1rMTsKICAgICAgfQogICAgICBmb3IoaW50IGk9bjtpPj0xO2ktLSkgY291dDw8ZW5kbDw8bGlzdFtpXTsKICAgfQogICAKICAgcmV0dXJuIDA7Cn0KCgp2b2lkIFNvbHZlKGludCBpLCBpbnQgaiwgaW50IGspCnsKICAgaWYoaT09MSAmJiBqPT1uKQogICB7CiAgICAgIGRwW2ldW2pdW2tdPWluZiwgdXNlZFtpXVtqXVtrXT10cnVlOwogICAgICBpZihrPT0wKQogICAgICB7CiAgICAgICAgIGlmKFRpbWUoMCxiWzFdKTw9bWludFsxXVtuXSkgZHBbaV1bal1ba109VGltZSgwLGJbMV0pOwogICAgICB9CiAgICAgIGVsc2UKICAgICAgewogICAgICAgICAgaWYoVGltZSgwLGJbbl0pPD1taW50WzFdW25dKSBkcFtpXVtqXVtrXT1UaW1lKDAsYltuXSk7CiAgICAgIH0KICAgICAgcmV0dXJuOwogICB9CiAgIC8vMTxpIHx8IGo8bgogICBpZihrPT0wKQogICB7CiAgICAgIGRwW2ldW2pdW2tdPWluZiwgdXNlZFtpXVtqXVtrXT10cnVlOwogICAgICBpZihpPjEpCiAgICAgIHsKICAgICAgICAgaWYoIXVzZWRbaS0xXVtqXVswXSkgU29sdmUoaS0xLGosMCk7CiAgICAgICAgIGlmKGRwW2ktMV1bal1bMF08aW5mICYmIGRwW2ktMV1bal1bMF0rVGltZShiW2ktMV0sYltpXSk8PW1pbnRbaV1bal0pCiAgICAgICAgICAgIFVwZGF0ZShkcFtpXVtqXVtrXSwgZHBbaS0xXVtqXVswXStUaW1lKGJbaS0xXSxiW2ldKSwgaSxqLGssaS0xLGosMCk7CiAgICAgIH0KICAgICAgaWYoajxuKQogICAgICB7CiAgICAgICAgIGlmKCF1c2VkW2ldW2orMV1bMV0pIFNvbHZlKGksaisxLDEpOwogICAgICAgICBpZihkcFtpXVtqKzFdWzFdPGluZiAmJiBkcFtpXVtqKzFdWzFdK1RpbWUoYltqKzFdLGJbaV0pPD1taW50W2ldW2pdKQogICAgICAgICAgICBVcGRhdGUoZHBbaV1bal1ba10sIGRwW2ldW2orMV1bMV0rVGltZShiW2orMV0sYltpXSksIGksaixrLGksaisxLDEpOwogICAgICB9CiAgIH0KICAgZWxzZQogICB7CiAgICAgIGRwW2ldW2pdW2tdPWluZiwgdXNlZFtpXVtqXVtrX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