How does government spending on imported goods affect GDP? How does government spending on imported goods affect GDP?

Is it first counted as government spending and then subtracted as imports? 

For instance, if the US government buy a new accounting system from overseas, how would this affect the US GDP?
Recall the definition of GDP that it is the aggregate value of all goods and services produced within the domestic territory.

The concept of domestic territory is central here. Only those government expenditures that creates a domestic income is counted in GDP.

For instance, if US government gives economic aid to a poor African country it will not be a part of US GDP, although it is a government expenditure.

In the same way the government expenditure on imports does not create any domestic income hence the value of imports will be subtracted from the GDP without any complementary addition.