function [A,B,Q] = HMM_BERUSKA(O)

param = size(O,1);
Q = 11;

mu=zeros(param,Q);
vr=zeros(param,Q);
cv=zeros(param,param,Q);

mu(:,2) = [ -7.313049e+000 -9.398881e-001 -4.510057e-001 -7.288507e-001 -2.897759e-001 -7.751375e-002 -3.618123e-003 -1.390386e-001 2.084902e-001 -1.320959e-001 8.817019e-002 -1.228079e-001 6.917090e+001 -3.107722e-002 8.907292e-003 9.247836e-003 1.905289e-002 1.233459e-002 1.001064e-002 1.002233e-002 8.150973e-003 3.113299e-003 3.548607e-003 2.532211e-003 1.085190e-003 -1.025690e-001 7.951854e-003 -8.182072e-003 -6.170174e-003 -1.514464e-002 -6.019351e-003 -8.480256e-003 -3.986343e-003 -5.266401e-003 -1.843392e-003 -2.877901e-003 -8.476687e-004 -6.497114e-004 8.289810e-002]';
vr(:,2) = [3.163979e+000 2.168602e+000 1.371846e+000 1.517981e+000 9.038908e-001 8.897811e-001 6.909518e-001 5.652684e-001 5.599021e-001 5.125359e-001 4.591469e-001 4.670824e-001 3.629802e+001 1.388832e-001 9.953099e-002 7.722628e-002 7.820329e-002 6.347974e-002 6.216895e-002 5.599645e-002 5.214563e-002 4.893730e-002 4.565161e-002 4.265450e-002 4.052969e-002 8.744203e-001 2.787767e-002 2.031806e-002 1.623932e-002 1.644616e-002 1.327494e-002 1.286692e-002 1.156766e-002 1.087449e-002 1.014029e-002 9.546626e-003 8.929418e-003 8.537616e-003 1.812941e-001]';
cv(:,:,2) = diag(vr(:,2));
gconst(2) = -1.317014e+001;

mu(:,3) = [-1.621377e+000 -4.453452e-001 -1.787026e+000 -3.078322e+000 -2.697741e+000 -2.739373e+000 -1.753876e+000 -1.332573e+000 -9.848484e-001 -9.055177e-001 -4.246274e-001 -4.549552e-001 8.127512e+001 -3.696124e-001 -1.375416e-001 1.162721e-001 -7.313237e-002 5.519211e-002 5.416070e-002 6.255484e-002 -5.232111e-003 4.066866e-002 4.605709e-003 2.537220e-002 -3.037072e-003 5.182204e-001 -1.652412e-001 -2.649247e-001 -1.453421e-001 -1.970941e-001 1.437897e-003 -2.796310e-002 6.620608e-002 2.193618e-002 4.980065e-002 1.363773e-002 8.935463e-003 -1.357568e-002 1.772392e+000];
vr(:,3) = [6.668507e+000 5.238743e+000 2.839279e+000 2.149852e+000 1.560984e+000 1.739775e+000 1.631311e+000 1.349365e+000 1.256409e+000 1.047792e+000 9.201391e-001 7.781480e-001 6.779091e+001 7.437097e-001 1.128874e+000 3.997987e-001 4.907404e-001 1.643707e-001 1.668303e-001 1.890328e-001 1.333354e-001 1.328436e-001 9.759200e-002 7.807993e-002 6.866559e-002 2.478067e+001 1.470881e-001 1.347253e-001 5.939887e-002 5.308220e-002 3.089979e-002 3.298876e-002 3.045420e-002 2.572247e-002 2.288560e-002 1.889402e-002 1.561905e-002 1.358917e-002 1.725672e+000];
cv(:,:,3) = diag(vr(:,3));

