///Bismillahir Rahmanir Rahim

#include<cstdio>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<sstream>
#include<stack>
#include<list>
#include<iostream>
#include<assert.h>
#include<bits/stdc++.h>

/**Define file I/O **/
#define f_input freopen("input.txt","r",stdin)
#define f_output freopen("output.txt","w",stdout)

/**Define memory set function**/
#define mem(x,y) memset(x,y,sizeof(x))
#define CLEAR(x) memset(x,0,sizeof(x))

/**Define function and object**/
#define pb push_back
#define Sort(v) sort(v.begin(),v.end())
#define RSort(v) sort(v.rbegin(),v.rend())
#define CSort(v,C) sort(v.begin(),v.end(),C)
#define all(v) (v).begin(),(v).end()
#define sqr(x) ((x)*(x))
#define find_dist(a,b) sqrt(sqr(a.x-b.x)+sqr(a.y-b.y))

/**Define constant value**/
#define ERR 1e-9
#define pi (2*acos(0))
#define PI 3.141592653589793

/**Define input**/
#define scanint(a) scanf("%d",&a)
#define scanLLD(a) scanf("%lld",&a)
#define scanstr(s) scanf("%s",s)
#define scanline(l) scanf(" %[^\n]",l)
#define scandouble(d) scanf("%lf",&d)
#define scanchar(c) scanf("%c",&c)

/**Define Bitwise operation**/
#define check(n, pos) (n & (1ll<<(pos)))
#define biton(n, pos) (n | (1ll<<(pos)))
#define bitoff(n, pos) (n & ~(1ll<<(pos)))

/**Define color**/
enum {WHITE,GREY,BLACK};

/**Sync off with stdio**/
#define __ cin.sync_with_stdio(false);\
           cin.tie();

/**Debug tools**/
#define what_is(x) cerr<<(#x)<<" is "<<x<<endl
using namespace std;

/**Typedef**/
typedef vector<int> vint;
typedef vector< vint > vint2D;
typedef vector<string> vstr;
typedef vector<char>vchar;
typedef vector< vchar >vchar2D;
typedef queue<int> Qi;
typedef queue< Qi > Qii;
typedef map<int,int> Mii;
typedef map<string,int> Msi;
typedef map<int,string> Mis;
typedef stack<int> stk;
typedef pair<int,int> pp;
typedef pair<int, pp > ppp;
typedef long long int ll;
ll inf=1e18;

/**Template & structure**/

template<class T>T gcd(T a,T b){return b == 0 ? a : gcd(b, a % b);}

template<typename T>T lcm(T a, T b) {return a / gcd(a,b) * b;}

template<typename T>T last_bit(T n) { return n & 1; }

template<class T>T big_mod(T n,T p,T m){if(p==0)return (T)1;T x=big_mod(n,p/2,m);x=(x*x)%m;if(p&1)x=(x*n)%m;return x;}

template<class T>T modInv(T a, T m){T x, y; extgcd(a, m, x, y); x %= m; while (x < 0){x += m;} return x;}

template<class T> T extgcd(T a,T b,T& x,T& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}

template<class T>T multiplication(T n,T p,T m){if(p==0)return (T)0;T x=multiplication(n,p/2,m);x=(x+x)%m;if(p&1)x=(x+n)%m;return x;}

template<class T>T my_pow(T n,T p){if(p==0)return 1;T x=my_pow(n,p/2);x=(x*x);if(p&1)x=(x*n);return x;} ///n to the power p

template <class T> double getdist(T a, T b){return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));}/// distance between a & b

template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}/// extract words or numbers from a line

template <class T> string tostring(T n) {stringstream ss; ss << n; return ss.str();}/// convert a number to string

template<class T> T Mod(T n,T m) {return (n%m+m)%m;} ///For Positive Negative No.

template<class T> T MIN3(T a,T b,T c) {return min(a,min(b,c));} /// minimum of 3 number

template<class T> T MAX3(T a,T b,T c) {return max(a,max(b,c));} ///maximum of 3 number

template <class T> void print_vector(T &v){int sz=v.size();if(sz)cout<<v[0];for(int i = 1; i < sz; i++)cout << ' '<<v[i];cout<<"\n";}/// prints all elements in a vector

bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}

bool isConsonant(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}

template <class R> R Josephus(R n,R k){R ans=1;for(R i=2;i<=n;i++)ans=(ans+k-1)%i+1;return ans;}

template <class R> R toitent_Phi2(R a){R result = a;for(R i=2;i*i<=a;i++){if(a%i==0) result=result-result/i;while(a%i==0) a=a/i;}if(a>1) result=result-result/a;return result;}

template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}

//namespace debug{
//    int sum(){return 0;}
//    template<typename T,typename... Args> T sum(T a,Args... args) {return a+sum(args...);}
//    void print(){cout<<"\n";return;}template<typename T, typename... Args>void print(T a,Args... args){cout<<a<<" ";print(args...);}
//}

/**Direction**/
///int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1}; ///8 Direction
///int dx[4] = {1, 0, -1, 0};int dy[4] = {0, 1, 0, -1}; ///4 Direction
///int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};///Knight Direction
///int dx[]={-1,-1,+0,+1,+1,+0};int dy[]={-1,+1,+2,+1,-1,-2}; ///Hexagonal Direction

/******************************End******************************/

#define mxn 300009
vector<ll>G[mxn],E[mxn];
ll a[mxn];
vector<ll>city;
ll vis[mxn];
ll lvl[mxn];
ll par[mxn];
set<ll>ans;
queue<ll>Q[mxn];

void bfs(ll x,ll mx){

        ll u=Q[x].front();
        Q[x].pop();

        if(lvl[u]==mx) return;

        ll sz=G[u].size();
        for(ll i=0;i<sz;i++){
            ll v=G[u][i];

            if(par[u]==v) continue;

            if(a[v]==1){
                ans.insert(E[u][i]);
                //vis[v]=1;
                continue;
            }

            if(vis[v]==1){
                ans.insert(E[u][i]);
                continue;
            }

            if(vis[v]==0){
                vis[v]=1;
                par[v]=u;
                lvl[v]=lvl[u]+1;
                Q[x].push(v);
            }
        }
}

int main()
{
    __;

    ll n,m,q;
    ll i,j,k;

    cin>>n>>m>>q;
    for(i=1;i<=m;i++){
        ll d;
        cin>>d;
        if(a[d]==0){
            Q[d].push(d);
            city.push_back(d);
        }
        a[d]=1;
        par[d]=d;
        lvl[d]=0;

    }

    k=1;
    for(i=1;i<n;i++){
        ll u,v;
        cin>>u>>v;
        G[u].push_back(v);
        G[v].push_back(u);
        E[u].push_back(k);
        E[v].push_back(k);
        k++;
    }

    ll city_num=city.size();

    while(1){
    ll f=0;
    for(i=0;i<city_num;i++){
        ll c=city[i];
        if(Q[c].size()>0){
            f=1;
            bfs(c,q);
        }
    }

    if(f==0) break;
    }

    cout<<ans.size()<<"\n";
    for(auto it=ans.begin();it!=ans.end();it++) cout<<*it<<" ";
    cout<<"\n";

    return 0;
}


///Bismillahir Rahmanir Rahim

#include<cstdio>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<sstream>
#include<stack>
#include<list>
#include<iostream>
#include<assert.h>
#include<bits/stdc++.h>

/**Define file I/O **/
#define f_input freopen("input.txt","r",stdin)
#define f_output freopen("output.txt","w",stdout)

/**Define memory set function**/
#define mem(x,y) memset(x,y,sizeof(x))
#define CLEAR(x) memset(x,0,sizeof(x))

/**Define function and object**/
#define pb push_back
#define Sort(v) sort(v.begin(),v.end())
#define RSort(v) sort(v.rbegin(),v.rend())
#define CSort(v,C) sort(v.begin(),v.end(),C)
#define all(v) (v).begin(),(v).end()
#define sqr(x) ((x)*(x))
#define find_dist(a,b) sqrt(sqr(a.x-b.x)+sqr(a.y-b.y))

/**Define constant value**/
#define ERR 1e-9
#define pi (2*acos(0))
#define PI 3.141592653589793

/**Define input**/
#define scanint(a) scanf("%d",&a)
#define scanLLD(a) scanf("%lld",&a)
#define scanstr(s) scanf("%s",s)
#define scanline(l) scanf(" %[^\n]",l)
#define scandouble(d) scanf("%lf",&d)
#define scanchar(c) scanf("%c",&c)

/**Define Bitwise operation**/
#define check(n, pos) (n & (1ll<<(pos)))
#define biton(n, pos) (n | (1ll<<(pos)))
#define bitoff(n, pos) (n & ~(1ll<<(pos)))

/**Define color**/
enum {WHITE,GREY,BLACK};

/**Sync off with stdio**/
#define __ cin.sync_with_stdio(false);\
           cin.tie();

/**Debug tools**/
#define what_is(x) cerr<<(#x)<<" is "<<x<<endl
using namespace std;

/**Typedef**/
typedef vector<int> vint;
typedef vector< vint > vint2D;
typedef vector<string> vstr;
typedef vector<char>vchar;
typedef vector< vchar >vchar2D;
typedef queue<int> Qi;
typedef queue< Qi > Qii;
typedef map<int,int> Mii;
typedef map<string,int> Msi;
typedef map<int,string> Mis;
typedef stack<int> stk;
typedef pair<int,int> pp;
typedef pair<int, pp > ppp;
typedef long long int ll;
ll inf=1e18;

/**Template & structure**/

template<class T>T gcd(T a,T b){return b == 0 ? a : gcd(b, a % b);}

template<typename T>T lcm(T a, T b) {return a / gcd(a,b) * b;}

template<typename T>T last_bit(T n) { return n & 1; }

template<class T>T big_mod(T n,T p,T m){if(p==0)return (T)1;T x=big_mod(n,p/2,m);x=(x*x)%m;if(p&1)x=(x*n)%m;return x;}

template<class T>T modInv(T a, T m){T x, y; extgcd(a, m, x, y); x %= m; while (x < 0){x += m;} return x;}

template<class T> T extgcd(T a,T b,T& x,T& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}

template<class T>T multiplication(T n,T p,T m){if(p==0)return (T)0;T x=multiplication(n,p/2,m);x=(x+x)%m;if(p&1)x=(x+n)%m;return x;}

template<class T>T my_pow(T n,T p){if(p==0)return 1;T x=my_pow(n,p/2);x=(x*x);if(p&1)x=(x*n);return x;} ///n to the power p

template <class T> double getdist(T a, T b){return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));}/// distance between a & b

template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}/// extract words or numbers from a line

template <class T> string tostring(T n) {stringstream ss; ss << n; return ss.str();}/// convert a number to string

template<class T> T Mod(T n,T m) {return (n%m+m)%m;} ///For Positive Negative No.

template<class T> T MIN3(T a,T b,T c) {return min(a,min(b,c));} /// minimum of 3 number

template<class T> T MAX3(T a,T b,T c) {return max(a,max(b,c));} ///maximum of 3 number

template <class T> void print_vector(T &v){int sz=v.size();if(sz)cout<<v[0];for(int i = 1; i < sz; i++)cout << ' '<<v[i];cout<<"\n";}/// prints all elements in a vector

bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}

bool isConsonant(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}

template <class R> R Josephus(R n,R k){R ans=1;for(R i=2;i<=n;i++)ans=(ans+k-1)%i+1;return ans;}

template <class R> R toitent_Phi2(R a){R result = a;for(R i=2;i*i<=a;i++){if(a%i==0) result=result-result/i;while(a%i==0) a=a/i;}if(a>1) result=result-result/a;return result;}

template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}

//namespace debug{
//    int sum(){return 0;}
//    template<typename T,typename... Args> T sum(T a,Args... args) {return a+sum(args...);}
//    void print(){cout<<"\n";return;}template<typename T, typename... Args>void print(T a,Args... args){cout<<a<<" ";print(args...);}
//}

/**Direction**/
///int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1}; ///8 Direction
///int dx[4] = {1, 0, -1, 0};int dy[4] = {0, 1, 0, -1}; ///4 Direction
///int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};///Knight Direction
///int dx[]={-1,-1,+0,+1,+1,+0};int dy[]={-1,+1,+2,+1,-1,-2}; ///Hexagonal Direction

/******************************End******************************/

#define mxn 300009
vector<ll>G[mxn],E[mxn];
ll a[mxn];
vector<ll>city;
ll vis[mxn];
ll lvl[mxn];
ll par[mxn];
set<ll>ans;
queue<ll>Q[mxn];

void bfs(ll x,ll mx){

        ll u=Q[x].front();
        Q[x].pop();

        if(lvl[u]==mx) return;

        ll sz=G[u].size();
        for(ll i=0;i<sz;i++){
            ll v=G[u][i];

            if(par[u]==v) continue;

            if(a[v]==1){
                ans.insert(E[u][i]);
                //vis[v]=1;
                continue;
            }

            if(vis[v]==1){
                ans.insert(E[u][i]);
                continue;
            }

            if(vis[v]==0){
                vis[v]=1;
                par[v]=u;
                lvl[v]=lvl[u]+1;
                //if(lvl[v]<mx)
                Q[x].push(v);
            }
        }
}

int main()
{
    __;

    ll n,m,q;
    ll i,j,k;

    cin>>n>>m>>q;
    for(i=1;i<=m;i++){
        ll d;
        cin>>d;
        if(a[d]==0){
            Q[d].push(d);
            city.push_back(d);
        }
        a[d]=1;
        par[d]=d;
        lvl[d]=0;

    }

    k=1;
    for(i=1;i<n;i++){
        ll u,v;
        cin>>u>>v;
        G[u].push_back(v);
        G[v].push_back(u);
        E[u].push_back(k);
        E[v].push_back(k);
        k++;
    }

    ll city_num=city.size();

    for(i=0;i<city_num;i++){
        ll u=city[i];
        for(j=0;j<G[u].size();j++){
            ll v=G[u][j];
            if(a[u]==1 && a[v]==1){
                ans.insert(E[u][j]);
            }
        }
    }

    while(1){
    ll f=0;
    for(i=0;i<city_num;i++){
        ll c=city[i];
        if(Q[c].size()>0){
            f=1;
            bfs(c,q);
        }
    }

    if(f==0) break;
    }

    cout<<ans.size()<<"\n";
    for(auto it=ans.begin();it!=ans.end();it++) cout<<*it<<" ";
    cout<<"\n";

    return 0;
}


