

object Main extends App{

  import scala.io.StdIn.readLine
  val n = readLine().toInt
  val player1= readLine().split(' ').map(_.toInt).tail.groupBy(it => it)
  val player2 = readLine().split(' ').map(_.toInt).tail.groupBy(it => it)
  val player3 = readLine().split(' ').map(_.toInt).tail.groupBy(it => it)
  val kosaka = new PokerFacePlayer(player1.count{case (k, v) => v.length % 2 == 1}, player1.exists{case (k, v) => k == 0})
  val sonoda = new WeekPlayer(player2.count{case (k, v) => v.length % 2 == 1}, player2.exists{case (k, v) => k == 0})
  val minami = new PokerFacePlayer(player3.count{case (k, v) => v.length % 2 == 1}, player3.exists{case (k, v) => k == 0})
  val memo = Array.tabulate(101){_ => Array.tabulate(101){_ => Array.tabulate(101){_ => Array.tabulate(3){_ => -1d}}}}
  println(f(GameState(kosaka, sonoda, minami), memo))
  def f(gameState:GameState, memo:Array[Array[Array[Array[Double]]]]):Double = {
    if (gameState.IsSonodaWin) 1d
    else if (gameState.IsSonodaLose) 0d
    else {
      if (memo(gameState.Kosaka.CardNum)(gameState.Sonoda.CardNum)(gameState.Minami.CardNum)(gameState.PlayerHasJoker.toInt) < 0) {
        val next = gameState.Next().flatMap {
          case (gsSonoda, probSondoa) => gsSonoda.Next().flatMap {
            case (gsMinami, probMinami) => gsMinami.Next().map {
              case (gsKosaka, probKosaka) => (gsKosaka, probSondoa * probMinami * probKosaka)
            }
          }
        }
        val same = next.filter {
          case (gs, prob) => gs == gameState
        }.map { case (_, prob) => prob }.fold(0d) { case (a, b) => a + b }
        val diff = next.filter {
          case (gs, prob) => gs != gameState
        }.map { case (gs, prob) => f(gs, memo) * prob }.fold(0d) { case (a, b) => a + b }
        memo(gameState.Kosaka.CardNum)(gameState.Sonoda.CardNum)(gameState.Minami.CardNum)(gameState.PlayerHasJoker.toInt) = diff / (1 + same)
      }
      memo(gameState.Kosaka.CardNum)(gameState.Sonoda.CardNum)(gameState.Minami.CardNum)(gameState.PlayerHasJoker.toInt)
    }
  }
}
sealed trait Player{
  override def equals(obj: scala.Any): Boolean = obj match{
    case p:Player => CardNum == p.CardNum && HasJoker == p.HasJoker
    case _ => false
  }
  val CardNum:Int
  val HasJoker:Boolean
  def IsWin:Boolean = CardNum == 0
  def NumOfNumberCard:Double = CardNum - (if (HasJoker) 1 else 0)
  def Draw(drawer:Player, theOther:Player):List[(DrawType, Double)]
  def AddCard(drawType: DrawType):Player = {
    drawType match{
      case Joker => Copy(CardNum + 1, true)
      case MakePair => Copy(CardNum - 1, HasJoker)
      case NoPair => Copy(CardNum + 1, HasJoker)
      case _ => this
    }
  }
  def SubCard(drawType: DrawType):Player = {
    drawType match{
      case Joker => Copy(CardNum - 1, false)
      case NoCard => this
      case _ => Copy(CardNum - 1, HasJoker)
    }
  }
  protected def Copy(cardNum: Int, hasJoker:Boolean):Player
}
class PokerFacePlayer(val CardNum:Int, val HasJoker:Boolean) extends Player{
  override def Draw(drawer: Player, theOther: Player): List[(DrawType, Double)] = {
    val allType = (CardNum + drawer.CardNum + theOther.CardNum) / 2
    val canMakePairType = allType - theOther.NumOfNumberCard
    val cantMakePairType = NumOfNumberCard - canMakePairType
    (MakePair, canMakePairType / CardNum)::(NoPair, cantMakePairType / CardNum)::(if (HasJoker) (Joker, 1d / CardNum)::Nil else Nil)
  }
  override protected def Copy(cardNum: Int, hasJoker: Boolean): Player = new PokerFacePlayer(cardNum, hasJoker)
}
class WeekPlayer(val CardNum:Int, val HasJoker:Boolean) extends Player {
  override def Draw(drawer: Player, theOther: Player): List[(DrawType, Double)] = {
    val allType = (CardNum + drawer.CardNum + theOther.CardNum) / 2
    val canMakePairType = allType - theOther.NumOfNumberCard
    if (canMakePairType > 0) (MakePair, 1d)::Nil
    else if (NumOfNumberCard > 0) (NoPair, 1d)::Nil
    else (Joker, 1d)::Nil
  }
  override protected def Copy(cardNum: Int, hasJoker: Boolean): Player = new WeekPlayer(cardNum, hasJoker)
}
case class GameState(val Kosaka:Player, val Sonoda:Player, val Minami:Player, val Turn:PlayerName = PKosaka){
  assert(Turn != null)
  override def equals(obj: scala.Any): Boolean = obj match{
    case gs:GameState => Kosaka == gs.Kosaka && Sonoda == gs.Sonoda && Minami == gs.Minami && Turn == gs.Turn
    case _ => false
  }
  def PlayerHasJoker:PlayerName =
    if (Kosaka.HasJoker) PKosaka
    else if (Sonoda.HasJoker) PSonoda
    else PMinami
  def IsSonodaWin:Boolean = Sonoda.IsWin
  def IsSonodaLose:Boolean = Kosaka.IsWin && Minami.IsWin
  def Next():List[(GameState, Double)] = {
    if (IsSonodaWin || IsSonodaLose) (GameState(Kosaka, Sonoda, Minami, Turn.next), 1d)::Nil
    else {
      Turn match{
        case PKosaka =>
          if (Kosaka.IsWin) (GameState(Kosaka, Sonoda, Minami, Turn.next), 1d)::Nil
          else if (Minami.IsWin) Sonoda.Draw(Kosaka, Minami).map{case (t, d) => (GameState(Kosaka.AddCard(t), Sonoda.SubCard(t), Minami, Turn.next), d)}
          else Minami.Draw(Kosaka, Sonoda).map{case (t, d) => (GameState(Kosaka.AddCard(t), Sonoda, Minami.SubCard(t), Turn.next), d)}
        case PSonoda =>
          if (Sonoda.IsWin) (GameState(Kosaka, Sonoda, Minami, Turn.next), 1d)::Nil
          else if (Kosaka.IsWin) Minami.Draw(Sonoda, Kosaka).map{case (t, d) => (GameState(Kosaka, Sonoda.AddCard(t), Minami.SubCard(t), Turn.next), d)}
          else Kosaka.Draw(Sonoda, Minami).map{case (t, d) => (GameState(Kosaka.SubCard(t), Sonoda.AddCard(t), Minami, Turn.next), d)}
        case PMinami =>
          if (Minami.IsWin) (GameState(Kosaka, Sonoda, Minami, Turn.next), 1d)::Nil
          else if (Sonoda.IsWin) Kosaka.Draw(Minami, Sonoda).map{case (t, d) => (GameState(Kosaka.SubCard(t), Sonoda, Minami.AddCard(t), Turn.next), d)}
          else Sonoda.Draw(Minami, Kosaka).map{case (t, d) => (GameState(Kosaka, Sonoda.SubCard(t), Minami.AddCard(t), Turn.next), d)}
      }
    }
  }
}
sealed trait DrawType
object Joker extends DrawType
object MakePair extends DrawType
object NoPair extends DrawType
object NoCard extends DrawType
sealed trait PlayerName{
  val toInt:Int
  val next:PlayerName
}
object PKosaka extends PlayerName {
  override val toInt: Int = 0
  override val next: PlayerName = PSonoda
}
object PSonoda extends PlayerName {
  override val toInt: Int = 1
  override val next: PlayerName = PMinami
}
object PMinami extends PlayerName {
  override val toInt: Int = 2
  override val next: PlayerName = PKosaka
}