mu(:,4) = [-5.652693e+000 -4.615658e+000 -2.951687e+000 -6.895529e+000 -2.690160e+000 -1.732640e+000 -4.101386e-001 -1.908145e+000 4.470546e-002 -1.065471e+000 -5.548403e-001 -4.460121e-001 1.102027e+002 2.847615e-001 1.058228e-001 5.352417e-002 3.017063e-002 -6.559902e-002 -2.231777e-002 -4.896455e-002 -2.233832e-002 -5.249316e-002 -6.145196e-004 -3.299612e-002 -1.492214e-002 -5.427094e-001 -6.388226e-002 1.414389e-001 5.564144e-002 1.609482e-001 6.562461e-002 -5.549205e-003 -2.051019e-003 5.329981e-002 -9.825671e-003 2.160343e-002 2.673190e-002 3.019699e-003 -1.050667e+000];
vr(:,4) = [1.016467e+001 8.372550e+000 3.267163e+000 3.284851e+000 3.946333e+000 2.220042e+000 1.971026e+000 1.683012e+000 1.512034e+000 1.961291e+000 1.249286e+000 1.248523e+000 1.649046e+002 9.557528e-001 7.732920e-001 2.755146e-001 4.788254e-001 2.462779e-001 1.959681e-001 1.378614e-001 1.330008e-001 1.054550e-001 1.039458e-001 9.952246e-002 8.163809e-002 2.124301e+001 1.870248e-001 1.010609e-001 4.240693e-002 5.646939e-002 4.331052e-002 3.720109e-002 2.576043e-002 2.202496e-002 1.933648e-002 1.898772e-002 1.799011e-002 1.529474e-002 1.844348e+000];
cv(:,:,4) = diag(vr(:,4));

mu(:,5) = [-5.138490e+000 -6.607156e+000 -2.764356e+000 -5.735899e+000 -3.267683e+000 -2.423122e+000 4.363049e-001 -1.331548e+000 -4.696270e-001 -6.273233e-001 -3.636466e-001 -6.644976e-001 1.106756e+002 2.414295e-001 -1.105582e-001 -1.015936e-001 -1.310272e-001 -1.201383e-001 -1.162828e-001 -3.604801e-002 -3.710509e-002 -5.636860e-002 -4.598598e-002 -2.952433e-002 -2.881427e-002 1.173055e+000 1.049023e-002 1.264918e-001 6.174608e-004 1.053397e-001 7.455110e-002 2.481753e-002 -4.897345e-002 2.940289e-002 1.569034e-002 -1.151004e-003 1.006300e-002 1.720161e-002 -7.341132e-001];
vr(:,5) = [8.898527e+000 7.274529e+000 3.864522e+000 3.301283e+000 2.725281e+000 2.735561e+000 1.669619e+000 1.856173e+000 1.378671e+000 1.134494e+000 1.079001e+000 8.193450e-001 1.658485e+002 7.463322e-001 7.349408e-001 4.013654e-001 3.767803e-001 2.460454e-001 2.066879e-001 1.467904e-001 1.387437e-001 1.185513e-001 9.134461e-002 8.561751e-002 7.021905e-002 1.649706e+001 1.472147e-001 1.230341e-001 7.962295e-002 5.576596e-002 4.213194e-002 3.501515e-002 2.552259e-002 2.342487e-002 2.173896e-002 1.728433e-002 1.674902e-002 1.349838e-002 2.223754e+000];
cv(:,:,5) = diag(vr(:,5));

mu(:,6) = [-6.374424e-001 -3.449837e+000 -5.194018e+000 -4.110452e+000 -2.333413e+000 -3.465592e+000 -1.587981e+000 -7.788820e-001 -3.900239e-002 -5.360528e-001 -3.606174e-001 -6.854025e-001 9.599519e+001 3.623443e-003 1.318213e-001 8.907953e-002 3.466142e-002 -1.566330e-002 -2.497277e-003 -1.539356e-002 2.526057e-003 -1.537508e-002 -3.564730e-003 -1.744805e-002 -5.585291e-003 -3.958968e-001 -1.931513e-001 3.958589e-002 1.182444e-001 3.467158e-002 2.949168e-002 6.945509e-002 4.603978e-002 -6.317663e-003 -5.148759e-003 8.108493e-003 1.136714e-002 9.529356e-003 -3.283142e-001];
vr(:,6) = [8.054543e+000 6.502929e+000 5.942059e+000 2.731102e+000 2.422907e+000 2.676124e+000 2.302071e+000 1.629028e+000 1.335677e+000 1.374703e+000 1.186637e+000 9.914073e-001 1.705191e+002 1.063450e+000 4.151200e-001 6.502147e-001 2.612229e-001 1.908476e-001 2.491034e-001 1.913918e-001 1.287643e-001 1.081986e-001 9.810293e-002 8.310411e-002 7.426784e-002 9.235799e+000 1.226237e-001 6.997315e-002 8.005074e-002 4.214157e-002 3.643373e-002 3.896218e-002 2.974814e-002 2.465434e-002 2.055153e-002 1.849015e-002 1.571884e-002 1.421743e-002 1.112672e+000];
cv(:,:,6) = diag(vr(:,6));