///Bismillahir Rahmanir Rahim

#include<cstdio>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<sstream>
#include<stack>
#include<list>
#include<iostream>
#include<assert.h>
#include<bits/stdc++.h>

/**Define file I/O **/
#define f_input freopen("input.txt","r",stdin)
#define f_output freopen("output.txt","w",stdout)

/**Define memory set function**/
#define mem(x,y) memset(x,y,sizeof(x))
#define CLEAR(x) memset(x,0,sizeof(x))

/**Define function and object**/
#define pb push_back
#define Sort(v) sort(v.begin(),v.end())
#define RSort(v) sort(v.rbegin(),v.rend())
#define CSort(v,C) sort(v.begin(),v.end(),C)
#define all(v) (v).begin(),(v).end()
#define sqr(x) ((x)*(x))
#define find_dist(a,b) sqrt(sqr(a.x-b.x)+sqr(a.y-b.y))

/**Define constant value**/
#define ERR 1e-9
#define pi (2*acos(0))
#define PI 3.141592653589793

/**Define input**/
#define scanint(a) scanf("%d",&a)
#define scanLLD(a) scanf("%lld",&a)
#define scanstr(s) scanf("%s",s)
#define scanline(l) scanf(" %[^\n]",l)
#define scandouble(d) scanf("%lf",&d)
#define scanchar(c) scanf("%c",&c)

/**Define Bitwise operation**/
#define check(n, pos) (n & (1ll<<(pos)))
#define biton(n, pos) (n | (1ll<<(pos)))
#define bitoff(n, pos) (n & ~(1ll<<(pos)))

/**Define color**/
enum {WHITE,GREY,BLACK};

/**Sync off with stdio**/
#define __ cin.sync_with_stdio(false);\
           cin.tie();

/**Debug tools**/
#define what_is(x) cerr<<(#x)<<" is "<<x<<endl
using namespace std;

/**Typedef**/
typedef vector<int> vint;
typedef vector< vint > vint2D;
typedef vector<string> vstr;
typedef vector<char>vchar;
typedef vector< vchar >vchar2D;
typedef queue<int> Qi;
typedef queue< Qi > Qii;
typedef map<int,int> Mii;
typedef map<string,int> Msi;
typedef map<int,string> Mis;
typedef stack<int> stk;
typedef pair<int,int> pp;
typedef pair<int, pp > ppp;
typedef long long int ll;
ll inf=1e18;

/**Template & structure**/

template<class T>T gcd(T a,T b){return b == 0 ? a : gcd(b, a % b);}

template<typename T>T lcm(T a, T b) {return a / gcd(a,b) * b;}

template<typename T>T last_bit(T n) { return n & 1; }

template<class T>T big_mod(T n,T p,T m){if(p==0)return (T)1;T x=big_mod(n,p/2,m);x=(x*x)%m;if(p&1)x=(x*n)%m;return x;}

template<class T>T modInv(T a, T m){T x, y; extgcd(a, m, x, y); x %= m; while (x < 0){x += m;} return x;}

template<class T> T extgcd(T a,T b,T& x,T& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}

template<class T>T multiplication(T n,T p,T m){if(p==0)return (T)0;T x=multiplication(n,p/2,m);x=(x+x)%m;if(p&1)x=(x+n)%m;return x;}

template<class T>T my_pow(T n,T p){if(p==0)return 1;T x=my_pow(n,p/2);x=(x*x);if(p&1)x=(x*n);return x;} ///n to the power p

template <class T> double getdist(T a, T b){return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));}/// distance between a & b

template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}/// extract words or numbers from a line

template <class T> string tostring(T n) {stringstream ss; ss << n; return ss.str();}/// convert a number to string

template<class T> T Mod(T n,T m) {return (n%m+m)%m;} ///For Positive Negative No.

template<class T> T MIN3(T a,T b,T c) {return min(a,min(b,c));} /// minimum of 3 number

template<class T> T MAX3(T a,T b,T c) {return max(a,max(b,c));} ///maximum of 3 number

template <class T> void print_vector(T &v){int sz=v.size();if(sz)cout<<v[0];for(int i = 1; i < sz; i++)cout << ' '<<v[i];cout<<"\n";}/// prints all elements in a vector

bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}

bool isConsonant(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}

template <class R> R Josephus(R n,R k){R ans=1;for(R i=2;i<=n;i++)ans=(ans+k-1)%i+1;return ans;}

template <class R> R toitent_Phi2(R a){R result = a;for(R i=2;i*i<=a;i++){if(a%i==0) result=result-result/i;while(a%i==0) a=a/i;}if(a>1) result=result-result/a;return result;}

template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}

//namespace debug{
//    int sum(){return 0;}
//    template<typename T,typename... Args> T sum(T a,Args... args) {return a+sum(args...);}
//    void print(){cout<<"\n";return;}template<typename T, typename... Args>void print(T a,Args... args){cout<<a<<" ";print(args...);}
//}

/**Direction**/
///int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1}; ///8 Direction
///int dx[4] = {1, 0, -1, 0};int dy[4] = {0, 1, 0, -1}; ///4 Direction
///int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};///Knight Direction
///int dx[]={-1,-1,+0,+1,+1,+0};int dy[]={-1,+1,+2,+1,-1,-2}; ///Hexagonal Direction

/******************************End******************************/

#define mxn 300009
vector<ll>G[mxn],E[mxn];
ll a[mxn];
ll city[mxn];
ll vis[mxn];
ll lvl[mxn];
ll par[mxn];
set<ll>ans;

void bfs(ll src,ll mx,ll t){
    vis[src]=1;
    queue<ll>Q;
    Q.push(src);
    lvl[src]=0;

    while(!Q.empty()){
        ll u=Q.front();
        Q.pop();

        if(lvl[u]==mx) return;

        ll sz=G[u].size();
        for(ll i=0;i<sz;i++){
            ll v=G[u][i];

            if(par[u]==v) continue;

            if(a[v]==1){
                ans.insert(E[u][i]);
                vis[v]=1;
                continue;
            }

            if(vis[v]==1){
                ans.insert(E[u][i]);
                continue;
            }

            if(vis[v]==0){
                vis[v]=1;
                par[v]=u;
                lvl[v]=lvl[u]+1;
                Q.push(v);
            }

        }
    }
}

int main()
{
    __;

    ll n,m,q;
    ll i,j,k;

    cin>>n>>m>>q;
    for(i=1;i<=m;i++){
        ll d;
        cin>>d;
        a[d]=1;
        city[i]=d;
        par[d]=d;
    }

    k=1;
    for(i=1;i<n;i++){
        ll u,v;
        cin>>u>>v;
        G[u].push_back(v);
        G[v].push_back(u);
        E[u].push_back(k);
        E[v].push_back(k);
        k++;
    }

    for(i=1;i<=m;i++){
        ll c=city[i];
        if(vis[c]==0){
            bfs(c,q,i);
        }
    }

    cout<<ans.size()<<"\n";
    for(auto it=ans.begin();it!=ans.end();it++) cout<<*it<<" ";
    cout<<"\n";

    return 0;
}


///Bismillahir Rahmanir Rahim

#include<cstdio>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<sstream>
#include<stack>
#include<list>
#include<iostream>
#include<assert.h>
#include<bits/stdc++.h>

/**Define file I/O **/
#define f_input freopen("input.txt","r",stdin)
#define f_output freopen("output.txt","w",stdout)

/**Define memory set function**/
#define mem(x,y) memset(x,y,sizeof(x))
#define CLEAR(x) memset(x,0,sizeof(x))

/**Define function and object**/
#define pb push_back
#define Sort(v) sort(v.begin(),v.end())
#define RSort(v) sort(v.rbegin(),v.rend())
#define CSort(v,C) sort(v.begin(),v.end(),C)
#define all(v) (v).begin(),(v).end()
#define sqr(x) ((x)*(x))
#define find_dist(a,b) sqrt(sqr(a.x-b.x)+sqr(a.y-b.y))

/**Define constant value**/
#define ERR 1e-9
#define pi (2*acos(0))
#define PI 3.141592653589793

/**Define input**/
#define scanint(a) scanf("%d",&a)
#define scanLLD(a) scanf("%lld",&a)
#define scanstr(s) scanf("%s",s)
#define scanline(l) scanf(" %[^\n]",l)
#define scandouble(d) scanf("%lf",&d)
#define scanchar(c) scanf("%c",&c)

/**Define Bitwise operation**/
#define check(n, pos) (n & (1ll<<(pos)))
#define biton(n, pos) (n | (1ll<<(pos)))
#define bitoff(n, pos) (n & ~(1ll<<(pos)))

/**Define color**/
enum {WHITE,GREY,BLACK};

/**Sync off with stdio**/
#define __ cin.sync_with_stdio(false);\
           cin.tie();

/**Debug tools**/
#define what_is(x) cerr<<(#x)<<" is "<<x<<endl
using namespace std;

/**Typedef**/
typedef vector<int> vint;
typedef vector< vint > vint2D;
typedef vector<string> vstr;
typedef vector<char>vchar;
typedef vector< vchar >vchar2D;
typedef queue<int> Qi;
typedef queue< Qi > Qii;
typedef map<int,int> Mii;
typedef map<string,int> Msi;
typedef map<int,string> Mis;
typedef stack<int> stk;
typedef pair<int,int> pp;
typedef pair<int, pp > ppp;
typedef long long int ll;
ll inf=1e18;

/**Template & structure**/

template<class T>T gcd(T a,T b){return b == 0 ? a : gcd(b, a % b);}

template<typename T>T lcm(T a, T b) {return a / gcd(a,b) * b;}

template<typename T>T last_bit(T n) { return n & 1; }

template<class T>T big_mod(T n,T p,T m){if(p==0)return (T)1;T x=big_mod(n,p/2,m);x=(x*x)%m;if(p&1)x=(x*n)%m;return x;}

template<class T>T modInv(T a, T m){T x, y; extgcd(a, m, x, y); x %= m; while (x < 0){x += m;} return x;}

template<class T> T extgcd(T a,T b,T& x,T& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}

template<class T>T multiplication(T n,T p,T m){if(p==0)return (T)0;T x=multiplication(n,p/2,m);x=(x+x)%m;if(p&1)x=(x+n)%m;return x;}

template<class T>T my_pow(T n,T p){if(p==0)return 1;T x=my_pow(n,p/2);x=(x*x);if(p&1)x=(x*n);return x;} ///n to the power p

template <class T> double getdist(T a, T b){return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));}/// distance between a & b

template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}/// extract words or numbers from a line

template <class T> string tostring(T n) {stringstream ss; ss << n; return ss.str();}/// convert a number to string

template<class T> T Mod(T n,T m) {return (n%m+m)%m;} ///For Positive Negative No.

template<class T> T MIN3(T a,T b,T c) {return min(a,min(b,c));} /// minimum of 3 number

template<class T> T MAX3(T a,T b,T c) {return max(a,max(b,c));} ///maximum of 3 number

template <class T> void print_vector(T &v){int sz=v.size();if(sz)cout<<v[0];for(int i = 1; i < sz; i++)cout << ' '<<v[i];cout<<"\n";}/// prints all elements in a vector

bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}

bool isConsonant(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}

template <class R> R Josephus(R n,R k){R ans=1;for(R i=2;i<=n;i++)ans=(ans+k-1)%i+1;return ans;}

template <class R> R toitent_Phi2(R a){R result = a;for(R i=2;i*i<=a;i++){if(a%i==0) result=result-result/i;while(a%i==0) a=a/i;}if(a>1) result=result-result/a;return result;}

template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}

//namespace debug{
//    int sum(){return 0;}
//    template<typename T,typename... Args> T sum(T a,Args... args) {return a+sum(args...);}
//    void print(){cout<<"\n";return;}template<typename T, typename... Args>void print(T a,Args... args){cout<<a<<" ";print(args...);}
//}

/**Direction**/
///int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1}; ///8 Direction
///int dx[4] = {1, 0, -1, 0};int dy[4] = {0, 1, 0, -1}; ///4 Direction
///int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};///Knight Direction
///int dx[]={-1,-1,+0,+1,+1,+0};int dy[]={-1,+1,+2,+1,-1,-2}; ///Hexagonal Direction

/******************************End******************************/

#define mxn 300009
vector<ll>G[mxn],E[mxn];
ll a[mxn];
vector<ll>city;
ll vis[mxn];
ll lvl[mxn];
ll par[mxn];
set<ll>ans;
queue<ll>Q;

void bfs(ll mx){
    while(!Q.empty()){
        ll u=Q.front();
        Q.pop();

        if(lvl[u]==mx) return;

        ll sz=G[u].size();
        for(ll i=0;i<sz;i++){
            ll v=G[u][i];

            if(par[u]==v) continue;

            if(a[v]==1){
                ans.insert(E[u][i]);
                //vis[v]=1;
                continue;
            }

            if(vis[v]==1){
                ans.insert(E[u][i]);
                continue;
            }

            if(vis[v]==0){
                vis[v]=1;
                par[v]=u;
                lvl[v]=lvl[u]+1;
                //if(lvl[v]<mx)
                Q.push(v);
            }
        }
    }
}

int main()
{
    __;

    ll n,m,q;
    ll i,j,k;

    cin>>n>>m>>q;
    for(i=1;i<=m;i++){
        ll d;
        cin>>d;
        if(a[d]==0){
            Q.push(d);
            city.push_back(d);
        }
        a[d]=1;
        par[d]=d;
        lvl[d]=0;

    }

    k=1;
    for(i=1;i<n;i++){
        ll u,v;
        cin>>u>>v;
        G[u].push_back(v);
        G[v].push_back(u);
        E[u].push_back(k);
        E[v].push_back(k);
        k++;
    }

    ll city_num=city.size();

    for(i=0;i<city_num;i++){
        ll u=city[i];
        for(j=0;j<G[u].size();j++){
            ll v=G[u][j];
            if(a[u]==1 && a[v]==1){
                ans.insert(E[u][j]);
            }
        }
    }

    bfs(q);

    cout<<ans.size()<<"\n";
    for(auto it=ans.begin();it!=ans.end();it++) cout<<*it<<" ";
    cout<<"\n";

    return 0;
}


///Bismillahir Rahmanir Rahim

#include<cstdio>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<sstream>
#include<stack>
#include<list>
#include<iostream>
#include<assert.h>
#include<bits/stdc++.h>

