The key to resolving the impasse over immigration in Congress is getting the middle behind a deal — not the center of Congress overall, but rather the members of each party who are closest to the ideological center of their party. That won’t be easy. Looking at the bipartisan deal reached on the budget last week provides a possible path, but it’s probably a path that would involve angering those both on the right and the left of the immigration debate, making passing legislation fairly hard.

The roadblocks are clear. The Senate this week is starting formal consideration on immigration legislation. It’s not clear what bill, if any, will be approved by the Senate because there are at least three factions on immigration in that chamber alone: Senate Democrats, who basically just want legislation that extends the work permits and protection from deportation that was in President Obama’s Deferred Action for Childhood Arrivals program; a group of Senate Republicans like Arizona’s Jeff Flake who are also broadly supportive of DACA; and Republicans like Arkansas Sen. Tom Cotton who argue that any immigration bill creating a DACA law should also include new limits on family-based immigration.

Senate Majority Leader Mitch McConnell has left open the possibility of a bill emerging from the Senate even if a majority of the chamber’s Republicans don’t back it.

The House is expected to hold a vote on immigration. But House Speaker Paul Ryan has hinted that he will not move forward on an immigration bill if it does not have the backing of the majority of House Republicans and has explicitly said any bill that he brings to the House floor must have the support of President Trump. That’s a much more narrow path than in the Senate, raising the possibility that — just as in 2013 — a Senate-passed immigration bill will die in the House.

So how could an immigration bill pass? I’m not sure the exact parameters of a bill that will satisfy all of these competing constituencies. So I’ll be watching the details of the legislation, but just as importantly, I’ll be watching the coalitions in Congress.

We just saw a two-year budget deal approved by both chambers and signed into law by Trump that calls for increased spending on some Democratic priorities (infrastructure, health care, etc.) and some things Republicans wanted (namely, defense). Immigration is obviously a different issue than the budget. But it’s worth looking at the vote count from last week as a guide to how bipartisan bills are approved in the current political environment.

First, let’s look at who voted against that deal: the leaders of the conservative House Freedom Caucus, more liberal Democrats in the House, several Senate Democrats considering running for president in 2020 and some of the more iconoclastic Republicans in the Senate (like Kentucky’s Rand Paul).

Who was in favor of the bill? In the House: 167 Republicans (a clear majority of the party’s 238-member caucus) along with 67 Democrats. In the Senate: 36 Democrats and 34 Republicans — an almost perfectly balanced bipartisan coalition.

That seems like the best bet for immigration, too. In other words, here’s what I think is not the path: the Senate’s 49 Democrats joining with about a dozen Republicans to pass a bill. There may be a dozen Republicans who would sign on to a Democrat-led bill for a DACA-style provision that includes increased border security funding. Indeed, getting to 12 might not even be all that hard, between more pro-immigration figures like Flake and South Carolina’s Lindsey Graham; senators not running in a future GOP primary, like Flake and Tennessee Sen. Bob Corker; and those from more left-leaning states like Maine’s Susan Collins and Colorado’s Cory Gardner. But legislation with that kind of Democratic skew in the Senate — whatever the contents of the bill — is going to be viewed skeptically by Trump and the House.

Instead, in order to bring Trump and the House along, the Senate would likely have to put together a bill that drew a more balanced coalition. Such legislation would likely be opposed by Republicans like Cotton (who would feel it does not have enough immigration limits) but also liberal Democrats like California’s Kamala Harris (who would feel it includes too many more conservative provisions).

Who would vote in favor of this kind of compromise? Probably Democrats Mark Warner and Tim Kaine of Virginia but also Republicans like Tennessee’s Lamar Alexander and Missouri’s Roy Blunt, all of whom backed the budget deal. Those four are not leading figures in either party on immigration policy but rather veteran politicians who might be willing to vote for some kind of compromise on this issue.

In the House, getting to a majority of Republicans (so about 120) means getting support for the bill beyond the most liberal Republicans, or the 23 electorally vulnerable Republicans representing districts won by Hillary Clinton in 2016. Getting something like 67 Democrats (the number who voted for the government funding bill last week) requires Democratic support beyond the 12 members who represent districts that Trump won.

I suspect Trump will have a hard time opposing legislation that passes with strong bipartisan majorities in both houses of Congress. It seems more likely that Ryan will advance a bill only if Trump views it favorably, and that most Republican senators will be leery of backing legislation that the president strongly opposes.

Policy matters here, of course, but maybe only in a broad sense. Immigration isn’t a dry budgetary matter; it’s an issue that animates partisans on both sides. No matter what the other details in the legislation are, how many Republicans in the House and Senate are willing to support a path to citizenship for more than 1 million undocumented immigrants? No matter how popular DACA recipients are, even among Republican voters, such a vote by a GOP incumbent probably increases the chances of losing in a primary to a conservative challenger.

How many Democrats in the House and Senate are willing to back a bill including some kind of new limits on immigration that is currently legal, either through cutting back on so-called diversity visas or family-based visas? Because of Trump’s rhetoric around these issues (“shithole” African countries and “rapists” from Mexico), backing immigration limits pushed by the president is likely to be cast by Democratic activists as codifying Trump’s racism into law.

Any deal on immigration that becomes law is likely to involve some members of both parties annoying their bases. Though it may be unlikely, such a deal could happen.