def filter_migration_segment_len(x, hmin=0, hmax=float('inf'), dmin=0, dmax
    =float('inf')):
    """
    Filter migration segment by home segment length and destination length.
    x: ['migration_list']
    hmin: min_home_segment_len
    hmax: max_home_segment_len
    dmin: min_des_segment_len
    dmax: max_des_segment_len
    """
    home_segment = x[0]
    des_segment = x[1]
    home_len = home_segment[1] - home_segment[0] + 1
    des_len = des_segment[1] - des_segment[0] + 1
    if hmin <= home_len <= hmax and dmin <= des_len <= dmax:
        return 1
    else:
        return 0