/**Define file I/O **/
#define f_input freopen("input.txt","r",stdin)
#define f_output freopen("output.txt","w",stdout)

/**Define memory set function**/
#define mem(x,y) memset(x,y,sizeof(x))
#define CLEAR(x) memset(x,0,sizeof(x))

/**Define function and object**/
#define pb push_back
#define Sort(v) sort(v.begin(),v.end())
#define RSort(v) sort(v.rbegin(),v.rend())
#define CSort(v,C) sort(v.begin(),v.end(),C)
#define all(v) (v).begin(),(v).end()
#define sqr(x) ((x)*(x))
#define find_dist(a,b) sqrt(sqr(a.x-b.x)+sqr(a.y-b.y))

/**Define constant value**/
#define ERR 1e-9
#define pi (2*acos(0))
#define PI 3.141592653589793

/**Define input**/
#define scanint(a) scanf("%d",&a)
#define scanLLD(a) scanf("%lld",&a)
#define scanstr(s) scanf("%s",s)
#define scanline(l) scanf(" %[^\n]",l)
#define scandouble(d) scanf("%lf",&d)
#define scanchar(c) scanf("%c",&c)

/**Define Bitwise operation**/
#define check(n, pos) (n & (1ll<<(pos)))
#define biton(n, pos) (n | (1ll<<(pos)))
#define bitoff(n, pos) (n & ~(1ll<<(pos)))

/**Define color**/
enum {WHITE,GREY,BLACK};

/**Sync off with stdio**/
#define __ cin.sync_with_stdio(false);\
           cin.tie();

/**Debug tools**/
#define what_is(x) cerr<<(#x)<<" is "<<x<<endl
using namespace std;

/**Typedef**/
typedef vector<int> vint;
typedef vector< vint > vint2D;
typedef vector<string> vstr;
typedef vector<char>vchar;
typedef vector< vchar >vchar2D;
typedef queue<int> Qi;
typedef queue< Qi > Qii;
typedef map<int,int> Mii;
typedef map<string,int> Msi;
typedef map<int,string> Mis;
typedef stack<int> stk;
typedef pair<int,int> pp;
typedef pair<int, pp > ppp;
typedef long long int ll;
ll inf=1e18;

/**Template & structure**/

template<class T>T gcd(T a,T b){return b == 0 ? a : gcd(b, a % b);}

template<typename T>T lcm(T a, T b) {return a / gcd(a,b) * b;}

template<typename T>T last_bit(T n) { return n & 1; }

template<class T>T big_mod(T n,T p,T m){if(p==0)return (T)1;T x=big_mod(n,p/2,m);x=(x*x)%m;if(p&1)x=(x*n)%m;return x;}

template<class T>T modInv(T a, T m){T x, y; extgcd(a, m, x, y); x %= m; while (x < 0){x += m;} return x;}

template<class T> T extgcd(T a,T b,T& x,T& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}

template<class T>T multiplication(T n,T p,T m){if(p==0)return (T)0;T x=multiplication(n,p/2,m);x=(x+x)%m;if(p&1)x=(x+n)%m;return x;}

template<class T>T my_pow(T n,T p){if(p==0)return 1;T x=my_pow(n,p/2);x=(x*x);if(p&1)x=(x*n);return x;} ///n to the power p

template <class T> double getdist(T a, T b){return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));}/// distance between a & b

template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}/// extract words or numbers from a line

template <class T> string tostring(T n) {stringstream ss; ss << n; return ss.str();}/// convert a number to string

template<class T> T Mod(T n,T m) {return (n%m+m)%m;} ///For Positive Negative No.

template<class T> T MIN3(T a,T b,T c) {return min(a,min(b,c));} /// minimum of 3 number

template<class T> T MAX3(T a,T b,T c) {return max(a,max(b,c));} ///maximum of 3 number

template <class T> void print_vector(T &v){int sz=v.size();if(sz)cout<<v[0];for(int i = 1; i < sz; i++)cout << ' '<<v[i];cout<<"\n";}/// prints all elements in a vector

bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}

bool isConsonant(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}

template <class R> R Josephus(R n,R k){R ans=1;for(R i=2;i<=n;i++)ans=(ans+k-1)%i+1;return ans;}

template <class R> R toitent_Phi2(R a){R result = a;for(R i=2;i*i<=a;i++){if(a%i==0) result=result-result/i;while(a%i==0) a=a/i;}if(a>1) result=result-result/a;return result;}

template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}

//namespace debug{
//    int sum(){return 0;}
//    template<typename T,typename... Args> T sum(T a,Args... args) {return a+sum(args...);}
//    void print(){cout<<"\n";return;}template<typename T, typename... Args>void print(T a,Args... args){cout<<a<<" ";print(args...);}
//}

/**Direction**/
///int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1}; ///8 Direction
///int dx[4] = {1, 0, -1, 0};int dy[4] = {0, 1, 0, -1}; ///4 Direction
///int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};///Knight Direction
///int dx[]={-1,-1,+0,+1,+1,+0};int dy[]={-1,+1,+2,+1,-1,-2}; ///Hexagonal Direction

/******************************End******************************/

#define mxn 300009
vector<ll>G[mxn],E[mxn];
ll a[mxn];
vector<ll>city;
ll vis[mxn];
ll lvl[mxn];
ll par[mxn];
set<ll>ans;
queue<ll>Q;

void bfs(ll mx){
    while(!Q.empty()){
        ll u=Q.front();
        Q.pop();

        //if(lvl[u]==mx) return;

        ll sz=G[u].size();
        for(ll i=0;i<sz;i++){
            ll v=G[u][i];

            if(par[u]==v) continue;

            if(a[v]==1){
                ans.insert(E[u][i]);
                //vis[v]=1;
                continue;
            }

            if(vis[v]==1){
                ans.insert(E[u][i]);
                continue;
            }

            if(vis[v]==0){
                vis[v]=1;
                par[v]=u;
                lvl[v]=lvl[u]+1;
                //if(lvl[v]<mx)
                Q.push(v);
            }
        }
    }
}

