#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,t) for(int i = s; i < t ; ++i)
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define UNIQ(a) a.erase(unique(ALL(a)),a.end())
#define debug(a) cerr<<#a":="<<a<<endl;
#define SZ(a) (int)a.size()
using LL = long long; template<class T> using V = vector <T>; template <class T> using VV = V<V<T>>;

int dp[5][10][301];

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int N, M, L; cin >> N >> M >> L;
	//[0,8)をきめる * 5
	using tp = tuple<int, int, int, int>;
	V<tp>Info(M);
	V<int>d(M), a(M), k(M), t(M);
	FOR(i, 0, M) {
		cin >> d[i] >> a[i] >> k[i] >> t[i];
	}
	FOR(x, 0, 5) {
		if (x >= 1) {
			FOR(z, 1, L + 1) {
				dp[x][0][z] = dp[x - 1][N][z];
			}
		}
		FOR(y, 1, N + 1) {
			FOR(z, 1, L + 1) {
				dp[x][y][z] = dp[x][y - 1][z];
			}
			FOR(z, 0, M) {
				if (d[z] == x && a[z] + k[z] - 1 == y) {
					FOR(v, 1, L + 1) {
						dp[x][y][v] = max(dp[x][y][v], dp[x][a[z] - 1][v - 1] + t[z]);
					}
				}
			}
		}
	}

	int ans = 0;
	FOR(i, 1, L + 1) {
		ans = max(ans, dp[4][N][i]);
	}
	cout << ans << endl;



	return 0;
}
