Inzane finally found Zane with a lot of money to spare, so they together decided to establish a country of their own.

Ruling a country is not an easy job. Thieves and terrorists are always ready to ruin the country's peace. To fight back, Zane and Inzane have enacted a very effective law: from each city it must be possible to reach a police station by traveling at most d kilometers along the roads.

There are n cities in the country, numbered from 1 to n, connected only by exactly n - 1 roads. All roads are 1 kilometer long. It is initially possible to travel from a city to any other city using these roads. The country also has k police stations located in some cities. In particular, the city's structure satisfies the requirement enforced by the previously mentioned law. Also note that there can be multiple police stations in one city.

However, Zane feels like having as many as n - 1 roads is unnecessary. The country is having financial issues, so it wants to minimize the road maintenance cost by shutting down as many roads as possible.

Help Zane find the maximum number of roads that can be shut down without breaking the law. Also, help him determine such roads.

Input

The first line contains three integers n, k, and d (2 ≤ n ≤ 3·105, 1 ≤ k ≤ 3·105, 0 ≤ d ≤ n - 1) — the number of cities, the number of police stations, and the distance limitation in kilometers, respectively.

The second line contains k integers p1, p2, ..., pk (1 ≤ pi ≤ n) — each denoting the city each police station is located in.

The i-th of the following n - 1 lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the cities directly connected by the road with index i.

It is guaranteed that it is possible to travel from one city to any other city using only the roads. Also, it is possible from any city to reach a police station within d kilometers.

Output

In the first line, print one integer s that denotes the maximum number of roads that can be shut down.

In the second line, print s distinct integers, the indices of such roads, in any order.

If there are multiple answers, print any of them.

Examples
Input

Copy
6 2 4
1 6
1 2
2 3
3 4
4 5
5 6
Output

Copy
1
5
Input

Copy
6 3 2
1 5 6
1 2
1 3
1 4
1 5
5 6
Output

Copy
2
4 5
Note

In the first sample, if you shut down road 5, all cities can still reach a police station within k = 4 kilometers.

In the second sample, although this is the only largest valid set of roads that can be shut down, you can print either 4 5 or 5 4 in the second line.

将每个警察局压入queue中,然后 bfs搜索;

如果某个点的 to 已经被访问了,但该条边还没有被访问,ans++;

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 1000005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9 + 7;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-4
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;
inline ll rd() {
ll x = 0;
char c = getchar();
bool f = false;
while (!isdigit(c)) {
if (c == '-') f = true;
c = getchar();
}
while (isdigit(c)) {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return f ? -x : x;
} ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a%b);
}
int sqr(int x) { return x * x; } /*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) {
x = 1; y = 0; return a;
}
ans = exgcd(b, a%b, x, y);
ll t = x; x = y; y = t - a / b * y;
return ans;
}
*/ int n, k, d;
struct node {
int to;
int id;
node(int to,int id):to(to),id(id){}
node(){}
}edge[maxn];
queue<int>q;
int ans;
int vis[maxn];
vector<node>vc[maxn];
int fgedge[maxn]; void bfs() {
while (!q.empty()) {
int u = q.front(); q.pop();
for (int i = 0; i < vc[u].size(); i++) {
node tmp = vc[u][i];
if (fgedge[tmp.id])continue;
if (vis[tmp.to]) {
ans++;
fgedge[tmp.id] = 2;
continue;
}
vis[tmp.to] = 1; fgedge[tmp.id] = 1;
q.push(tmp.to);
}
}
} int main() {
//ios::sync_with_stdio(0);
cin >> n >> k >> d;
for (int i = 1; i <= k; i++) {
int x; rdint(x); vis[x] = 1;
q.push(x);
}
for (int i = 1; i < n; i++) {
int u, v; rdint(u); rdint(v);
vc[u].push_back(node(v, i));
vc[v].push_back(node(u, i));
}
bfs();
cout << ans << endl;
for (int i = 1; i < n; i++) {
if (fgedge[i] == 2)cout << i << ' ';
} return 0;
}

最新文章

  1. 外部函数test显示的返回内部函数add的调用
  2. 【tornado】系列项目(一)之基于领域驱动模型架构设计的京东用户管理后台
  3. Socket 学习入门
  4. Unity-Animator深入系列---状态机面板深入
  5. Good Number
  6. NET Core 中的依赖注入
  7. 第三章 CUDA设备相关
  8. axios与vue的配合使用事例,实现缓存和重复加载的控制
  9. sql中某条件不为空,可能有的小祖宗会喷了,这还用总结?emmm,我渣,我觉得有一点意思对于第二种(土味)
  10. 基于CC2530/CC2430 的光强采集系统--ADC实验
  11. 获取APP和设备相关信息
  12. test zhenai
  13. Knockout: 使用knockout validation插件进行校验, 给未通过校验的输入框添加红色边框突出显示.
  14. FastCGI中fastcgi_param 详细说明
  15. 微信Tinker的一切都在这里,包括源码(一)
  16. poj2559单调栈
  17. Ubuntu14.04下使用PPA安装php5.6,php7
  18. PC/APP/H5三端测试的相同与不同
  19. bzoj1004 [HNOI2008]Cards Burnside定理+背包
  20. Something haunts me in Python

热门文章

  1. JDBC---bai
  2. SQL 2008提供几种数据同步方式
  3. java 多线程系列基础篇(十一)之生产消费者问题
  4. javascript——对象的概念——内建对象
  5. MongoDB中的查询
  6. eclipse 报错:GC overhead limit exceeded
  7. Maven 导包后,在Maven Dependencies 里面却没有相应的包
  8. 基于IFC的大型三维城市群体——智慧城市模拟
  9. c语言输入数据
  10. Qt中显示图像的两种方法