I have two dataframes of the form:
Table 1

```
sid   student_details
1      A
2      B
3      C

```

Table 2

```
did   dept_details
    4      E
    5      F
    6      G

```

Table 3:

```
sid    did
1    5
3    4
2    6

```

Now how to join dataframe1 and dataframe2 according to dataframe3 in pandas?