// 6/17/2026
// Solution to Kattis Problem: Hidden Password
// https://open.kattis.com/problems/hidden

using namespace std;
#include <bits/stdc++.h>

bool solve(string& pass, string& whole);
int getNext(string& pass, int pI, string& whole, int wI);

int main() {

    // Get data, use a string for the middle item.
    string pass, whole;
    cin >> pass >> whole;

    // Solve and output accordingly.
    if (solve(pass, whole))
        cout << "PASS" << endl;
    else
        cout << "FAIL" << endl;

    return 0;
}

bool solve(string& pass, string& whole) {

    // Go through the password, letter by letter.
    int curI = 0;
    for (int i=0; i<pass.size(); i++) {

        // Get the next index of j starting at curI, -1 is returned if no
        // such index exists or if the wrong letter comes next.
        int j = getNext(pass, i, whole, curI);

        // Can't do it.
        if (j == -1) return false;

        // Update curI.
        curI = j+1;
    }

    // If we get here we are good.
    return true;
}

// Returns next occurence of pass[pI] in whole starting at wI.
// Returns -1 if the wrong letter comes next or no such occurrence.
int getNext(string& pass, int pI, string& whole, int wI) {

    // Go to each index.
    for (int i=wI; i<whole.size(); i++) {

        // We found it.
        if (whole[i] == pass[pI]) return i;

        // This only works since the data is small...
        // If we find a future letter and haven't found pass[pI] yet, it's bad.
        for (int j=pI+1; j<pass.size(); j++)
            if (pass[j] == whole[i])
                return -1;
    }

    // We never found the letter we needed.
    return -1;
}