int main()
{
    __;

    ll n,m,q;
    ll i,j,k;

    cin>>n>>m>>q;
    for(i=1;i<=m;i++){
        ll d;
        cin>>d;
        if(a[d]==0){
            Q.push(d);
            city.push_back(d);
        }
        a[d]=1;
        par[d]=d;
        lvl[d]=0;

    }

    k=1;
    for(i=1;i<n;i++){
        ll u,v;
        cin>>u>>v;
        G[u].push_back(v);
        G[v].push_back(u);
        E[u].push_back(k);
        E[v].push_back(k);
        k++;
    }

    ll city_num=city.size();

    for(i=0;i<city_num;i++){
        ll u=city[i];
        for(j=0;j<G[u].size();j++){
            ll v=G[u][j];
            if(a[u]==1 && a[v]==1){
                ans.insert(E[u][j]);
            }
        }
    }

    bfs(q);

    cout<<ans.size()<<"\n";
    for(auto it=ans.begin();it!=ans.end();it++) cout<<*it<<" ";
    cout<<"\n";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n,k,d,a[300005],u,v,res[300005],t;
vector<int>edges[300005],id[300005];
bool bl[300005],cl[300005];

void dfs(int p, int ed, int dist)
{
   // printf("%d %d %d\n",p,ed,dist);
   if(bl[p]==true) return ;
   cl[ed]=true;
   bl[p]=true;
    if((a[p]==1 && ed>0))
    {
       // cout<<ed;
        res[++t]=ed;
        dist=d;
    }
    else if(dist<0)
    {
        res[++t]=ed; return ;
    }
    for(int i=0;i<(int)edges[p].size();i++)
    {
        int v=edges[p][i];
        int c=id[p][i];
        if(cl[c]==false && bl[v]==false)
        {
            dfs(v,c,dist-1);
        }
    }
    return ;
}
int main()
{
    scanf("%d %d %d",&n,&k,&d);
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&a[0]);
        a[a[0]]=1;
    }
    for(int i=1;i<=n-1;i++)
    {
       scanf("%d %d",&u,&v);
        edges[u].push_back(v);
        edges[v].push_back(u);
        id[u].push_back(i);
        id[v].push_back(i);
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]==1 && bl[i]==false)
        {
           dfs(i,0,d);
          // break;
        }
    }
    cout<<t<<endl;
    for(int i=1;i<=t;i++)
    {
        if(i>1) cout<<" ";
        printf("%d",res[i]);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n,k,d,a[300005],u,v,res[300005],t;
vector<int>edges[300005],id[300005];
bool bl[300005],cl[300005];

void dfs(int p, int ed, int dist)
{
   // printf("%d %d %d\n",p,ed,dist);
    if(cl[ed]==true) return;
    cl[ed]=true;

    if((a[p]==1 && d!=dist) || dist<0)
    {
       // cout<<ed;
        res[++t]=ed;
        return;
    }

    for(int i=0;i<(int)edges[p].size();i++)
    {
        int v=edges[p][i];
        int c=id[p][i];
        if(cl[c]==false)
        {
            dfs(v,c,dist-1);
        }
    }
    return ;
}
int main()
{
    scanf("%d %d %d",&n,&k,&d);
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&a[0]);
        a[a[0]]=1;
    }
    for(int i=1;i<=n-1;i++)
    {
       scanf("%d %d",&u,&v);
        edges[u].push_back(v);
        edges[v].push_back(u);
        id[u].push_back(i);
        id[v].push_back(i);
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]==1)
        {
           dfs(i,0,d);
           cl[0]=false;
        }
    }
    cout<<t<<endl;
    for(int i=1;i<=t;i++)
    {
        if(i>1) cout<<" ";
        printf("%d",res[i]);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n,k,d,a[300005],u,v,res[300005],t,dist[300005],par[300005];
vector<int>edges[300005],id[300005];
bool bl[300005];

struct data
{
    int ct,cost;
    bool operator<(const data& p)
    const
    {
        if(cost==p.cost) return ct>p.ct;
        return cost<p.cost;
        }
};

void bfs(int p)
{
    priority_queue<data>q;
    data u,v;
    int ed;
    u.ct=p;
    u.cost=d+1;
    q.push(u);
    while(!q.empty())
    {
        u=q.top();

        q.pop();
        if(dist[u.ct]==1) continue;

        for(int i=0;i<(int)edges[u.ct].size();i++)
        {
            v.ct=edges[u.ct][i];
            ed=id[u.ct][i];
            if(dist[v.ct]<dist[u.ct]-1)
            {
              dist[v.ct]=dist[u.ct]-1;
              v.cost=dist[v.ct];
              q.push(v);
              bl[ed]=true;
              par[v.ct]=u.ct;
            }
            else if(par[u.ct]!=v.ct)
            {
               bl[ed]=false;
            }
        }
    }

}
int main()
{
    scanf("%d %d %d",&n,&k,&d);
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&a[0]);
        a[a[0]]=1;
    }
    for(int i=1;i<=n-1;i++)
    {
       scanf("%d %d",&u,&v);
        edges[u].push_back(v);
        edges[v].push_back(u);
        id[u].push_back(i);
        id[v].push_back(i);
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]==1)
        {
          dist[i]=d+1;
        }
    }

    for(int i=1;i<=n;i++)
    {
        if(a[i]==1)
        {
        bfs(i);

        }
    }

    t=0;

    for(int i=1;i<=n-1;i++)
    {
     if(bl[i]==false)
     {
         res[++t]=i;
     }
    }
    cout<<t<<endl;
    for(int i=1;i<=t;i++)
    {
        if(i>1) cout<<" ";
        printf("%d",res[i]);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n,k,d,a[300005],u,v,res[300005],t;
vector<int>edges[300005],id[300005];
bool bl[300005],cl[300005],dl[300005];

int dfs(int p, int dist, int par)
{
   // printf("%d %d %d\n",p,ed,dist);
   if(dist<0) return 0;
   if(a[p]==1 && par!=0) return 0;

    int ret=0,tmp;
    for(int i=0;i<(int)edges[p].size();i++)
    {
        int v=edges[p][i];
        int c=id[p][i];

        if(v!=par)
        {
            tmp=dfs(v,dist-1,p);
            if(tmp==1)
            {
                dl[c]=true;
            }
            ret|=tmp;
        }
    }
    if(bl[p]==false)
    {
        bl[p]=true; ret=1;
    }
    return ret;
}
int main()
{
    scanf("%d %d %d",&n,&k,&d);
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&a[0]);
        a[a[0]]=1;
    }
    for(int i=1;i<=n-1;i++)
    {
       scanf("%d %d",&u,&v);
        edges[u].push_back(v);
        edges[v].push_back(u);
        id[u].push_back(i);
        id[v].push_back(i);
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]==1)
        {
           dfs(i,d,0);
          // break;
        }
    }
    for(int i=1;i<n;i++)
        if(dl[i]==0)
        res[++t]=i;

    cout<<t<<endl;
    for(int i=1;i<=t;i++)
    {
        if(i>1) cout<<" ";
        printf("%d",res[i]);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n,k,d,a[300005],u,v,res[300005],t;
vector<int>edges[300005],id[300005];
bool bl[300005],cl[300005];

void dfs(int p, int ed, int dist)
{
   // printf("%d %d %d\n",p,ed,dist);
   cl[ed]=true;
    if((a[p]==1 && d>dist))
    {
       // cout<<ed;
        res[++t]=ed;
        dist=d;
    }
    else if(dist<0)
    {
        res[++t]=ed; return ;
    }
    for(int i=0;i<(int)edges[p].size();i++)
    {
        int v=edges[p][i];
        int c=id[p][i];
        if(cl[c]==false)
        {
            dfs(v,c,dist-1);
        }
    }
    return ;
}
int main()
{
    scanf("%d %d %d",&n,&k,&d);
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&a[0]);
        a[a[0]]=1;
    }
    for(int i=1;i<=n-1;i++)
    {
       scanf("%d %d",&u,&v);
        edges[u].push_back(v);
        edges[v].push_back(u);
        id[u].push_back(i);
        id[v].push_back(i);
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]==1)
        {
           dfs(i,0,d);
           break;
        }
    }
    cout<<t<<endl;
    for(int i=1;i<=t;i++)
    {
        if(i>1) cout<<" ";
        printf("%d",res[i]);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n,k,d,a[300005],u,v,res[300005],t;
vector<int>edges[300005],id[300005];
bool bl[300005],cl[300005],dl[300005];

int dfs(int p, int dist, int par)
{
   // printf("%d %d %d\n",p,ed,dist);
   if(dist<0) return 0;
   if(a[p]==1 && par!=0) return 0;

    int ret=0,tmp;
    for(int i=0;i<(int)edges[p].size();i++)
    {
        int v=edges[p][i];
        int c=id[p][i];

        if(cl[c]==false && v!=par)
        {
            tmp=dfs(v,dist-1,p);
            if(tmp==1)
            {
                dl[c]=true;
            }
            ret|=tmp;
        }
    }
    if(bl[p]==false)
    {
        bl[p]=true; ret=1;
    }
    return ret;
}
int main()
{
    scanf("%d %d %d",&n,&k,&d);
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&a[0]);
        a[a[0]]=1;
    }
    for(int i=1;i<=n-1;i++)
    {
       scanf("%d %d",&u,&v);
        edges[u].push_back(v);
        edges[v].push_back(u);
        id[u].push_back(i);
        id[v].push_back(i);
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]==1)
        {
           dfs(i,d,0);
          // break;
        }
    }
    for(int i=1;i<n;i++)
        if(dl[i]==0)
        res[++t]=i;

    cout<<t<<endl;
    for(int i=1;i<=t;i++)
    {
        if(i>1) cout<<" ";
        printf("%d",res[i]);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n,k,d,a[300005],u,v,res[300005],t;
vector<int>edges[300005],id[300005];
bool bl[300005],cl[300005];

queue<int>q;
void bfs()
{

   int u,v;
    int ed;

    while(!q.empty())
    {
        u=q.front();

        q.pop();

        for(int i=0;i<(int)edges[u].size();i++)
        {
            v=edges[u][i];
            ed=id[u][i];
            if(bl[v]==false)
            {
              q.push(v);
              bl[v]=true;
              cl[ed]=true;
            }
        }
    }

}
int main()
{
    scanf("%d %d %d",&n,&k,&d);
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&a[0]);
        a[a[0]]=1;
    }

     for(int i=1;i<=n-1;i++)
    {
       scanf("%d %d",&u,&v);
        edges[u].push_back(v);
        edges[v].push_back(u);
        id[u].push_back(i);
        id[v].push_back(i);
    }
    //sobgula ek sathe dukanoi main fact
    for(int i=1;i<=n;i++)
    {
        if(a[i]==1)
        {
          q.push(i);
          bl[i]=true;
        }
    }

    bfs();

    t=0;

    for(int i=1;i<=n-1;i++)
    {
     if(cl[i]==false)
     {
         res[++t]=i;
     }
    }
    cout<<t<<endl;
    for(int i=1;i<=t;i++)
    {
        if(i>1) cout<<" ";
        printf("%d",res[i]);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n,k,d,a[300005],u,v,res[300005],t;
vector<int>edges[300005],id[300005];
bool bl[300005],cl[300005];

queue<int>q;
void bfs()
{

   int u,v;
    int ed;

    while(!q.empty())
    {
        u=q.front();

        q.pop();

        for(int i=0;i<(int)edges[u].size();i++)
        {
            v=edges[u][i];
            ed=id[u][i];
            if(bl[v]==false)
            {
              q.push(v);
              bl[v]=true;
              cl[ed]=true;
            }
        }
    }

}
int main()
{
    scanf("%d %d %d",&n,&k,&d);
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&a[0]);
        a[a[0]]=1;
    }

     for(int i=1;i<=n-1;i++)
    {
       scanf("%d %d",&u,&v);
        edges[u].push_back(v);
        edges[v].push_back(u);
        id[u].push_back(i);
        id[v].push_back(i);
    }
    ///sobgula ek sathe dukanoi main fact
    for(int i=1;i<=n;i++)
    {
        if(a[i]==1)
        {
          q.push(i);
        }
    }

    bfs();

    t=0;

    for(int i=1;i<=n-1;i++)
    {
     if(cl[i]==false)
     {
         res[++t]=i;
     }
    }
    cout<<t<<endl;
    for(int i=1;i<=t;i++)
    {
        if(i>1) cout<<" ";
        printf("%d",res[i]);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n,k,d,a[300005],u,v,res[300005],t,dist[300005],par[300005];
vector<int>edges[300005],id[300005];
bool bl[300005];

void bfs(int p)
{
    queue<int>q;
    int u,v,ed;
    q.push(p);
    while(!q.empty())
    {
        u=q.front();

        q.pop();
        if(dist[u]==1) continue;

        for(int i=0;i<(int)edges[u].size();i++)
        {
            v=edges[u][i];
            ed=id[u][i];
            if(dist[v]<dist[u]-1)
            {
              dist[v]=dist[u]-1;
              q.push(v);
              bl[ed]=true;
              par[v]=u;
            }
            else if(par[u]!=v)
            {
               bl[ed]=false;
            }
        }
    }

}
int main()
{
    scanf("%d %d %d",&n,&k,&d);
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&a[0]);
        a[a[0]]=1;
    }
    for(int i=1;i<=n-1;i++)
    {
       scanf("%d %d",&u,&v);
        edges[u].push_back(v);
        edges[v].push_back(u);
        id[u].push_back(i);
        id[v].push_back(i);
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]==1)
        {
          dist[i]=d+1;
        }
    }

    for(int i=1;i<=n;i++)
    {
        if(a[i]==1)
        {
        bfs(i);

        }
    }

    t=0;

    for(int i=1;i<=n-1;i++)
    {
     if(bl[i]==false)
     {
         res[++t]=i;
     }
    }
    cout<<t<<endl;
    for(int i=1;i<=t;i++)
    {
        if(i>1) cout<<" ";
        printf("%d",res[i]);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n,k,d,a[300005],u,v,res[300005],t;
vector<int>edges[300005],id[300005];
bool bl[300005],cl[300005];

void dfs(int p, int ed, int dist)
{
   // printf("%d %d %d\n",p,ed,dist);
   cl[ed]=true;
    if((a[p]==1 && d>dist))
    {
       // cout<<ed;
        res[++t]=ed;
        dist=d;
    }
    else if(dist<0)
    {
        res[++t]=ed; return ;
    }
    for(int i=0;i<(int)edges[p].size();i++)
    {
        int v=edges[p][i];
        int c=id[p][i];
        if(cl[c]==false)
        {
            dfs(v,c,dist-1);
        }
    }
    return ;
}
int main()
{
    scanf("%d %d %d",&n,&k,&d);
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&a[0]);
        a[a[0]]=1;
    }
    for(int i=1;i<=n-1;i++)
    {
       scanf("%d %d",&u,&v);
        edges[u].push_back(v);
        edges[v].push_back(u);
        id[u].push_back(i);
        id[v].push_back(i);
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]==1)
        {
           dfs(i,0,d);
          // break;
        }
    }
    cout<<t<<endl;
    for(int i=1;i<=t;i++)
    {
        if(i>1) cout<<" ";
        printf("%d",res[i]);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n,k,d,a[300005],u,v,res[300005],t,dist[300005],par[300005];
vector<int>edges[300005],id[300005];
bool bl[300005];

struct data
{
    int ct,cost;
    bool operator<(const data& p)
    const
    {
        if(cost==p.cost) return ct>p.ct;
        return cost>p.cost;
        }
};

void bfs(int p)
{
    priority_queue<data>q;
    data u,v;
    int ed;
    u.ct=p;
    u.cost=d+1;
    q.push(u);
    while(!q.empty())
    {
        u=q.top();

        q.pop();
        if(dist[u.ct]==1) continue;

        for(int i=0;i<(int)edges[u.ct].size();i++)
        {
            v.ct=edges[u.ct][i];
            ed=id[u.ct][i];
            if(dist[v.ct]<dist[u.ct]-1)
            {
              dist[v.ct]=dist[u.ct]-1;
              v.cost=dist[v.ct];
              q.push(v);
              bl[ed]=true;
              par[v.ct]=u.ct;
            }
            else if(par[u.ct]!=v.ct)
            {
               bl[ed]=false;
            }
        }
    }

}
int main()
{
    scanf("%d %d %d",&n,&k,&d);
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&a[0]);
        a[a[0]]=1;
    }
    for(int i=1;i<=n-1;i++)
    {
       scanf("%d %d",&u,&v);
        edges[u].push_back(v);
        edges[v].push_back(u);
        id[u].push_back(i);
        id[v].push_back(i);
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]==1)
        {
          dist[i]=d+1;
        }
    }

    for(int i=1;i<=n;i++)
    {
        if(a[i]==1)
        {
        bfs(i);

        }
    }

    t=0;

    for(int i=1;i<=n-1;i++)
    {
     if(bl[i]==false)
     {
         res[++t]=i;
     }
    }
    cout<<t<<endl;
    for(int i=1;i<=t;i++)
    {
        if(i>1) cout<<" ";
        printf("%d",res[i]);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n,k,d,a[300005],u,v,res[300005],t,dist[300005],par[300005];
vector<int>edges[300005],id[300005];
bool bl[300005],cl[300005];

struct data
{
    int ct,cost;
    bool operator<(const data& p)
    const
    {
        if(cost==p.cost) return ct>p.ct;
        return cost>p.cost;
        }
};

void bfs(int p)
{
    priority_queue<data>q;
    data u,v;
    int ed;
    u.ct=p;
    u.cost=d+1;
    q.push(u);
    while(!q.empty())
    {
        u=q.top();

        q.pop();
      if(dist[u.ct]==1) continue;

        for(int i=0;i<(int)edges[u.ct].size();i++)
        {
            v.ct=edges[u.ct][i];
            ed=id[u.ct][i];
            if(dist[v.ct]<dist[u.ct]-1)
            {
              dist[v.ct]=dist[u.ct]-1;
              v.cost=dist[v.ct];
              q.push(v);
              bl[ed]=true;
              par[v.ct]=u.ct;
            }
            else if(par[u.ct]!=v.ct)
            {
               bl[ed]=false;
            }
        }
    }

}
int main()
{
    scanf("%d %d %d",&n,&k,&d);
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&a[0]);
        a[a[0]]=1;
    }

     for(int i=1;i<=n-1;i++)
    {
       scanf("%d %d",&u,&v);
        edges[u].push_back(v);
        edges[v].push_back(u);
        id[u].push_back(i);
        id[v].push_back(i);
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]==1)
        {
          dist[i]=d+1;
        }
    }

    for(int i=1;i<=n;i++)
    {
        if(a[i]==1 && cl[i]==false)
        {
        bfs(i);

        }
    }

    t=0;

    for(int i=1;i<=n-1;i++)
    {
     if(bl[i]==false)
     {
         res[++t]=i;
     }
    }
    cout<<t<<endl;
    for(int i=1;i<=t;i++)
    {
        if(i>1) cout<<" ";
        printf("%d",res[i]);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n,k,d,a[300005],u,v,res[300005],t,dist[300005],par[300005];
vector<int>edges[300005],id[300005];
bool bl[300005];

struct data
{
    int ct,cost;
    bool operator<(const data& p)
    const
    {
        if(cost==p.cost) return ct>p.ct;
        return cost<p.cost;
        }
};

void bfs(int p)
{
    priority_queue<data>q;
    data u,v;
    int ed;
    u.ct=p;
    u.cost=d+1;
    q.push(u);
    while(!q.empty())
    {
        u=q.top();

        q.pop();
     //   if(dist[u.ct]==1) continue;

        for(int i=0;i<(int)edges[u.ct].size();i++)
        {
            v.ct=edges[u.ct][i];
            ed=id[u.ct][i];
            if(dist[v.ct]<dist[u.ct]-1)
            {
              dist[v.ct]=dist[u.ct]-1;
              v.cost=dist[v.ct];
              q.push(v);
              bl[ed]=true;
              par[v.ct]=u.ct;
            }
            else if(par[u.ct]!=v.ct)
            {
               bl[ed]=false;
            }
        }
    }

}
int main()
{
    scanf("%d %d %d",&n,&k,&d);
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&a[0]);
        a[a[0]]=1;
    }
    for(int i=1;i<=n-1;i++)
    {
       scanf("%d %d",&u,&v);
        edges[u].push_back(v);
        edges[v].push_back(u);
        id[u].push_back(i);
        id[v].push_back(i);
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]==1)
        {
          dist[i]=d+1;
        }
    }

    for(int i=1;i<=n;i++)
    {
        if(a[i]==1)
        {
        bfs(i);

        }
    }

    t=0;

    for(int i=1;i<=n-1;i++)
    {
     if(bl[i]==false)
     {
         res[++t]=i;
     }
    }
    cout<<t<<endl;
    for(int i=1;i<=t;i++)
    {
        if(i>1) cout<<" ";
        printf("%d",res[i]);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n,k,d,a[300005],u,v,res[300005],t;
vector<int>edges[300005],id[300005];
bool bl[300005],cl[300005],dl[300005];

int dfs(int p, int dist, int par)
{
   // printf("%d %d %d\n",p,ed,dist);
   if(dist<0) return 0;
   if(a[p]==1 && par!=0) {bl[p]=true;return 0;}
    int ret=0,tmp;

    for(int i=0;i<(int)edges[p].size();i++)
    {
        int v=edges[p][i];
        int c=id[p][i];

        if(v!=par)
        {
            tmp=dfs(v,dist-1,p);

            if(tmp==1)
            {
                dl[c]=true;
            }
            if(tmp==1) ret=1;
        }
    }
    if(bl[p]==false)
    {
        bl[p]=true; ret=1;
    }
    return ret;
}
int main()
{
    scanf("%d %d %d",&n,&k,&d);
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&a[0]);
        a[a[0]]=1;
    }
    for(int i=1;i<=n-1;i++)
    {
       scanf("%d %d",&u,&v);
        edges[u].push_back(v);
        edges[v].push_back(u);
        id[u].push_back(i);
        id[v].push_back(i);
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]==1)
        {
           dfs(i,d,0);
          // break;
        }
    }
    for(int i=1;i<n;i++)
        if(dl[i]==0)
        res[++t]=i;

    cout<<t<<endl;
    for(int i=1;i<=t;i++)
    {
        if(i>1) cout<<" ";
        printf("%d",res[i]);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n,k,d,a[300005],u,v,res[300005],t,dist[300005],par[300005];
vector<int>edges[300005],id[300005];
bool bl[300005];

struct data
{
    int ct,cost;
    bool operator<(const data& p)
    const
    {
        if(cost==p.cost) return ct>p.ct;
        return cost>p.cost;
        }
};

void bfs(int p)
{
    priority_queue<data>q;
    data u,v;
    int ed;
    u.ct=p;
    u.cost=d+1;
    q.push(u);
    while(!q.empty())
    {
        u=q.top();

        q.pop();
     //   if(dist[u.ct]==1) continue;

        for(int i=0;i<(int)edges[u.ct].size();i++)
        {
            v.ct=edges[u.ct][i];
            ed=id[u.ct][i];
            if(dist[v.ct]<dist[u.ct]-1)
            {
              dist[v.ct]=dist[u.ct]-1;
              v.cost=dist[v.ct];
              q.push(v);
              bl[ed]=true;
              par[v.ct]=u.ct;
            }
            else if(par[u.ct]!=v.ct)
            {
               bl[ed]=false;
            }
        }
    }

}
int main()
{
    scanf("%d %d %d",&n,&k,&d);
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&a[0]);
        a[a[0]]=1;
    }
    for(int i=1;i<=n-1;i++)
    {
       scanf("%d %d",&u,&v);
        edges[u].push_back(v);
        edges[v].push_back(u);
        id[u].push_back(i);
        id[v].push_back(i);
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]==1)
        {
          dist[i]=d+1;
        }
    }

    for(int i=1;i<=n;i++)
    {
        if(a[i]==1)
        {
        bfs(i);

        }
    }

    t=0;

    for(int i=1;i<=n-1;i++)
    {
     if(bl[i]==false)
     {
         res[++t]=i;
     }
    }
    cout<<t<<endl;
    for(int i=1;i<=t;i++)
    {
        if(i>1) cout<<" ";
        printf("%d",res[i]);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int n,k,d,a[300005],u,v,res[300005],t;
vector<int>edges[300005],id[300005];
bool bl[300005],cl[300005];

void dfs(int p, int ed, int dist)
{
   // printf("%d %d %d\n",p,ed,dist);
   if(bl[p]==true) return ;
   cl[ed]=true;
   bl[p]=true;
    if((a[p]==1 && ed>0))
    {
       // cout<<ed;
        res[++t]=ed;
        dist=d;
    }
    else if(dist<0)
    {
        res[++t]=ed; return ;
    }
    for(int i=0;i<(int)edges[p].size();i++)
    {
        int v=edges[p][i];
        int c=id[p][i];
        if(cl[c]==false && bl[v]==false)
        {
            dfs(v,c,dist-1);
        }
    }
    return ;
}
int main()
{
    scanf("%d %d %d",&n,&k,&d);
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&a[0]);
        a[a[0]]=1;
    }
    for(int i=1;i<=n-1;i++)
    {
       scanf("%d %d",&u,&v);
        edges[u].push_back(v);
        edges[v].push_back(u);
        id[u].push_back(i);
        id[v].push_back(i);
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]==1)
        {
           dfs(i,0,d);
          // break;
        }
    }
    cout<<t<<endl;
    for(int i=1;i<=t;i++)
    {
        if(i>1) cout<<" ";
        printf("%d",res[i]);
    }
    return 0;
}