mu(:,7) = [-1.603416e+001 7.507358e-001 -1.407832e+000 -4.127440e+000 1.407664e-002 -1.656041e+000 4.679846e-002 -9.190412e-001 5.436572e-001 -6.947153e-001 3.350086e-001 -3.955967e-001 9.501358e+001 -1.541677e-002 5.344535e-002 -7.461143e-002 1.795507e-002 2.954059e-002 1.888430e-002 3.052400e-002 2.707495e-002 1.531634e-002 1.196435e-002 1.773604e-002 2.118004e-002 -2.584564e-001 3.830172e-001 -7.200656e-002 -3.770571e-002 -6.588890e-002 -8.853020e-002 -4.455511e-002 -3.820749e-002 -1.621041e-002 -2.740145e-002 -4.379787e-003 -1.729693e-002 -6.324748e-003 1.483322e-001];
vr(:,7) = [1.558496e+001 9.357395e+000 5.139068e+000 4.044436e+000 2.370071e+000 1.734317e+000 1.301193e+000 1.204043e+000 8.197531e-001 8.864431e-001 6.775458e-001 6.526102e-001 1.550867e+002 3.289991e+000 5.003857e-001 2.457228e-001 3.506598e-001 2.880684e-001 1.750401e-001 1.368733e-001 1.066352e-001 8.486561e-002 7.059494e-002 7.052024e-002 6.015307e-002 5.861481e+000 2.196120e-001 7.715791e-002 4.908770e-002 4.684436e-002 3.399236e-002 2.720158e-002 2.332206e-002 1.985351e-002 1.659907e-002 1.448548e-002 1.353637e-002 1.216432e-002 9.334090e-001];
cv(:,:,7) = diag(vr(:,7));

mu(:,8) = [-6.545323e+000 -3.892320e+000 -1.636953e+000 -2.222779e+000 -1.014096e+000 -9.023929e-001 1.103083e-003 -2.985399e-001 1.321728e-001 -2.284619e-001 5.709594e-002 -2.461104e-001 8.240534e+001 -1.893980e-002 -3.273061e-001 -1.775057e-001 -6.073304e-002 4.163495e-002 -4.962487e-002 3.911957e-002 3.734658e-002 3.037159e-002 -1.502426e-002 9.716090e-003 1.767162e-002 1.140246e+000 1.125629e-001 -1.703891e-002 -9.927938e-002 -1.330571e-001 -5.118115e-002 -7.256605e-002 -4.440103e-002 -3.517200e-002 -2.585248e-002 -2.186541e-002 -1.990273e-002 -1.605375e-002 8.911036e-001];
vr(:,8) = [1.270238e+001 1.381968e+001 5.881086e+000 5.416528e+000 2.727337e+000 2.071733e+000 1.482240e+000 1.328801e+000 1.007770e+000 7.911476e-001 6.821217e-001 5.817094e-001 1.626822e+002 1.510991e+000 1.742701e+000 5.902455e-001 7.072293e-001 3.172706e-001 2.990301e-001 1.996341e-001 1.575205e-001 1.155321e-001 9.620684e-002 8.330090e-002 7.047909e-002 2.746779e+001 2.696688e-001 3.676652e-001 9.530207e-002 9.549393e-002 5.675465e-002 4.484101e-002 3.335138e-002 2.812197e-002 2.218434e-002 1.852601e-002 1.630673e-002 1.398936e-002 4.171160e+000];
cv(:,:,8) = diag(vr(:,8));

