#include <bits/stdc++.h>
using namespace std;
string S;
int a,b,c,d, Q;
int palavra1[100];
int palavra2[100];
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> S >> Q;
for(int i = 1; i<=Q; i++){
cin >> a >> b >> c >> d;
for(int k = a; k <= b; k++) palavra1[(int)S[k-1] - 96]++;
for(int k = c; k <= d; k++) palavra2[(int)S[k-1] - 96]++;
/*
for(int k=1; k<=27; k++) cout << palavra1[k] << " ";
cout << endl;
for(int k=1; k<=27; k++) cout << palavra2[k] << " ";
cout << endl;
*/
bool ok = true;
for(int k=1; k<=27; k++){
if(palavra1[k]!=palavra2[k]) ok = false;
palavra1[k] = palavra2[k] = 0;
}
if(ok) cout << "DA\n";
else cout << "NE\n";
}
return 0;
}