Market allocation where it is impossible for some parties

  Market failure, as a common economic problem, exists when markets allocate resources in a Pareto-inefficient way. There are several types of market failure, among which negative externalities are an important one. Negative externalities, which refer to external costs in production or consumption, result from incomplete contracts. In order to reduce and even eliminate them, government intervention is required. Possible remedies provided by the government include regulation, tradable permits, taxation, and extending property rights followed by Coasean bargaining.
  Free markets under perfect competition theoretically allocate resources in a Pareto-efficient way by market mechanism. Nevertheless, due to various reasons, markets may and often fail. Pareto optimality, an allocation where it is impossible for some parties to be better off without others being worse off, occurs when markets are in equilibrium ( clears). Graphical representation of equilibrium is the point where supply curve intercepts demand curve. 
At the point, social welfare is maximised. Through market mechanism, or what Adam Smith described as ‘invisible hand’, market equilibrium is achieved. Thus, when economic conditions alter, markets response accordingly. Nonetheless, markets may fail to allocate resources efficiently due to various reasons and welfare losses ensue.
  Externalities are third-party effects which affect people who are neither the buyers nor the sellers in the transaction. It exists when decision-makers do not take full account of the effects that their actions exert on society(i.e.themselves and others). There are two types of externalities, namely positive externalities and negative externalities. Positive externalities occurs when marginal social benefits are greater than marginal private benefits. As illustrated in the graph, there will be under-consumption of the good. 
Negative externalities exist when marginal social costs are greater than marginal private costs, leading to overproduction of the good. 
Positive externalities are associated with public goods whilst negative externalities in itself is a form of market failure.
  Negative externalities, or sometimes spillover effects, result in Pareto-inefficiency and therefore lead to market failure. Negative externalities are external costs inflicted on others  who do not participate in the transactions. Hence, marginal external cost is the difference between marginal social cost and marginal private cost. For Pareto efficiency to be established, production should take place at the point where marginal benefits equal marginal social costs. However, in practice, producers will produce the good at the point where marginal benefits equal marginal private costs since they do not acknowledge or ignore the external costs. Thus, markets do not function at socially optimal level. The ensuing welfare loss for a single producer are represented by the shaded area in the graph. 
In a free market characterised by perfect competition, a firm is a price taker. Hence the price at which they can sell their products is constant. Each additional unit produced beyond Q2 up to Q1