#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define stop char nyaa;cin>>nyaa;

struct cors {
	int a, k, t;
};
void solve() {
	int n, m, l; cin >> n >> m >> l;
	vector<vector<cors>> v(5);
	rep(i, m) {
		int d, a, k, t; cin >> d >> a >> k >> t; a--;
		v[d].push_back({ a,k,t });
	}
	vector<vector<int>> memo(5);
	rep(i, 5) {
		memo[i].resize(n + 1, -mod);
	}
	rep(i, 5) {
		vector<vector<int>> dp(1 << n);
		rep(j, (1 << n)) {
			dp[j].resize(n + 1, -mod);
		}
		dp[0][0] = 0;
		rep(j, v[i].size()) {
			cors &c = v[i][j];
			int s = 0;
			Rep(k, c.a, c.a + c.k) {
				s += (1 << k);
			}
			rep(k, (1 << n)) {
				if (k&s)continue;
				rep(x, n) {
					dp[k | s][x + 1] = max(dp[k | s][x + 1], dp[k][x] + c.t);
				}
			}
		}
		rep(j, (1 << n)) {
			rep(k, n + 1) {
				memo[i][k] = max(memo[i][k], dp[j][k]);
			}
		}
		//cout << "hello " << i << endl;
		//rep(k, n + 1)cout << memo[i][k] << endl;
	}
	vector<int> dp(41,-mod);
	dp[0] = 0;
	rep(i, 5) {
		vector<int> cop(41, -mod);
		rep(j, 41) {
			rep(k, memo[i].size()) {
				if (j + k > 40)break;
				cop[j + k] = max(cop[j + k], dp[j] + memo[i][k]);
			}
		}
		dp = cop;
	}
	int ans = 0;
	rep(i, l + 1) {
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
		return 0;
}

