In Chelyabinsk lives a much respected businessman Nikita with a strange nickname "Boss". Once Nikita decided to go with his friend Alex to the Summer Biathlon World Cup. Nikita, as a very important person, received a token which allows to place bets on each section no more than on one competitor.

To begin with friends learned the rules: in the race there are n sections of equal length and m participants. The participants numbered from 1 to m. About each participant the following is known:

  * li — the number of the starting section, 
  * ri — the number of the finishing section (li ≤ ri),
  * ti — the time a biathlete needs to complete an section of the path,
  * ci — the profit in roubles. If the i-th sportsman wins on one of the sections, the profit will be given to the man who had placed a bet on that sportsman.



The i-th biathlete passes the sections from li to ri inclusive. The competitor runs the whole way in (ri - li + 1)·ti time units. It takes him exactly ti time units to pass each section. In case of the athlete's victory on k sections the man who has betted on him receives k·ci roubles.

In each section the winner is determined independently as follows: if there is at least one biathlete running this in this section, then among all of them the winner is the one who has ran this section in minimum time (spent minimum time passing this section). In case of equality of times the athlete with the smaller index number wins. If there are no participants in this section, then the winner in this section in not determined. We have to say that in the summer biathlon all the participants are moving at a constant speed.

We should also add that Nikita can bet on each section and on any contestant running in this section.

Help the friends find the maximum possible profit.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 100). Then follow m lines, each containing 4 integers li, ri, ti, ci (1 ≤ li ≤ ri ≤ n, 1 ≤ ti, ci ≤ 1000).

Output

Print a single integer, the maximal profit in roubles that the friends can get. In each of n sections it is not allowed to place bets on more than one sportsman.

Examples

Input

4 4
1 4 20 5
1 3 21 10
3 3 4 30
3 4 4 20


Output

60

Input

8 4
1 5 24 10
2 4 6 15
4 6 30 50
6 7 4 20


Output

105

Note

In the first test the optimal bet is: in the 1-2 sections on biathlete 1, in section 3 on biathlete 3, in section 4 on biathlete 4. Total: profit of 5 rubles for 1 section, the profit of 5 rubles for 2 section, profit of 30 rubles for a 3 section, profit of 20 rubles for 4 section. Total profit 60 rubles.

