require 'forwardable'

class Array
    include Comparable
    def <=>(other)
        c = (self[0] <=> other[0])
        c == 0 ? (self[1] <=> other[1]) : c
    end
end

class Heap
    extend Forwardable

    def initialize
        @array = []
        @index = {}
    end

    def add(obj, key)
        @array << [obj, key]
        @index[obj] = @array.size - 1
        lift_up(@array.size - 1)
    end

    def swap(i, j)
        u = @array[i]
        v = @array[j]
        @index[u[0]], @index[v[0]] = j, i
        @array[i], @array[j] = v, u
    end

    def lift_up(i)
        return if i == 0
        j = (i - 1) / 2
        if @array[i][1] < @array[j][1]
            swap(i, j)
            lift_up(j)
        end
    end

    def del_min
        raise "heap is empty!" if empty?
        min = @array[0]
        if size > 1
            swap(0, @array.size-1)
            @array.pop
            lift_down(0)
        else
            @array.pop
        end
        @index.delete(min[0])
        min
    end

    def inc_key(obj, diff)
        i = @index[obj]
        @array[i][1] += diff
        lift_down(i)
    end

    def dec_key(obj, diff)
        i = @index[obj]
        @array[i][1] -= diff
        lift_up(i)
    end

    def update_key(obj, new_key)
        i = @index[obj]
        return unless i
        old_key = @array[i][1]
        @array[i][1] = new_key
        if new_key > old_key
            @array[i][1] = new_key
            lift_down(i)
        else
            @array[i][1] = new_key
            lift_up(i)
        end
    end

    def min_obj
        @array[0][0]
    end

    def min_key
        @array[0][1]
    end

    def lift_down(i)
        j = 2 * i + 1
        k = j + 1
        if k >= size
            return if j >= size
            if @array[i][1] > @array[j][1]
                swap(i, j)
                lift_down(j)
            end
        else
            l = (@array[j][1] < @array[k][1] ? j : k)
            if @array[i][1] > @array[l][1]
                swap(i, l)
                lift_down(l)
            end
        end
    end

    def key(obj)
        i = @index[obj]
        @array[i][1]
    end

    def_delegators :@array, :empty?, :size
end

n, r, l = gets.split.map(&:to_i)
heap = Heap.new
total_time = {}
(1..n).each do |i|
    heap.add(i, [0, i])
    total_time[i] = 0
end

events = (1..r).map { gets.split.map(&:to_i) }

t0 = 0
until events.empty?
    _, t, _ = events[0]
    top = heap.min_obj
    total_time[top] += t - t0

    while !events.empty? and events[0][1] == t
        d, t, x = events.shift
        score, i = heap.key(d)
        heap.update_key(d, [score - x, d])
    end
    t0 = t
end
top = heap.min_obj
total_time[top] += l - t0
p total_time.max_by {|i, t| t}[0]