/*
 *	Task: 796D
 *	Lang: C/C++11
 *	Author: comtalyst
 *	Site: Codeforces
 *	Last Update: 22/8/2017
 */

#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
using namespace std;

/* Note
----------------------------
Learned :
Bugs found & solved :
- forgot to calculate limits
----------------------------
*/

#define x first
#define y second
#define umap unordered_map
#define pqueue priority_queue
#define mset multiset
#define mp make_pair
#define mt make_tuple

vector<pair<int,int>> adl[300005];
bool chk[300005];

main(){
	int t,i,j,n,m,k,x,y,d,id,f;
	queue<tuple<int,int,int>> q;
	set<int> res;

	scanf("%d %d %d",&n,&m,&k);
	for(i = 1; i <= m; i++){
		scanf("%d",&x);
		q.emplace(0,x,0);
		chk[x] = true;
	}
	for(i = 1; i < n; i++){
		scanf("%d %d",&x,&y);
		adl[x].emplace_back(y,i);
		adl[y].emplace_back(x,i);
	}
	while(!q.empty()){
		tie(d,x,f) = q.front();
		q.pop();
		if(d == k){
			for(i = 0; i < adl[x].size(); i++){
				y = adl[x][i].x;
				id = adl[x][i].y;
				if(y == f) continue;
				res.emplace(id);
			}
			continue;
		}
		for(i = 0; i < adl[x].size(); i++){
			y = adl[x][i].x;
			id = adl[x][i].y;
			if(y == f) continue;
			if(chk[y]){
				res.emplace(id);
			}
			else{
				chk[y] = true;
				q.emplace(d+1,y,x);
			}
		}
	}
	printf("%d\n",res.size());
	while(!res.empty()){
		printf("%d ",*res.begin());
		res.erase(res.begin());
	}
	printf("\n");

	return 0;
}


/*
 *	Task: 796D
 *	Lang: C/C++11
 *	Author: comtalyst
 *	Site: Codeforces
 *	Last Update: 22/8/2017
 */

#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
using namespace std;

/* Note
----------------------------
Learned :
Bugs found & solved :
- forgot to calculate limits
----------------------------
*/

#define x first
#define y second
#define umap unordered_map
#define pqueue priority_queue
#define mset multiset
#define mp make_pair
#define mt make_tuple

vector<pair<int,int>> adl[300005];
bool chk[300005];

main(){
	int t,i,j,n,m,k,x,y,d,id,f;
	queue<tuple<int,int,int>> q;
	set<int> res;

	scanf("%d %d %d",&n,&m,&k);
	for(i = 1; i <= m; i++){
		scanf("%d",&x);
		q.emplace(0,x,0);
		chk[x] = true;
	}
	for(i = 1; i < n; i++){
		scanf("%d %d",&x,&y);
		adl[x].emplace_back(y,i);
		adl[y].emplace_back(x,i);
	}
	while(!q.empty()){
		tie(d,x,f) = q.front();
		q.pop();
		if(d == k){
			//printf("%d %d %d\n",d,x,f);
			for(i = 0; i < adl[x].size(); i++){
				y = adl[x][i].x;
				id = adl[x][i].y;
				if(y == f) continue;
				res.emplace(id);
			}
			continue;
		}
		for(i = 0; i < adl[x].size(); i++){
			y = adl[x][i].x;
			id = adl[x][i].y;
			if(y == f) continue;
			if(chk[y]){
				res.emplace(id);
			}
			else{
				chk[y] = true;
				q.emplace(d+1,y,x);
			}
		}
	}
	for(i = 1; i <= n; i++){
		if(!chk[i]){
			printf("BOBO\n");
			return 136;
		}
	}
	printf("%d\n",res.size());
	while(!res.empty()){
		printf("%d ",*res.begin());
		res.erase(res.begin());
	}
	printf("\n");

	return 0;
}


/*
 *	Task: 796D
 *	Lang: C/C++11
 *	Author: comtalyst
 *	Site: Codeforces
 *	Last Update: 22/8/2017
 */

#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
using namespace std;

/* Note
----------------------------
Learned :
Bugs found & solved :
- forgot to calculate limits
----------------------------
*/

#define x first
#define y second
#define umap unordered_map
#define pqueue priority_queue
#define mset multiset
#define mp make_pair
#define mt make_tuple

vector<pair<int,int>> adl[300005];
bool chk[300005];

main(){
	int t,i,j,n,m,k,x,y,d,id,f;
	queue<tuple<int,int,int>> q;
	set<int> res;

	scanf("%d %d %d",&n,&m,&k);
	for(i = 1; i <= m; i++){
		scanf("%d",&x);
		if(chk[x]) continue;
		q.emplace(0,x,0);
		chk[x] = true;
	}
	for(i = 1; i < n; i++){
		scanf("%d %d",&x,&y);
		adl[x].emplace_back(y,i);
		adl[y].emplace_back(x,i);
	}
	while(!q.empty()){
		tie(d,x,f) = q.front();
		q.pop();
		if(d == k){
			//printf("%d %d %d\n",d,x,f);
			for(i = 0; i < adl[x].size(); i++){
				y = adl[x][i].x;
				id = adl[x][i].y;
				if(y == f) continue;
				res.emplace(id);
			}
			continue;
		}
		for(i = 0; i < adl[x].size(); i++){
			y = adl[x][i].x;
			id = adl[x][i].y;
			if(y == f) continue;
			if(chk[y]){
				res.emplace(id);
			}
			else{
				chk[y] = true;
				q.emplace(d+1,y,x);
			}
		}
	}
	printf("%d\n",res.size());
	while(!res.empty()){
		printf("%d ",*res.begin());
		res.erase(res.begin());
	}
	printf("\n");

	return 0;
}


/*
 *	Task: D
 *	Lang: C/C++11
 *	Author: comtalyst
 *	Site: Educational Codeforces Round 27
 *	Last Update: 21/8/2017
 */

#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
using namespace std;

/* Note
----------------------------
Learned :
Bugs found & solved :
----------------------------
*/

#define x first
#define y second
#define umap unordered_map
#define pqueue priority_queue
#define mset multiset
#define mp make_pair
#define mt make_tuple

main(){
	int t,i,j,n,m,c,v,olimc=0,res=0,x,lvlim=INT_MAX;
	bool olim=false;
	multiset<int> vlim;
	stack<int> vlims;

	scanf("%d",&n);
	for(i = 1; i <= n; i++){
		scanf("%d",&c);
		if(c == 1){
			scanf("%d",&v);
			if(v <= lvlim) continue;
			while(!vlims.empty() && v > vlims.top()){
				vlims.pop();
				res++;
			}
		}
		else if(c == 2){
			if(olim){
				res += olimc;
				olimc = 0;
			}
		}
		else if(c == 3){
			scanf("%d",&lvlim);
			if(v > lvlim){
				res++;
			}
			else{
				vlim.emplace(lvlim);
				vlims.emplace(lvlim);
			}
		}
		else if(c == 4){
			olim = false;
			olimc = 0;
		}
		else if(c == 5){
			vlim.clear();
			while(!vlims.empty()){
				vlims.pop();
			}
			lvlim = INT_MAX;
		}
		else if(c == 6){
			olim = true;
			olimc++;
		}
	}
	printf("%d\n",res);

	return 0;
}


/*
 *	Task: 796D
 *	Lang: C/C++11
 *	Author: comtalyst
 *	Site: Codeforces
 *	Last Update: 22/8/2017
 */

#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
using namespace std;

/* Note
----------------------------
Learned :
Bugs found & solved :
----------------------------
*/

#define x first
#define y second
#define umap unordered_map
#define pqueue priority_queue
#define mset multiset
#define mp make_pair
#define mt make_tuple

vector<pair<int,int>> adl[300005];
bool chk[300005];

main(){
	int t,i,j,n,m,k,x,y,d,id,f;
	queue<pair<int,int>> q;
	set<int> res;

	scanf("%d %d %d",&n,&m,&k);
	for(i = 1; i <= m; i++){
		scanf("%d",&x);
		q.emplace(x,0);
		chk[x] = true;
	}
	for(i = 1; i < n; i++){
		scanf("%d %d",&x,&y);
		adl[x].emplace_back(y,i);
		adl[y].emplace_back(x,i);
	}
	while(!q.empty()){
		x = q.front().x;
		f = q.front().y;
		q.pop();
		for(i = 0; i < adl[x].size(); i++){
			y = adl[x][i].x;
			id = adl[x][i].y;
			if(y == f) continue;
			if(chk[y]){
				res.emplace(id);
			}
			else{
				chk[y] = true;
				q.emplace(y,x);
			}
		}
	}
	printf("%d\n",res.size());
	while(!res.empty()){
		printf("%d ",*res.begin());
		res.erase(res.begin());
	}
	printf("\n");

	return 0;
}


/*
 *	Task: 796D
 *	Lang: C/C++11
 *	Author: comtalyst
 *	Site: Codeforces
 *	Last Update: 22/8/2017
 */

#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
using namespace std;

/* Note
----------------------------
Learned :
Bugs found & solved :
- forgot to calculate limits
----------------------------
*/

#define x first
#define y second
#define umap unordered_map
#define pqueue priority_queue
#define mset multiset
#define mp make_pair
#define mt make_tuple

vector<pair<int,int>> adl[300005];
bool chk[300005];