mu(:,9) = [-4.481637e+000 -8.077502e+000 -4.016692e+000 -3.959216e+000 -1.943099e+000 -1.942464e+000 -5.334513e-002 -1.779836e+000 -9.108570e-001 -8.647965e-001 -1.575557e-001 -3.417000e-001 1.108569e+002 1.572965e-001 1.522747e-001 3.694922e-002 6.427733e-002 -1.576646e-002 2.460924e-003 -4.861242e-002 -8.977579e-003 -2.786925e-002 -1.844933e-003 -7.239067e-003 -6.211887e-003 -7.288184e-001 -5.171122e-002 2.275510e-001 9.396244e-002 3.644866e-002 2.680325e-002 8.704010e-003 -1.878852e-002 3.775245e-002 2.848845e-002 1.600545e-002 3.224804e-003 4.063338e-004 -1.001832e+000];
vr(:,9) = [1.090561e+001 9.380291e+000 4.552089e+000 4.492853e+000 3.058557e+000 2.528795e+000 2.069547e+000 2.826441e+000 1.757432e+000 1.402670e+000 1.125660e+000 1.032359e+000 2.222020e+002 7.745796e-001 1.412038e+000 4.231963e-001 3.036933e-001 1.844625e-001 1.880224e-001 1.470821e-001 1.549169e-001 1.284645e-001 1.011812e-001 8.199082e-002 6.975959e-002 2.564225e+001 1.581634e-001 1.436237e-001 5.938128e-002 5.372630e-002 3.572884e-002 3.539442e-002 2.820129e-002 2.596946e-002 2.251661e-002 1.860138e-002 1.593943e-002 1.345356e-002 2.273973e+000];
cv(:,:,9) = diag(vr(:,9));

mu(:,10) = [ -7.313049e+000 -9.398881e-001 -4.510057e-001 -7.288507e-001 -2.897759e-001 -7.751375e-002 -3.618123e-003 -1.390386e-001 2.084902e-001 -1.320959e-001 8.817019e-002 -1.228079e-001 6.917090e+001 -3.107722e-002 8.907292e-003 9.247836e-003 1.905289e-002 1.233459e-002 1.001064e-002 1.002233e-002 8.150973e-003 3.113299e-003 3.548607e-003 2.532211e-003 1.085190e-003 -1.025690e-001 7.951854e-003 -8.182072e-003 -6.170174e-003 -1.514464e-002 -6.019351e-003 -8.480256e-003 -3.986343e-003 -5.266401e-003 -1.843392e-003 -2.877901e-003 -8.476687e-004 -6.497114e-004 8.289810e-002]';
vr(:,10) = [3.163979e+000 2.168602e+000 1.371846e+000 1.517981e+000 9.038908e-001 8.897811e-001 6.909518e-001 5.652684e-001 5.599021e-001 5.125359e-001 4.591469e-001 4.670824e-001 3.629802e+001 1.388832e-001 9.953099e-002 7.722628e-002 7.820329e-002 6.347974e-002 6.216895e-002 5.599645e-002 5.214563e-002 4.893730e-002 4.565161e-002 4.265450e-002 4.052969e-002 8.744203e-001 2.787767e-002 2.031806e-002 1.623932e-002 1.644616e-002 1.327494e-002 1.286692e-002 1.156766e-002 1.087449e-002 1.014029e-002 9.546626e-003 8.929418e-003 8.537616e-003 1.812941e-001]';
cv(:,:,10) = diag(vr(:,10));
gconst(10) = -1.317014e+001;


A = [
    0.000000e+000 1.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000;
    0.000000e+000 9.649747e-001 3.502526e-002 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000;
    0.000000e+000 0.000000e+000 8.347217e-001 1.652783e-001 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000;
    0.000000e+000 0.000000e+000 0.000000e+000 8.426186e-001 1.573814e-001 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000;
    0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 8.208070e-001 1.791930e-001 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000;
    0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 8.866652e-001 1.133348e-001 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000;
    0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 9.070622e-001 9.293784e-002 0.000000e+000 0.000000e+000 0.000000e+000;
    0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 8.789026e-001 1.210974e-001 0.000000e+000 0.000000e+000;
    0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 8.722202e-001 1.277798e-001 0.000000e+000;
    0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 9.649747e-001 3.502526e-002;
    0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000;
    ];

B=zeros(Q,size(O,2));


for i = 1 : size(O,2)
    o = O(:,i);
    for j = 2 : Q-1
        B(j,i) =  (1/((((2*pi)^param)*det(cv(:,:,j)))^(1/2)))*exp(-0.5*(o-mu(:,j))'*inv(cv(:,:,j))*(o-mu(:,j)));
    end
end