#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

template<typename Weight_>
struct WeightedTo {
	typedef int Vertex; typedef Weight_ Weight;
	Vertex to; Weight w;
	WeightedTo() { }
	WeightedTo(Vertex to_, Weight w_): to(to_), w(w_) { }
	Weight getWeight() const { return w; }
};
template<typename To_>
struct StaticGraph {
	typedef To_ To;
	typedef typename To::Vertex Vertex;
	typedef std::pair<Vertex,To> Edge;
	typedef const To *const_iterator;
 
	void init(int n_, const std::vector<Edge> &edges) {
		n = n_; int m = edges.size();
		tos.resize(m+1); offsets.resize(n+1);
		for(int e = 0; e < m; e ++) offsets[edges[e].first] ++;
		for(int v = 1; v <= n_; v ++) offsets[v] += offsets[v-1];
		for(int e = 0; e < m; e ++)
			tos[-- offsets[edges[e].first]] = edges[e].second;
	}
	int numVertices() const { return n; }
	int numEdges() const { return tos.size() - 1; }
 
	inline const_iterator edgesBegin(int v) const { return &tos[offsets[v]]; }
	inline const_iterator edgesEnd(int v) const { return &tos[offsets[v+1]]; }
private:
	int n;
	std::vector<To> tos;
	std::vector<int> offsets;
};


template<typename Value, typename Compare = std::less<Value>, typename Index = int>
class BinaryHeap {
	Compare cmp;
	vector<Value> a;
	vector<Index> idx, nodeidx;
	int pos;

public:
	BinaryHeap(Compare cmp_ = Compare()): cmp(cmp_) { }
	BinaryHeap(int n, Compare cmp_ = Compare()): cmp(cmp_) { init(n); }

	void init(int n) {
		a.resize(n+1);
		idx.assign(n+1, -1);
		nodeidx.assign(n+1, -1);
		pos = 1;
	}

	const Value &min() const { return a[1]; }
	const Value &get(Index i) const { return a[nodeidx[i]]; }
	Index argmin() const { return idx[1]; }
	Index size() const { return pos - 1; }
	bool empty() const { return pos == 1; }

	const Value &add(Index i, const Value &x) {
		Index node = nodeidx[i];
		if(node >= 0) return a[node];
		a[pos] = x;
		idx[pos] = i;
		nodeidx[i] = pos;
		++ pos;
		up(pos-1);
		return x;
	}

	const Value &update(Index i, const Value &x) {
		Index node = nodeidx[i];
		if(node < 0) {
			a[pos] = x;
			idx[pos] = i;
			nodeidx[i] = pos;
			++ pos;
			up(pos-1);
		}else {
			a[node] = x;
			up(node);
			down(node);
		}
		return x;
	}

	const Value &updatemin(Index i, const Value &x) {
		Index node = nodeidx[i];
		if(node >= 0 && !cmp(x, a[node])) return a[node];
		else return update(i, x);
	}

	const Value remove(Index i) {
		if(i < 0) return Value();
		Index node = nodeidx[i];
		if(node < 0) return Value();
		-- pos;
		idx[node] = idx[pos];
		nodeidx[idx[pos]] = node;
		nodeidx[i] = -1;
		idx[pos] = -1;
		swap(a[pos], a[node]);
		up(node);
		down(node);
		return a[pos];
	}

private:
	void up(Index i) {
		for(Index c = i, p = c >> 1; p > 0 && cmp(a[c], a[p]); c >>= 1, p >>= 1) {
			swap(a[p], a[c]);
			swap(nodeidx[idx[p]], nodeidx[idx[c]]);
			swap(idx[p], idx[c]);
		}
	}

	void down(Index i) {
		Index bottom = pos;
		for(Index c = i; c * 2 < bottom; ) {
			Index b = c * 2 + (c * 2 + 1 < bottom && cmp(a[c * 2 + 1], a[c * 2]));
			if(!cmp(a[b], a[c])) break;
			swap(a[c], a[b]);
			swap(nodeidx[idx[c]], nodeidx[idx[b]]);
			swap(idx[c], idx[b]);
			c = b;
		}
	}
};

template<typename Dist, typename Graph>
void dijkstra(const Graph &g, int s, vector<Dist> &dist) {
	int n = g.numVertices();
	dist.assign(n, numeric_limits<Dist>::max());
	vector<bool> vis(n);
	BinaryHeap<Dist> h(n);
	h.add(s, 0);
	while(!h.empty()) {
		int v = h.argmin(); Dist d = h.min();
		dist[v] = d;
		h.remove(v);
		vis[v] = true;
		for(typename Graph::const_iterator it = g.edgesBegin(v), et = g.edgesEnd(v); it != et; ++ it) {
			if(!vis[it->to])
				h.updatemin(it->to, d + it->getWeight());
		}
	}
}

int main() {
	typedef WeightedTo<int> To;
	typedef StaticGraph<To> Graph;
	int N, M, K, start;
	scanf("%d%d%d%d", &N, &M, &K, &start), -- start;
	vector<Graph::Edge> edges;
	rep(i, M) {
		int x, y, w;
		scanf("%d%d%d", &x, &y, &w), -- x, -- y;
		edges.push_back(Graph::Edge(x, Graph::To(y, w)));
		edges.push_back(Graph::Edge(y, Graph::To(x, w)));
	}
	vector<int> roll(N, -1);
	rep(i, K) {
		int s, t;
		scanf("%d%d", &s, &t), -- s, -- t;
		roll[s] = i;
		roll[t] = K + i;
	}
	roll[start] = K * 2;
	int V = K * 2 + 1;
	vi vertices(V, -1);
	rep(i, N) if(roll[i] != -1)
		vertices[roll[i]] = i;
	Graph g; g.init(N, edges);
	vector<vector<int> > dist(V, vector<int>());
	rep(i, V)
		dijkstra(g, vertices[i], dist[i]);
	vector<vi> dp(1 << (K*2), vi(V, INF));
	dp[0][K * 2] = 0;
	rep(i, 1 << (K*2)) rep(j, V) {
		int x = dp[i][j];
		if(x == INF) continue;
//		cerr << i << ", " << vertices[j]+1 << ": " << x << endl;
		rep(k, K) if((~i >> k & 1) && dist[j][vertices[k]] < INF)
			amin(dp[i | 1 << k][k], x + dist[j][vertices[k]]);
		rep(k, K) if((i >> k & 1) && (~i >> (K+k) & 1) && dist[j][vertices[K+k]] < INF)
			amin(dp[i | 1 << (K+k)][K+k], x + dist[j][vertices[K+k]]);
	}
	int ans = INF;
	rep(j, V)
		amin(ans, dp[(1 << (K*2))-1][j]);
	if(ans == INF)
		puts("Cannot deliver");
	else
		printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1528