#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define ROOT 1

// getLeftChildIndex returns the index of the left child of index.
int getLeftChildIndex(int index)
{
  return 2*index;
}

// getRightChildIndex returns the index of the right child of index.
int getRightChildIndex(int index)
{
  return 2*index+1;
}

// getParentIndex returns the index of the parent of index.
int getParentIndex(int index)
{
  return index/2;
}

// getLeftBoundIndex returns the farthest left leaf index which index contains.
int getLeftBoundIndex(int treeLeavesLength, int index)
{
  while ( index < treeLeavesLength )
    index = getLeftChildIndex(index);
  return index-treeLeavesLength;
}

// getRightBoundIndex returns the farthest right leaf index which index contains.
int getRightBoundIndex(int treeLeavesLength, int index)
{
  while ( index < treeLeavesLength )
    index = getRightChildIndex(index);
  return index-treeLeavesLength;
}

// addToRange adds the value toadd from left to right in the tree.
void addToRange(int *tree, int treeLeavesLength, int currentIndex, int leftLeaf, int rightLeaf, int toadd)
{
  int leftBound = getLeftBoundIndex(treeLeavesLength, currentIndex),
    rightBound = getRightBoundIndex(treeLeavesLength, currentIndex);
  // if the proper node (currentIndex) has been found
  if ( leftBound == leftLeaf && rightBound == rightLeaf )
    {
      tree[currentIndex] += toadd;
      return;
    }
  // if the range lies in the left subtree
  if ( rightLeaf <= getRightBoundIndex(treeLeavesLength, getLeftChildIndex(currentIndex)) )
    {
      addToRange(tree, treeLeavesLength, getLeftChildIndex(currentIndex), leftLeaf, rightLeaf, toadd);
    }
  // if the range lies in the right subtree
  else if ( leftLeaf >= getLeftBoundIndex(treeLeavesLength, getRightChildIndex(currentIndex)) )
    {
      addToRange(tree, treeLeavesLength, getRightChildIndex(currentIndex), leftLeaf, rightLeaf, toadd);
    }
  // if the range lies in both subtrees
  else
    {
      int leftIndex = getLeftChildIndex(currentIndex),
	rightIndex = getRightChildIndex(currentIndex);
      // left piece
      addToRange(tree, treeLeavesLength, leftIndex, leftLeaf, getRightBoundIndex(treeLeavesLength, leftIndex), toadd);
      // right piece
      addToRange(tree, treeLeavesLength, rightIndex, getLeftBoundIndex(treeLeavesLength, rightIndex), rightLeaf, toadd);
    }
  return;
}

// printIndex prints the value at index in the leaves of the tree by summing along the branch from the root down.
void printIndex(int *tree, int treeLeavesLength, int leafIndex)
{
  int currentIndex = treeLeavesLength+leafIndex,
    output = tree[currentIndex];
  while ( currentIndex != ROOT )
    {
      currentIndex = getParentIndex(currentIndex);
      output += tree[currentIndex];
    }
  printf("%d\n", output);
  return;
}

int main(){
  size_t length, treeLeavesLength = 1;
  int numberOfQueries, i;
  scanf(" %lu %d", &length, &numberOfQueries);
  // find the length of the array to allocate for a tree with length leaves
  while ( treeLeavesLength < length )
    {
      treeLeavesLength <<= 1;
    }
  int *tree = (int *) malloc(sizeof(int[2*treeLeavesLength]));
  memset(tree, 0, 2*treeLeavesLength);
  // read in queries
  int query;
  for ( i = 0; i < numberOfQueries; i++ )
    {
      scanf(" %d", &query);
      // query is for addition
      if ( !query )
	{
	  int left, right, toadd;
	  scanf(" %d %d %d", &left, &right, &toadd);
	  addToRange(tree, treeLeavesLength, ROOT, left-1, right-1, toadd);
	}
      // query is for a get command
      else
	{
	  int index;
	  scanf(" %d", &index);
	  printIndex(tree, treeLeavesLength, index-1);
	}
    }
  free(tree);
  return 0;
}



Measured memory_bytes: 2376