main(){
	int t,i,j,n,m,k,x,y,d,id,f;
	queue<tuple<int,int,int>> q;
	set<int> res;

	scanf("%d %d %d",&n,&m,&k);
	for(i = 1; i <= m; i++){
		scanf("%d",&x);
		q.emplace(0,x,0);
		chk[x] = true;
	}
	for(i = 1; i < n; i++){
		scanf("%d %d",&x,&y);
		adl[x].emplace_back(y,i);
		adl[y].emplace_back(x,i);
	}
	while(!q.empty()){
		tie(d,x,f) = q.front();
		q.pop();
		if(d == k){
			for(i = 0; i < adl[x].size(); i++){
				y = adl[x][i].x;
				id = adl[x][i].y;
				res.emplace(id);
			}
			continue;
		}
		for(i = 0; i < adl[x].size(); i++){
			y = adl[x][i].x;
			id = adl[x][i].y;
			if(y == f) continue;
			if(chk[y]){
				res.emplace(id);
			}
			else{
				chk[y] = true;
				q.emplace(d+1,y,x);
			}
		}
	}
	printf("%d\n",res.size());
	while(!res.empty()){
		printf("%d ",*res.begin());
		res.erase(res.begin());
	}
	printf("\n");

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

using namespace std;

typedef long long int64;
const int kMaxN= 3e5+10;
const int kInf = (1<<30);

int n, k, d;
bool police[kMaxN];
int mind[kMaxN];
bool covered[kMaxN];
vector<pair<int, int>> T[kMaxN];
set<int> S;

void dfs(int x, int f, int i) {
	mind[x] = kInf;
	covered[x] = false;
	for (auto edge : T[x]) {
		int y = edge.first;
		if (y == f)
			continue;

		dfs(y, x, edge.second);
		mind[x] = min(mind[x], mind[y] + 1);
	}

	if (police[x]) {
		mind[x] = 0;
		for (auto edge : T[x]) {
			int y = edge.first;
			if (y == f)
				continue;
			if (covered[y])
				S.insert(edge.second);
		}
	}

	if (mind[x] == d && x != 1) {
		S.insert(i);
	}
	if (mind[x] > d) {
		covered[x] = false;
	} else {
		covered[x] = true;
	}
}

void solve() {
	scanf("%d %d %d", &n, &k, &d);

	if (d == 0) {
		cout << k-1 << "\n";
		for (int i = 1; i < n; ++i) {
			cout << i << " ";
		}
		cout << "\n";
		return;
	}

	for (int i = 1; i <= k; ++i) {
		int x;
		scanf("%d", &x);
		police[x] = true;
	}

	for (int i = 1; i < n; ++i) {
		int x, y;
		scanf("%d %d", &x, &y);
		T[x].push_back({y, i});
		T[y].push_back({x, i});
	}

	dfs(1, 0, 0);

	cout << S.size() << "\n";
	for (auto el : S) {
		cout << el << " ";
	}
	cout << "\n";
}

void reset() {
	for (int i = 1; i <= n; ++i) {
		police[i] = false;
		T[i].clear();
	}
	S.clear();
}

int main() {
	int tests = 1;

	for (;tests; --tests) {
		solve();
		reset();
	}
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

using namespace std;

typedef long long int64;
const int kMaxN= 3e5+10;
const int kInf = (1<<30);

int n, k, d;
bool police[kMaxN];
int mind[kMaxN], longd[kMaxN];
vector<pair<int, int>> T[kMaxN];
set<int> S;

void dfs(int x, int f, int i) {
	longd[x] = -1;
	mind[x] = kInf;
	for (auto edge : T[x]) {
		int y = edge.first;
		if (y == f)
			continue;

		dfs(y, x, edge.second);
		mind[x] = min(mind[x], mind[y] + 1);
	}
	if (police[x])
		mind[x] = 0;

	for (auto edge : T[x]) {
		int y = edge.first;
		if (y == f)
			continue;
		if (longd[y] != -1 && longd[y] + mind[x] + 1 > d) {
			longd[x] = max(longd[x], longd[y] + 1);
		}
	}
	if (mind[x] > d) {
		longd[x] = 0;
	}

	if (police[x]) {
		for (auto edge : T[x]) {
			int y = edge.first;
			if (y == f)
				continue;
			if (longd[y] == -1)
				S.insert(edge.second);
		}
	}

	// cout << x << " " << mind[x] << " " << longd[x] << "\n";

	if (longd[x] == -1 && mind[x] == d && x != 1) {
		S.insert(i);
	}
}

void solve() {
	scanf("%d %d %d", &n, &k, &d);

	if (d == 0) {
		cout << n-1 << "\n";
		for (int i = 1; i < n; ++i) {
			cout << i << " ";
		}
		cout << "\n";
		return;
	}

	for (int i = 1; i <= k; ++i) {
		int x;
		scanf("%d", &x);
		police[x] = true;
	}

	for (int i = 1; i < n; ++i) {
		int x, y;
		scanf("%d %d", &x, &y);
		T[x].push_back({y, i});
		T[y].push_back({x, i});
	}

	dfs(1, 0, 0);

	cout << S.size() << "\n";
	for (auto el : S) {
		cout << el << " ";
	}
	cout << "\n";
}

void reset() {
	for (int i = 1; i <= n; ++i) {
		police[i] = false;
		T[i].clear();
	}
	S.clear();
}

int main() {
	int tests = 2;

	for (;tests; --tests) {
		solve();
		reset();
	}
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

using namespace std;

typedef long long int64;
const int kMaxN= 3e5+10;
const int kInf = (1<<30);

int n, k, d;
bool police[kMaxN];
int mind[kMaxN], longd[kMaxN], from[kMaxN];
vector<pair<int, int>> T[kMaxN];
set<int> S;

void dfs(int x, int f, int i) {
	longd[x] = -1;
	mind[x] = kInf;
	from[x] = -1;
	from[x] = 0;
	for (auto edge : T[x]) {
		int y = edge.first;
		if (y == f)
			continue;

		dfs(y, x, edge.second);
		if (mind[y] + 1 < mind[x]) {
			mind[x] = mind[y] + 1;
			from[x] = y;
		}
	}
	if (police[x]) {
		from[x] = x;
		mind[x] = 0;
	}

	for (auto edge : T[x]) {
		int y = edge.first;
		if (y == f)
			continue;
		if (longd[y] != -1 && longd[y] + mind[x] + 1 > d) {
			longd[x] = max(longd[x], longd[y] + 1);
		}
	}
	if (mind[x] > d) {
		longd[x] = 0;
	}

	if (mind[x] <= d) {
		for (auto edge : T[x]) {
			int y = edge.first;
			if (y == f)
				continue;
			if (longd[y] == -1 && from[x] != y)
				S.insert(edge.second);
		}
	}
}

void solve() {
	scanf("%d %d %d", &n, &k, &d);

	if (d == 0) {
		cout << n-1 << "\n";
		for (int i = 1; i < n; ++i) {
			cout << i << " ";
		}
		cout << "\n";
		return;
	}

	for (int i = 1; i <= k; ++i) {
		int x;
		scanf("%d", &x);
		police[x] = true;
	}

	for (int i = 1; i < n; ++i) {
		int x, y;
		scanf("%d %d", &x, &y);
		T[x].push_back({y, i});
		T[y].push_back({x, i});
	}

	dfs(1, 0, 0);

	cout << S.size() << "\n";
	for (auto el : S) {
		cout << el << " ";
	}
	cout << "\n";
}

void reset() {
	for (int i = 1; i <= n; ++i) {
		police[i] = false;
		T[i].clear();
	}
	S.clear();
}

int main() {
	int tests = 1;

	for (;tests; --tests) {
		solve();
		reset();
	}
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

using namespace std;

typedef long long int64;
const int kMaxN= 3e5+10;
const int kInf = (1<<30);

int n, k, d;
bool police[kMaxN];
vector<int> T[kMaxN];
vector<pair<int,int>> edges;
int from[kMaxN];

void bfs() {
	queue<int> Q;
	for (int i = 1; i <= n; ++i) {
		if (police[i]) {
			from[i] = i;
			Q.push(i);
		}
	}

	while (!Q.empty()) {
		int x = Q.front();
		Q.pop();

		for (auto y : T[x]) {
			if (from[y] == 0) {
				from[y] = from[x];
				Q.push(y);
			}
		}
	}
}

void solve() {
	scanf("%d %d %d", &n, &k, &d);

	for (int i = 1; i <= k; ++i) {
		int x;
		scanf("%d", &x);
		police[x] = true;
	}

	for (int i = 1; i < n; ++i) {
		int x, y;
		scanf("%d %d", &x, &y);
		T[x].push_back(y);
		T[y].push_back(x);
		edges.push_back({x, y});
	}

	bfs();

	vector<int> sol;
	for (int i = 0; i < edges.size(); ++i) {
		auto& edge = edges[i];
		if (from[edge.first] != from[edge.second]) {
			sol.push_back(i+1);
		}
	}

	cout << sol.size() << "\n";
	for (auto el : sol) {
		cout << el << " ";
	}
	cout << "\n";
}

void reset() {
}

int main() {
	int tests = 1;

	for (;tests; --tests) {
		solve();
		reset();
	}
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

using namespace std;

typedef long long int64;
const int kMaxN= 3e5+10;
const int kInf = (1<<30);

int n, k, d;
bool police[kMaxN];
int mind[kMaxN], longd[kMaxN];
vector<pair<int, int>> T[kMaxN];
set<int> S;

void dfs(int x, int f, int i) {
	longd[x] = -1;
	mind[x] = kInf;
	for (auto edge : T[x]) {
		int y = edge.first;
		if (y == f)
			continue;

		dfs(y, x, edge.second);
		mind[x] = min(mind[x], mind[y] + 1);
	}
	if (police[x])
		mind[x] = 0;

	for (auto edge : T[x]) {
		int y = edge.first;
		if (y == f)
			continue;
		if (longd[y] != -1 && longd[y] + mind[x] + 1 > d) {
			longd[x] = max(longd[x], longd[y] + 1);
		}
	}
	if (mind[x] > d) {
		longd[x] = 0;
	}

	if (police[x]) {
		for (auto edge : T[x]) {
			int y = edge.first;
			if (y == f)
				continue;
			if (longd[y] == -1)
				S.insert(edge.second);
		}
	}

	// cout << x << " " << mind[x] << " " << longd[x] << "\n";

	if (longd[x] == -1 && mind[x] == d && x != 1) {
		S.insert(i);
	}
}

void solve() {
	scanf("%d %d %d", &n, &k, &d);

	if (d == 0) {
		cout << n-1 << "\n";
		for (int i = 1; i < n; ++i) {
			cout << i << " ";
		}
		cout << "\n";
		return;
	}

	for (int i = 1; i <= k; ++i) {
		int x;
		scanf("%d", &x);
		police[x] = true;
	}

	for (int i = 1; i < n; ++i) {
		int x, y;
		scanf("%d %d", &x, &y);
		T[x].push_back({y, i});
		T[y].push_back({x, i});
	}

	dfs(1, 0, 0);

	cout << S.size() << "\n";
	for (auto el : S) {
		cout << el << " ";
	}
	cout << "\n";
}

void reset() {
	for (int i = 1; i <= n; ++i) {
		police[i] = false;
		T[i].clear();
	}
	S.clear();
}

int main() {
	int tests = 1;

	for (;tests; --tests) {
		solve();
		reset();
	}
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

using namespace std;

typedef long long int64;
const int kMaxN= 3e5+10;
const int kInf = (1<<30);

int n, k, d;
bool police[kMaxN];
int mind[kMaxN], longd[kMaxN], from[kMaxN];
vector<pair<int, int>> T[kMaxN];
set<int> S;

void dfs(int x, int f, int i) {
	longd[x] = -1;
	mind[x] = kInf;
	from[x] = -1;
	from[x] = 0;
	for (auto edge : T[x]) {
		int y = edge.first;
		if (y == f)
			continue;

		dfs(y, x, edge.second);
		if (mind[y] + 1 < mind[x]) {
			mind[x] = mind[y] + 1;
			from[x] = y;
		}
	}
	if (police[x]) {
		from[x] = x;
		mind[x] = 0;
	}
	if (mind[x] > d) {
		longd[x] = 0;
	}

	for (auto edge : T[x]) {
		int y = edge.first;
		if (y == f)
			continue;
		if (longd[y] != -1 && longd[y] + mind[x] + 1 > d) {
			longd[x] = max(longd[x], longd[y] + 1);
		}
	}
	if (mind[x] <= d) {
		for (auto edge : T[x]) {
			int y = edge.first;
			if (y == f)
				continue;
			if (longd[y] == -1 && from[x] != y)
				S.insert(edge.second);
		}
	}
}

void solve() {
	scanf("%d %d %d", &n, &k, &d);

	if (d == 0) {
		cout << n-1 << "\n";
		for (int i = 1; i < n; ++i) {
			cout << i << " ";
		}
		cout << "\n";
		return;
	}

	for (int i = 1; i <= k; ++i) {
		int x;
		scanf("%d", &x);
		police[x] = true;
	}

	for (int i = 1; i < n; ++i) {
		int x, y;
		scanf("%d %d", &x, &y);
		T[x].push_back({y, i});
		T[y].push_back({x, i});
	}

	dfs(1, 0, 0);

	cout << S.size() << "\n";
	for (auto el : S) {
		cout << el << " ";
	}
	cout << "\n";
}

void reset() {
	for (int i = 1; i <= n; ++i) {
		police[i] = false;
		T[i].clear();
	}
	S.clear();
}

int main() {
	int tests = 1;

	for (;tests; --tests) {
		solve();
		reset();
	}
}


#include<cstring>
#include<cstdio>
#include<queue>
using namespace std;
struct edge
{
	int to,next;
} e[600005];
int n,k,d;
int belong[300005];
int idx[300005];
int p[300005];
int top=0;
int dis[300005];
void add(int x,int y)
{
	top++;
	e[top].to=y;
	e[top].next=idx[x];
	idx[x]=top;
}
int dd1[300005],dd2[300005];
struct item
{
	int id;
	int col;
	int level;
} p1,p2;
int cur;
int bl[300005];
void bfs()
{
	queue<item> q;
	for(int i=1; i<=k; i++)
	{
		if(p[i])
		{
			p1.id=p[i];
			p1.col=i;
			p1.level=0;
			q.push(p1);
			dis[p[i]]=0;
			belong[p[i]]=p1.col;
		}
	}
	while(!q.empty())
	{
		p1=q.front();
		q.pop();
		for(int i=idx[p1.id];i;i=e[i].next)
		{
			p2.level=p1.level+1;
			p2.col=p1.col;
			p2.id=e[i].to;
			if(dis[p2.id]>p2.level&&belong[p2.id]!=p2.col)
			{
				dis[p2.id]=p2.level;
				belong[p2.id]=p2.col;
				q.push(p2);
			}
		}
	}
}
int cnt=0;
inline int getint()
{
	int ret=0;
	char s;
	s=getchar();
	while(s>'9'||s<'0') s=getchar();
	while(s<='9'&&s>='0')
	{
		ret=ret*10+s-'0';
		s=getchar();
	}
	return ret;
}
int main()
{
	memset(dis,0x3f,sizeof(dis));
	n=getint();
	k=getint();
	d=getint();
	for(int i=1; i<=k; i++)
	{
		int temp;
		temp=getint();
		if(bl[temp]==0)
		{
			bl[temp]=1;
			p[i]=temp;
		}
		else cnt++;
	}
	for(int i=1; i<n; i++)
	{
		int a,b;
		a=getint();
		b=getint();
		add(a,b);
		add(b,a);
		dd1[i]=a;
		dd2[i]=b;
	}
	bfs();
	printf("%d\n",k-1-cnt);
	int sign=0;
	for(int i=1; i<n; i++)
	{
		if(belong[dd1[i]]!=belong[dd2[i]])
		{
			if(sign==0) sign=1;
			else printf(" ");
			printf("%d",i);
		}
	}
	printf("\n");
	return 0;
}


#include<cstring>
#include<cstdio>
#include<queue>
using namespace std;
struct edge
{
	int to,next;
} e[600005];
int n,k,d;
int belong[300005];
int idx[300005];
int p[300005];
int top=0;
void add(int x,int y)
{
	top++;
	e[top].to=y;
	e[top].next=idx[x];
	idx[x]=top;
}
int dd1[300005],dd2[300005];
struct item
{
	int id;
	int level;
} p1,p2;
int cur;
int bl[300005];
void bfs(int start)
{
	belong[start]=cur;
	p1.id=start;
	p1.level=0;
	queue<item> q;
	q.push(p1);
	while(!q.empty())
	{
		p1=q.front();
		q.pop();
		if(p1.level==d) continue;
		for(int i=idx[p1.id]; i; i=e[i].next)
		{
			if(bl[e[i].to]==0)
			{
				belong[e[i].to]=cur;
				p2.id=e[i].to;
				p2.level=p1.level+1;
				q.push(p2);
			}
		}
	}
}
int cnt=0;
int main()
{
	scanf("%d%d%d",&n,&k,&d);
	for(int i=1; i<=k; i++)
	{
		int temp;
		scanf("%d",&temp);
		if(bl[temp]==0)
		{
			bl[temp]=1;
			p[i]=temp;
		}
		else cnt++;
	}
	for(int i=1; i<n; i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		add(a,b);
		add(b,a);
		dd1[i]=a;
		dd2[i]=b;
	}
	for(int i=1; i<=k; i++)
	{
		if(p[i])
		{
			cur=i;
			bfs(p[i]);
		}
	}
	printf("%d\n",k-1-cnt);
	int sign=0;
	for(int i=1; i<n; i++)
	{
		if(belong[dd1[i]]!=belong[dd2[i]])
		{
			if(sign==0) sign=1;
			else printf(" ");
			printf("%d",i);
		}
	}
	printf("\n");
	return 0;
}


#include<cstring>
#include<cstdio>
#include<queue>
using namespace std;
struct edge
{
	int to,next;
} e[600005];
int n,k,d;
int belong[300005];
int idx[300005];
int p[300005];
int top=0;
int dis[300005];
void add(int x,int y)
{
	top++;
	e[top].to=y;
	e[top].next=idx[x];
	idx[x]=top;
}
int dd1[300005],dd2[300005];
struct item
{
	int id;
	int level;
} p1,p2;
int cur;
int bl[300005];
void bfs(int start)
{
	dis[start]=0;
	belong[start]=cur;
	p1.id=start;
	p1.level=0;
	queue<item> q;
	q.push(p1);
	while(!q.empty())
	{
		p1=q.front();
		q.pop();
		if(p1.level==d) continue;
		for(int i=idx[p1.id]; i; i=e[i].next)
		{
			if(bl[e[i].to]==0&&1+p1.level<dis[e[i].to])
			{
				dis[e[i].to]=1+p1.level;
				belong[e[i].to]=cur;
				p2.id=e[i].to;
				p2.level=p1.level+1;
				q.push(p2);
			}
		}
	}
}
int cnt=0;
int main()
{
	memset(dis,0x3f,sizeof(dis));
	scanf("%d%d%d",&n,&k,&d);
	for(int i=1; i<=k; i++)
	{
		int temp;
		scanf("%d",&temp);
		if(bl[temp]==0)
		{
			bl[temp]=1;
			p[i]=temp;
		}
		else cnt++;
	}
	for(int i=1; i<n; i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		add(a,b);
		add(b,a);
		dd1[i]=a;
		dd2[i]=b;
	}
	for(int i=1; i<=k; i++)
	{
		if(p[i])
		{
			cur=i;
			bfs(p[i]);
		}
	}
	printf("%d\n",k-1-cnt);
	int sign=0;
	for(int i=1; i<n; i++)
	{
		if(belong[dd1[i]]!=belong[dd2[i]])
		{
			if(sign==0) sign=1;
			else printf(" ");
			printf("%d",i);
		}
	}
	printf("\n");
	return 0;
}


#include<cstring>
#include<cstdio>
#include<queue>
using namespace std;
struct edge{int to,next;}e[600005];
int n,k,d;
int belong[300005];
int idx[300005];
int p[300005];
int top=0;
void add(int x,int y)
{
	top++;
	e[top].to=y;
	e[top].next=idx[x];
	idx[x]=top;
}
int dd1[300005],dd2[300005];
struct item
{
	int id;
	int level;
}p1,p2;
void bfs(int start)
{
	p1.id=start;
	p1.level=0;
	queue<item> q;
	q.push(p1);
	while(!q.empty())
	{
		p1=q.front();
		q.pop();
		if(p1.level==d) continue;
		for(int i=idx[p1.id];i;i=e[i].next)
		{
			if(belong[e[i].to]==0)
			{
				belong[e[i].to]=belong[start];
				p2.id=e[i].to;
				p2.level=p1.level+1;
				q.push(p2);
			}
		}
	}
}
int main()
{
	scanf("%d%d%d",&n,&k,&d);
	for(int i=1;i<=k;i++) {scanf("%d",&p[i]);belong[p[i]]=i;}
	for(int i=1;i<n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		add(a,b);
		add(b,a);
		dd1[i]=a;
		dd2[i]=b;
	}
	for(int i=1;i<=k;i++)
	{
		bfs(p[i]);
	}
	printf("%d\n",k-1);
	int sign=0;
	for(int i=1;i<n;i++)
	{
		if(belong[dd1[i]]!=belong[dd2[i]])
		{
			if(sign==0) sign=1;
			else printf(" ");
			printf("%d",i);
		}
	}
	printf("\n");
	return 0;
}


#include<cstring>
#include<cstdio>
#include<queue>
using namespace std;
struct edge
{
	int to,next;
} e[600005];
int n,k,d;
int belong[300005];
int idx[300005];
int p[300005];
int top=0;
int dis[300005];
void add(int x,int y)
{
	top++;
	e[top].to=y;
	e[top].next=idx[x];
	idx[x]=top;
}
int dd1[300005],dd2[300005];
struct item
{
	int id;
	int level;
} p1,p2;
int cur;
int bl[300005];
void bfs(int start)
{
	belong[start]=cur;
	p1.id=start;
	p1.level=0;
	queue<item> q;
	q.push(p1);
	while(!q.empty())
	{
		p1=q.front();
		q.pop();
		if(p1.level==d) continue;
		for(int i=idx[p1.id]; i; i=e[i].next)
		{
			if(1+p1.level<dis[e[i].to])
			{
				dis[e[i].to]=1+p1.level;
				belong[e[i].to]=cur;
				p2.id=e[i].to;
				p2.level=p1.level+1;
				q.push(p2);
			}
		}
	}
}
int cnt=0;
inline int getint()
{
	int ret=0;
	char s;
	s=getchar();
	while(s>'9'||s<'0') s=getchar();
	while(s<='9'&&s>='0') {ret=ret*10+s-'0';s=getchar();}
	return ret;
}
int main()
{
	memset(dis,0x3f,sizeof(dis));
	n=getint();
	k=getint();
	d=getint();
	for(int i=1; i<=k; i++)
	{
		int temp;
		temp=getint();
		if(bl[temp]==0)
		{
			bl[temp]=1;
			p[i]=temp;
			dis[temp]=0;
		}
		else cnt++;
	}
	for(int i=1; i<n; i++)
	{
		int a,b;
		a=getint();
		b=getint();
		add(a,b);
		add(b,a);
		dd1[i]=a;
		dd2[i]=b;
	}
	for(int i=1; i<=k; i++)
	{
		if(p[i])
		{
			cur=i;
			bfs(p[i]);
		}
	}
	printf("%d\n",k-1-cnt);
	int sign=0;
	for(int i=1; i<n; i++)
	{
		if(belong[dd1[i]]!=belong[dd2[i]])
		{
			if(sign==0) sign=1;
			else printf(" ");
			printf("%d",i);
		}
	}
	printf("\n");
	return 0;
}


#include<cstring>
#include<cstdio>
#include<queue>
using namespace std;
struct edge{int to,next;}e[600005];
int n,k,d;
int belong[300005];
int idx[300005];
int p[300005];
int top=0;
void add(int x,int y)
{
	top++;
	e[top].to=y;
	e[top].next=idx[x];
	idx[x]=top;
}
int dd1[300005],dd2[300005];
struct item
{
	int id;
	int level;
}p1,p2;
void bfs(int start)
{
	p1.id=start;
	p1.level=0;
	queue<item> q;
	q.push(p1);
	while(!q.empty())
	{
		p1=q.front();
		q.pop();
		if(p1.level==d) continue;
		for(int i=idx[p1.id];i;i=e[i].next)
		{
			if(belong[e[i].to]==0)
			{
				belong[e[i].to]=belong[start];
				p2.id=e[i].to;
				p2.level=p1.level+1;
				q.push(p2);
			}
		}
	}
}
int cnt=0;
int main()
{
	scanf("%d%d%d",&n,&k,&d);
	for(int i=1;i<=k;i++) {scanf("%d",&p[i]);if(belong[p[i]]==0) belong[p[i]]=i;else cnt++;}
	for(int i=1;i<n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		add(a,b);
		add(b,a);
		dd1[i]=a;
		dd2[i]=b;
	}
	for(int i=1;i<=k;i++)
	{
		bfs(p[i]);
	}
	printf("%d\n",k-1-cnt);
	int sign=0;
	for(int i=1;i<n;i++)
	{
		if(belong[dd1[i]]!=belong[dd2[i]])
		{
			if(sign==0) sign=1;
			else printf(" ");
			printf("%d",i);
		}
	}
	printf("\n");
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <vector>
#include <stack>
#include <string>

using namespace std;
typedef pair<int,int> Pair;
map<Pair,int> rode;
int vis[300000+5];
int main()
{    int n,k,d;
      cin>>n>>k>>d;
      queue<int> G;
      vector<int> GC[300000+5];
      int dis[300000+5];
      memset(dis,0,sizeof(dis));
      memset(vis,0,sizeof(vis));
      int a;
      int g=k;
       while(k--)
       {
            scanf("%d",&a);
            //cout<<a<<"VVVVVVVVVVVVVVVX";
            G.push(a);
            dis[a]=0;
            vis[a]=1;
       }
       int c=n-1;
       int x,s;
       int t=0;
       while(c--)
       {    t++;
           scanf("%d%d",&x,&s);
           Pair A;
           A=make_pair(x,s);
           rode[A]=t;
           A=make_pair(s,x);
           rode[A]=t;
           GC[x].push_back(s);
           GC[s].push_back(x);
       }
       while(G.size()!=0)
       {
           int f=G.front();
           //cout<<f<<"hhhhhhhhhhhhhhhhhhhh";
           G.pop();
           for(int i=0;i<GC[f].size();i++)
           {
               if(vis[GC[f][i]]==0)
                   {
                    dis[GC[f][i]]=dis[f]+1;
                   vis[GC[f][i]]=1;
                   G.push(GC[f][i]);
                   //cout<<f<<"CCCCCCCCCCCCCCCCC"<<endl;
               }
           }
       }
       //for(int k=1;k<=n;k++)
        //cout<<dis[k]<<' ';
       vector<int> de;
       for(int i=0;i<n;i++)
       {    int first=1;
           for(int ic=0;ic<GC[i].size();ic++)
           {   Pair F;
                 F=make_pair(i,GC[i][ic]);
               if(dis[i]==dis[GC[i][ic]]&&rode[F]!=0)
                {Pair F;
                 F=make_pair(i,GC[i][ic]);
                  de.push_back(rode[F]);
                  rode[F]=0;
                  //cout<<"DDDDDDDDDDDDD";
                  F=make_pair(GC[i][ic],i);
                  rode[F]=0;
                }
                else if(dis[i]==dis[GC[i][ic]]+1&&first==0&&rode[F]!=0)
                {Pair F;
                 F=make_pair(i,GC[i][ic]);
                  de.push_back(rode[F]);
                  rode[F]=0;
                  //cout<<"SSSSSSSSSSSSSS";
                  F=make_pair(GC[i][ic],i);
                  rode[F]=0;
                }
                if(dis[i]==dis[GC[i][ic]]+1)
                    first=0;

           }
       }
       cout<<g-1<<endl;
       for(int i=0;i<de.size();i++)
        cout<<de[i]<<' ';
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <string>

using namespace std;
typedef pair<int,int> Pair;
map<Pair,int> rode;
int vis[300000+5];
  vector<int> GC[300000+5];
   int dis[300000+5];
int main()
{    int n,k,d;
      cin>>n>>k>>d;
      queue<int> G;

      memset(dis,0,sizeof(dis));
      memset(vis,0,sizeof(vis));
      int a;
      int gg=0;
      set<int> cs;
       while(k--)
       {
            scanf("%d",&a);
            //cout<<a<<"VVVVVVVVVVVVVVVX";
            G.push(a);
            if(cs.count(a))
                ;
            else
                {gg++;
            cs.insert(a);}
            dis[a]=0;
            vis[a]=1;
       }
       int c=n-1;
       int x,s;
       int t=0;
       while(c--)
       {    t++;
           scanf("%d%d",&x,&s);
           Pair A;
           A=make_pair(x,s);
           rode[A]=t;
           A=make_pair(s,x);
           rode[A]=t;
           GC[x].push_back(s);
           GC[s].push_back(x);
       }
       while(G.size()!=0)
       {
           int f=G.front();
           //cout<<f<<"hhhhhhhhhhhhhhhhhhhh";
           G.pop();
           for(int i=0;i<GC[f].size();i++)
           {
               if(vis[GC[f][i]]==0)
                   {
                    dis[GC[f][i]]=dis[f]+1;
                   vis[GC[f][i]]=1;
                   G.push(GC[f][i]);
                   //cout<<f<<"CCCCCCCCCCCCCCCCC"<<endl;
               }
           }
       }
       //for(int k=1;k<=n;k++)
        //cout<<dis[k]<<' ';
       vector<int> de;
       for(int i=0;i<n;i++)
       {    int first=1;
           for(int ic=0;ic<GC[i].size();ic++)
           {   Pair F;
                 F=make_pair(i,GC[i][ic]);
               if(dis[i]==dis[GC[i][ic]]&&rode[F]!=0)
                {Pair F;
                 F=make_pair(i,GC[i][ic]);
                  de.push_back(rode[F]);
                  rode[F]=0;
                  //cout<<"DDDDDDDDDDDDD";
                  F=make_pair(GC[i][ic],i);
                  rode[F]=0;
                }
                else if(dis[i]==dis[GC[i][ic]]+1&&first==0&&rode[F]!=0)
                {Pair F;
                 F=make_pair(i,GC[i][ic]);
                  de.push_back(rode[F]);
                  rode[F]=0;
                  //cout<<"SSSSSSSSSSSSSS";
                  F=make_pair(GC[i][ic],i);
                  rode[F]=0;
                }
                if(dis[i]==dis[GC[i][ic]]+1)
                    first=0;

           }
       }
       cout<<gg<<endl;
       for(int i=0;i<de.size();i++)
        cout<<de[i]<<' ';
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <vector>
#include <stack>
#include <string>

using namespace std;
typedef pair<int,int> Pair;
map<Pair,int> rode;
int vis[300000+5];
int main()
{    int n,k,d;
      cin>>n>>k>>d;
      queue<int> G;
      vector<int> GC[300000+5];
      int dis[300000+5];
      memset(dis,0,sizeof(dis));
      memset(vis,0,sizeof(vis));
      int a;
       while(k--)
       {

            scanf("%d",&a);
            //cout<<a<<"VVVVVVVVVVVVVVVX";
            G.push(a);
            dis[a]=0;
            vis[a]=1;
       }
       int c=n-1;
       int x,s;
       int t=0;
       while(c--)
       {    t++;
           scanf("%d%d",&x,&s);
           Pair A;
           A=make_pair(x,s);
           rode[A]=t;
           A=make_pair(s,x);
           rode[A]=t;
           GC[x].push_back(s);
           GC[s].push_back(x);
       }
       while(G.size()!=0)
       {
           int f=G.front();
           //cout<<f<<"hhhhhhhhhhhhhhhhhhhh";
           G.pop();
           for(int i=0;i<GC[f].size();i++)
           {
               if(vis[GC[f][i]]==0)
                   {
                    dis[GC[f][i]]=dis[f]+1;
                   vis[GC[f][i]]=1;
                   G.push(GC[f][i]);
                   //cout<<f<<"CCCCCCCCCCCCCCCCC"<<endl;
               }
           }
       }
       //for(int k=1;k<=n;k++)
        //cout<<dis[k]<<' ';
       vector<int> de;
       for(int i=0;i<n;i++)
       {    int first=1;
           for(int ic=0;ic<GC[i].size();ic++)
           {   Pair F;
                 F=make_pair(i,GC[i][ic]);
               if(dis[i]==dis[GC[i][ic]]&&rode[F]!=0)
                {Pair F;
                 F=make_pair(i,GC[i][ic]);
                  de.push_back(rode[F]);
                  rode[F]=0;
                  //cout<<"DDDDDDDDDDDDD";
                  F=make_pair(GC[i][ic],i);
                  rode[F]=0;
                }
                else if(dis[i]==dis[GC[i][ic]]+1&&first==0&&rode[F]!=0)
                {Pair F;
                 F=make_pair(i,GC[i][ic]);
                  de.push_back(rode[F]);
                  rode[F]=0;
                  //cout<<"SSSSSSSSSSSSSS";
                  F=make_pair(GC[i][ic],i);
                  rode[F]=0;
                }
                if(dis[i]==dis[GC[i][ic]]+1)
                    first=0;

           }
       }
       cout<<de.size()<<endl;
       for(int i=0;i<de.size();i++)
        cout<<de[i]<<' ';
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <vector>
#include <stack>
#include <string>

using namespace std;
typedef pair<int,int> Pair;
map<Pair,int> rode;
int vis[100000];
int main()
{    int n,k,d;
      cin>>n>>k>>d;
      queue<int> G;
      vector<int> GC[100000];
      int dis[100000];
      memset(dis,0,sizeof(dis));
      memset(vis,0,sizeof(vis));
      int a;
       while(k--)
       {
            scanf("%d",&a);
            //cout<<a<<"VVVVVVVVVVVVVVVX";
            G.push(a);
            dis[a]=0;
            vis[a]=1;
       }
       int c=n-1;
       int x,s;
       int t=0;
       while(c--)
       {    t++;
           scanf("%d%d",&x,&s);
           Pair A;
           A=make_pair(x,s);
           rode[A]=t;
           A=make_pair(s,x);
           rode[A]=t;
           GC[x].push_back(s);
           GC[s].push_back(x);
       }
       while(G.size()!=0)
       {
           int f=G.front();
           //cout<<f<<"hhhhhhhhhhhhhhhhhhhh";
           G.pop();
           for(int i=0;i<GC[f].size();i++)
           {
               if(vis[GC[f][i]]==0)
                   {
                    dis[GC[f][i]]=dis[f]+1;
                   vis[GC[f][i]]=1;
                   G.push(GC[f][i]);
                   //cout<<f<<"CCCCCCCCCCCCCCCCC"<<endl;
               }
           }
       }
       //for(int k=1;k<=n;k++)
        //cout<<dis[k]<<' ';
       vector<int> de;
       for(int i=0;i<n;i++)
       {    int first=1;
           for(int ic=0;ic<GC[i].size();ic++)
           {   Pair F;
                 F=make_pair(i,GC[i][ic]);
               if(dis[i]==dis[GC[i][ic]]&&rode[F]!=0)
                {Pair F;
                 F=make_pair(i,GC[i][ic]);
                  de.push_back(rode[F]);
                  rode[F]=0;
                  //cout<<"DDDDDDDDDDDDD";
                  F=make_pair(GC[i][ic],i);
                  rode[F]=0;
                }
                else if(dis[i]==dis[GC[i][ic]]+1&&first==0&&rode[F]!=0)
                {Pair F;
                 F=make_pair(i,GC[i][ic]);
                  de.push_back(rode[F]);
                  rode[F]=0;
                  cout<<"SSSSSSSSSSSSSS";
                  F=make_pair(GC[i][ic],i);
                  rode[F]=0;
                }
                if(dis[i]==dis[GC[i][ic]]+1)
                    first=0;

           }
       }
       cout<<de.size()<<endl;
       for(int i=0;i<de.size();i++)
        cout<<de[i]<<' ';
    return 0;
}


#include <iostream>
#include <cstdio>
#include <set>
#include <cstring>
#include <map>
#include <queue>
#include <vector>
#include <stack>
#include <string>

using namespace std;
typedef pair<int,int> Pair;
map<Pair,int> rode;
int vis[300000+5];
int main()
{    int n,k,d;
      cin>>n>>k>>d;
      queue<int> G;
      vector<int> GC[300000+5];
      int dis[300000+5];
      memset(dis,0,sizeof(dis));
      memset(vis,0,sizeof(vis));
      int a;
      set<int>  cs;
      int gg=0;
       while(k--)
       {
            scanf("%d",&a);
            //cout<<a<<"VVVVVVVVVVVVVVVX";
            G.push(a);
            if(cs.count(a))
                ;
            else
                {gg++;
            cs.insert(a);}
            dis[a]=0;
            vis[a]=1;
       }
       int c=n-1;
       int x,s;
       int t=0;
       while(c--)
       {    t++;
           scanf("%d%d",&x,&s);
           Pair A;
           A=make_pair(x,s);
           rode[A]=t;
           A=make_pair(s,x);
           rode[A]=t;
           GC[x].push_back(s);
           GC[s].push_back(x);
       }
       while(G.size()!=0)
       {
           int f=G.front();
           //cout<<f<<"hhhhhhhhhhhhhhhhhhhh";
           G.pop();
           for(int i=0;i<GC[f].size();i++)
           {
               if(vis[GC[f][i]]==0)
                   {
                    dis[GC[f][i]]=dis[f]+1;
                   vis[GC[f][i]]=1;
                   G.push(GC[f][i]);
                   //cout<<f<<"CCCCCCCCCCCCCCCCC"<<endl;
               }
           }
       }
       //for(int k=1;k<=n;k++)
        //cout<<dis[k]<<' ';
       vector<int> de;
       for(int i=0;i<n;i++)
       {    int first=1;
           for(int ic=0;ic<GC[i].size();ic++)
           {   Pair F;
                 F=make_pair(i,GC[i][ic]);
               if(dis[i]==dis[GC[i][ic]]&&rode[F]!=0)
                {Pair F;
                 F=make_pair(i,GC[i][ic]);
                  de.push_back(rode[F]);
                  rode[F]=0;
                  //cout<<"DDDDDDDDDDDDD";
                  F=make_pair(GC[i][ic],i);
                  rode[F]=0;
                }
                else if(dis[i]==dis[GC[i][ic]]+1&&first==0&&rode[F]!=0)
                {Pair F;
                 F=make_pair(i,GC[i][ic]);
                  de.push_back(rode[F]);
                  rode[F]=0;
                  //cout<<"SSSSSSSSSSSSSS";
                  F=make_pair(GC[i][ic],i);
                  rode[F]=0;
                }
                if(dis[i]==dis[GC[i][ic]]+1)
                    first=0;

           }
       }
       cout<<gg<<endl;
       for(int i=0;i<de.size();i++)
        cout<<de[i]<<' ';
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <string>

using namespace std;
typedef pair<int,int> Pair;
map<Pair,int> rode;
int vis[300000+5];
  vector<int> GC[300000+5];
   int dis[300000+5];
int main()
{    int n,k,d;
      cin>>n>>k>>d;
      queue<int> G;

      memset(dis,0,sizeof(dis));
      memset(vis,0,sizeof(vis));
      int a;
      set<int> cs;
      int gg=0;
       while(k--)
       {
            scanf("%d",&a);
            //cout<<a<<"VVVVVVVVVVVVVVVX";
            G.push(a);
            if(cs.count(a))
                ;
            else
                {gg++;
            cs.insert(a);}
            dis[a]=0;
            vis[a]=1;
       }
       int c=n-1;
       int x,s;
       int t=0;
       while(c--)
       {    t++;
           scanf("%d%d",&x,&s);
           Pair A;
           A=make_pair(x,s);
           rode[A]=t;
           A=make_pair(s,x);
           rode[A]=t;
           GC[x].push_back(s);
           GC[s].push_back(x);
       }
       while(G.size()!=0)
       {
           int f=G.front();
           //cout<<f<<"hhhhhhhhhhhhhhhhhhhh";
           G.pop();
           for(int i=0;i<GC[f].size();i++)
           {
               if(vis[GC[f][i]]==0)
                   {
                    dis[GC[f][i]]=dis[f]+1;
                   vis[GC[f][i]]=1;
                   G.push(GC[f][i]);
                   //cout<<f<<"CCCCCCCCCCCCCCCCC"<<endl;
               }
           }
       }
       //for(int k=1;k<=n;k++)
        //cout<<dis[k]<<' ';
       vector<int> de;
       for(int i=0;i<n;i++)
       {    int first=1;
           for(int ic=0;ic<GC[i].size();ic++)
           {   Pair F;
                 F=make_pair(i,GC[i][ic]);
               if(dis[i]==dis[GC[i][ic]]&&rode[F]!=0)
                {Pair F;
                 F=make_pair(i,GC[i][ic]);
                  de.push_back(rode[F]);
                  rode[F]=0;
                  //cout<<"DDDDDDDDDDDDD";
                  F=make_pair(GC[i][ic],i);
                  rode[F]=0;
                }
                else if(dis[i]==dis[GC[i][ic]]+1&&first==0&&rode[F]!=0)
                {Pair F;
                 F=make_pair(i,GC[i][ic]);
                  de.push_back(rode[F]);
                  rode[F]=0;
                  //cout<<"SSSSSSSSSSSSSS";
                  F=make_pair(GC[i][ic],i);
                  rode[F]=0;
                }
                if(dis[i]==dis[GC[i][ic]]+1)
                    first=0;

           }
       }
       cout<<gg-1<<endl;
       for(int i=0;i<de.size();i++)
        cout<<de[i]<<' ';
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <vector>
#include <stack>
#include <string>

using namespace std;
typedef pair<int,int> Pair;
map<Pair,int> rode;
int vis[300000+5];
int main()
{    int n,k,d;
      cin>>n>>k>>d;
      queue<int> G;
      vector<int> GC[300000+5];
      int dis[300000+5];
      memset(dis,0,sizeof(dis));
      memset(vis,0,sizeof(vis));
      int a;
      set<int> cs
       while(k--)
       {
            scanf("%d",&a);
            //cout<<a<<"VVVVVVVVVVVVVVVX";
            G.push(a);
            if(cs.count(a))
                ;
            else
                {gg++;
            cs.push_back(a);}
            dis[a]=0;
            vis[a]=1;
       }
       int c=n-1;
       int x,s;
       int t=0;
       while(c--)
       {    t++;
           scanf("%d%d",&x,&s);
           Pair A;
           A=make_pair(x,s);
           rode[A]=t;
           A=make_pair(s,x);
           rode[A]=t;
           GC[x].push_back(s);
           GC[s].push_back(x);
       }
       while(G.size()!=0)
       {
           int f=G.front();
           //cout<<f<<"hhhhhhhhhhhhhhhhhhhh";
           G.pop();
           for(int i=0;i<GC[f].size();i++)
           {
               if(vis[GC[f][i]]==0)
                   {
                    dis[GC[f][i]]=dis[f]+1;
                   vis[GC[f][i]]=1;
                   G.push(GC[f][i]);
                   //cout<<f<<"CCCCCCCCCCCCCCCCC"<<endl;
               }
           }
       }
       //for(int k=1;k<=n;k++)
        //cout<<dis[k]<<' ';
       vector<int> de;
       for(int i=0;i<n;i++)
       {    int first=1;
           for(int ic=0;ic<GC[i].size();ic++)
           {   Pair F;
                 F=make_pair(i,GC[i][ic]);
               if(dis[i]==dis[GC[i][ic]]&&rode[F]!=0)
                {Pair F;
                 F=make_pair(i,GC[i][ic]);
                  de.push_back(rode[F]);
                  rode[F]=0;
                  //cout<<"DDDDDDDDDDDDD";
                  F=make_pair(GC[i][ic],i);
                  rode[F]=0;
                }
                else if(dis[i]==dis[GC[i][ic]]+1&&first==0&&rode[F]!=0)
                {Pair F;
                 F=make_pair(i,GC[i][ic]);
                  de.push_back(rode[F]);
                  rode[F]=0;
                  //cout<<"SSSSSSSSSSSSSS";
                  F=make_pair(GC[i][ic],i);
                  rode[F]=0;
                }
                if(dis[i]==dis[GC[i][ic]]+1)
                    first=0;

           }
       }
       cout<<gg-1<<endl;
       for(int i=0;i<de.size();i++)
        cout<<de[i]<<' ';
    return 0;
}