In the second test the optimal bet is: on 1 and 5 sections on biathlete 1, in the 2-4 sections on biathlete 2, in the 6-7 sections on athlete 4. There is no winner in the 8 section. Total: profit of 10 rubles for 1 section, the profit of 15 rubles for 2,3,4 section, profit of 10 rubles for a 5 section, profit of 20 rubles for 6, 7 section. Total profit 105 rubles.
import java.io.*;
import java.math.BigInteger;
import java.util.*;
 
 
 
 public class Main {
	public static InputReader in;
    public static PrintWriter pw;
 
 
 
	public static void main(String args[]) {
		new Thread(null, new Runnable() {
            public void run() {
                try{
                    solve();
                }
                catch(Exception e){
                    e.printStackTrace();
                }
            }
        }, "1", 1 << 26).start();
    }
	static ArrayList<Integer> g[];
	static ArrayList<Integer> h[];
	static boolean visited[];
	static boolean visit[];
	static int par[];
	static int degree[];
	static int edjes=0;
	static int start=-1;
	static int end=-1;
	static int Total=0;
	static int time1[];
	static int time2[];
	static int glob=0;
	static long cnt=0;
	static boolean vis2[][];
	static int lev=1;
    static int depth[];
    static long[] sm;
    static int val[];
    static int len=0;
    static long sum1=0;
    static int pre[][];
 static HashMap<String,Integer> hm;
 //static TreeSet<Long> set;
 static boolean Not[];
 //static int pre[][];
 static int parent[];
 static HashSet<Integer> set[];
 static boolean bb=false;
 static int max[];
    public static void solve(){
		
	
		 in = new InputReader(System.in);
	  	 pw = new PrintWriter(System.out);
	     
	    int n=in.nextInt();
	    int m=in.nextInt();
	    int l[]=new int[m];
	    int r[]=new int[m];
	    int t[]=new int[m];
	    int c[]=new int[m];
	    for(int i=0;i<m;i++)
	    {
	    	l[i]=in.nextInt();
	    	r[i]=in.nextInt();
	    	t[i]=in.nextInt();
	    	c[i]=in.nextInt();
	    }
	    int ans=0;
	    for(int i=0;i<n;i++)
	    {
	    	int min=Integer.MAX_VALUE;
	    	for(int j=0;j<m;j++)
	    	{
	    		if(i+1>=l[j]&&i+1<=r[j])
	    		min=Math.min(min, t[j]);
	    	}
	    	//System.out.println(min);
	    	for(int j=0;j<m;j++)
	    	{
	    		if(i+1>=l[j]&&i+1<=r[j]&&min==t[j])
	    		{
	    			ans+=c[j];
	    			break;
	    		}
	    	}
	    }
	    System.out.println(ans);
    }
    public static void MergeSort(int a[],int l,int r)
    {
    	if(l<r)
    	{
    		int m=(l+r)/2;
    		MergeSort(a,l,m);
    		MergeSort(a,m+1,r);
    		Merge(a,l,m,r);
    	}
    }
    public static void Merge(int a[],int l,int m,int r)
    {
    	int ll = m - l + 1;
        int rr = r - m;
 
        int left[] = new int [ll];
        int right[] = new int [rr];
         for (int i=0; i<ll; ++i)
            left[i] = a[l + i];
        for (int j=0; j<rr; ++j)
            right[j] = a[m + 1+ j];
 
         int i = 0, j = 0;
          int k = l;
        while (i < ll&& j < rr)
        {
            if (left[i] <= right[j])
            {
                a[k] = left[i];
                i++;
            }
            else
            {
            	System.out.println((l+i)+" "+(m+1+j));
            	max[l+i]=Math.max(m+1+j,0);
                a[k] = right[j];
                j++;
            }
            k++;
        }
   while (i < ll)
        {
            a[k] = left[i];
            i++;
            k++;
        }
 while (j < rr)
        {
            a[k] = right[j];
            j++;
            k++;
        }
    }
    private static int getParent(int x) {
    	while(parent[(int) x]!=x){
			parent[ (int) x] = parent[(int) parent[ (int) x]];
			x = parent[ (int) x];
		}
		return (int) x;
	}
	    
 /* private static boolean check(int mid, int[] a, int[] pr,int n) {
	
	  HashMap<Integer,Integer> hm=new HashMap();
	  
	  for(int i=1;i<=(mid+1);i++)
	  {
		  for(int x:set[i]){
		if(!hm.containsKey(x))
		  hm.put(x,1);
		else
			hm.put(x,hm.get(x)+1);
		if(hm.get(x)==(mid+1))
		{
			//System.out.println(i+" "+mid);
			//ana[i]=1;i
			return true;
		}
		  }
	  }
	  int now=1;
	  int then=mid+2;
	  while(then<=n)
	  {
		  for(int x:set[now])
		  {
			  if(hm.containsKey(x))
				  hm.put(x,hm.get(x)-1);
		  }
		  for(int x:set[then])
		  {
			  if(!hm.containsKey(x))
				  hm.put(x,1);
			  else
				  hm.put(x,hm.get(x)+1);
			  if(hm.get(x)==(mid+1))
			  {
				  
				  ana[now+1]=1;
				  return true;
			  }
		  }
		  now++;
		  then++;
	  }
	  
	return false;
}
  
 */
/*  public static int bfs(int x,int y,int tx,int ty,int n,int m)
    {
    		boolean vis[][]=new boolean[101][101];
    		vis[x][y]=true;
    		int lev=0;
    		Queue<String> Q=new LinkedList();
    		String sx=x+" "+y;
    		Q.add(sx);
    		while(!Q.isEmpty())
    		{
    			int count=Q.size();
    			while(count>0)
    			{
    				String p=Q.poll();
    				int i=Integer.parseInt(p.split(" ")[0]);
    				int j=Integer.parseInt(p.split(" ")[1]);
    				vis[i][j]=true;
    				if(i==tx&&j==ty)
    				{
    					return lev;
    				}
    				if(i==tx&&(j-1)==ty)
    				{
    					return lev;
    				}
    				if(i==tx&&(j+1)==ty)
    				{
    					return lev;
    				}
    				if((i+1)==tx&&(j)==ty)
    				{
    					return lev;
    				}
    				if((i-1)==tx&&(j)==ty)
    				{
    					return lev;
    				}
    				if(i<n&&j-1>=0&&!vis[i][j-1]&&a[i][j-1]=='O')
    				{
    					vis[i][j-1]=true;
    					String s=(i)+" "+(j-1);
    					Q.add(s);
    				}
    				if(i<n&&j+1<m&&!vis[i][j+1]&&a[i][j+1]=='O')
    				{
    					vis[i][j+1]=true;
    					String s=(i)+" "+(j+1);
    					Q.add(s);
    				}
    				if(i+1<n&&j<m&&!vis[i+1][j]&&a[i+1][j]=='O')
    				{
    					vis[i+1][j]=true;
    					String s=(i+1)+" "+j;
    					Q.add(s);
    				}
    				if(i-1>=0&&j<m&&!vis[i-1][j]&&a[i-1][j]=='O')
    				{
    					vis[i-1][j]=true;
    					String s=(i-1)+" "+j;
    					Q.add(s);
    				}
    				count--;
    			}
    			lev++;
    		//	System.out.println(Q);
    		}
    		return -1;
    }*/
    public static void dfs(int curr,int parent)
    {
    	visited[curr]=true;
    	par[curr]=parent;
    	for(int x:g[curr])
    	{
    		if(!visited[x])
    		{
    		depth[x]=depth[curr]+1;
    		dfs(x,curr);	
    		}
    	}
    		
    	
    }
  /*  public static void dfs2(int curr,int parent, HashSet<Integer> fk)
    {
    	visited[curr]=true;
    	fk.add(curr);
    	//System.out.print(curr+" ");
    	cnt++;
    	for(int x:g[curr])
    	{
    		if(x!=parent)
    		{
    			dfs2(x,par[x],fk);
    		}
    	}
    }*/
    /*public static void dfs1(int curr)
    {
    	visited[curr]=true;
    	long find=sm[curr]-(long)val[curr];
    	if(set.lower(find)!=null)
    	{
    		cnt+=(size[curr]);
    		return;
    	}
    	set.add(sm[curr]);
    	for(int x:g[curr])
    	{
    		if(!visited[x])
    			dfs1(x);
    	}
    	set.remove(sm[curr]);
    }
   /* public static void dfs(int curr,int parent)
    {
    	visited[curr]=true;
    	par[curr]=parent;
    	String s=curr+" "+parent;
    	sum1+=(hm.get(s));
    	size[curr]=1;
    	for(int x:g[curr])
    	{
    		if(!visited[x])
    		{
    			dfs(x,curr);
    			size[curr]+=size[x];
    		}
    	}
    	sm[curr]=sum1;
    	String p=curr+" "+parent;
    	sum1-=(hm.get(p));
    }
	public static int len(String s)
    {
    	
    	if(s.charAt(len++)=='l')
    	{
    		return 1;
    	}
    	else{
    		return Math.max(len(s), len(s))+1;
    	}
    }
    */
    
   public static int LCA(int p,int q)
    {
    	if(depth[p]<depth[q])
		{
			int tmp=p;
			p=q;
			q=tmp;
		}
		int dist=depth[p]-depth[q];
		while(dist>0)
		{
			int raise=(int)(Math.log(dist)/Math.log(2));
			p=pre[p][raise];
			dist-=(1<<raise);
		}
		if(p==q)
		{
			return p;
		}
		else{
		
		int current=(int)(Math.log(depth[p])/Math.log(2));
		for(int j=current;j>=0;j--)
		{
			if(pre[p][j]!=0&&pre[p][j]!=pre[q][j])
			{
				p=pre[p][j];
				q=pre[q][j];
			}
		}
		}
	return par[p];
    }
    
public static void dfs(int curr,int lev,int parent)
{
     visited[curr]=true;
     depth[curr]=lev;
     par[curr]=parent;
    // set[lev].add(curr);
     for(int x:g[curr])
     {
    	 if(!visited[x])
    	 {
    		 dfs(x,lev+1,curr);
    	 }
     }
     
}
 
 
	
 
 
 
 
     
        
     
        
 
   
/*public static void dfs2(int curr,int lev)
{
	time1[curr]=glob++;
	
	depth[curr]=lev;
	visited[curr]=true;
	nodes[lev].add(time1[curr]);
	values[lev].add(a[curr]);
	for(int x:g[curr])
	{
		if(!visited[x])
		{
			dfs2(x,lev+1);
		}
	}
time2[curr]=glob++;
}
 
 
 
public static void bfs1(int curr)
{
Queue<Integer> Q=new LinkedList<Integer>();
Q.add(1);
visit[1]=true;
int lev=2;
levels[1].add(1);
while(!Q.isEmpty())
{
	int cnt=Q.size();
	while(cnt>0)
	{
		int p=Q.poll();
		visit[p]=true;
		for(int x:g[p])
		{
			if(!visit[x])
			{
				Q.add(x);
				levels[lev].add(x);
			}
		}
		cnt--;
	}
	max=Math.max(lev, max);
	lev++;
}
}
 
 
	
 	private static long fact(int len) {
	long ans=1;
	for(int i=1;i<=len;i++)
		ans*=i;
	return ans;
}
 */
 
 
	
	// SubTree Checker DFS (TO CHECK IF X IS IN A SUBTREE OF Y)
	public static void dfs3(int curr)
	{
		visited[curr]=true;
		time1[curr]=glob++;
		for(int x:g[curr])
		{
		if(!visited[x])
			dfs3(x);
		}
		time2[curr]=glob++;
	}
    
	
	
 
    /*NO OF EDJES IN WHOLE CONNECTED COMPONENTS
  
	public static void dfs1(int curr)
	{
		visited[curr]=true;
		for(int next:g[curr])
		{
			edje++;
			if(!visited[next])
				dfs1(next);
		}
	}
	/*SUM OF ALL SUBTREE NODE'S VLAUES DFS
	public static void dfs(int curr,int prev)
		{
		val[curr]=1;
			for(int x:g[curr])
			{
				if(x!=prev)
				{
		            dfs(x,curr);
		            val[curr]+=val[x];
					
			    }
			}
		}*/
	
		public static long power(long a,long b)
		{
			long result=1;
			while(b>0)
			{
				if(b%2==1)
					result*=a;
				a=a*a;
				b/=2;
			}
			return result;
		}
				public static long pow(long n,long p,long m)
	{
		 long  result = 1;
		  if(p==0)
		    return 1;
		if (p==1)
		    return n;
		while(p!=0)
		{
		    if(p%2==1)
		        result *= n;
		    if(result>=m)
		    result%=m;
		    p >>=1;
		    n*=n;
		    if(n>=m)
		    n%=m;
		}
		return result;
	}
	static class Pair implements Comparable<Pair>{
	//int x;
		char c;
		int val;
		Pair(char ver,int weight){
	     	this.c=ver;
			this.val=weight;
			//this.val=vl;
			//this.index=index;
			
		}
		@Override
		public int compareTo(Pair o) {
		return 1;
		}
				
	}
	public static long gcd(long a, long b) {
		  if (b == 0) return a;
		  return gcd(b, a%b);
		}
	static class InputReader {
 
		private InputStream stream;
		private byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;
 
		public InputReader(InputStream stream) {
			this.stream = stream;
		}
 
		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}
 
		public   int nextInt() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
 
		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
 
		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}
 
		public String readString() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}
 
		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
 
		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}
}