import scala.io.StdIn._
object Main extends App {
  val s = readLine.trim
  val Array(q, a, b) = readLine.trim.split(' ').map(_.toLong)
  val replacer = Replacer(Array.fill(q.toInt){
    val Array(from, to) = readLine.trim.split(' ')
    (from.head, to)
  }:_*)
  val replaced = replacer.replaced(s)
  println(if (b <= replaced.length) replaced.substring(a - 1, b) else ".")
}

sealed trait Replacer {
  def replaced(char: Char): ReplacedString
  def replaced(str: String): ReplacedString = ReplacedString.Succ(str, this)
}
object Replacer {
  import ReplacedString.{Succ, Empty, Replaced, Id}
  case class Replace(from: Char, to: String) extends Replacer {
    private val replaced = if (to == "") Empty else Replaced(to)
    override def replaced(char: Char): ReplacedString = if (char == from) replaced else Id(char)
  }
  case class :>>:(head: Replace, tail: Replacer) extends Replacer {
    private val map = ('a' to 'z').map(c ⇒ (if (c == head.from) Succ(head.to, tail) else tail.replaced(c)))
    override def replaced(char: Char): ReplacedString = map(char - 'a')
  }
  def apply(replace: (Char, String)*): Replacer = {
    replace.map{
      case (c, ".") ⇒ Replace(c, "")
      case (c, r) ⇒ Replace(c, r)
    }.reduceRight(:>>:)
  }
}
sealed trait ReplacedString {
  val length: Long
  def substring(from: Long, until: Long): String = appendReversedString(from, until).reverse.mkString
  private[this] def appendReversedString(from: Long, until: Long): List[Char] = {
    var (currentFrom, currentUntil, list, stack) = shallowAppend(from, until, Nil, Nil)
    while (currentUntil > 0) {
      stack match {
        case (head::Nil)::rest ⇒
          val (f, u, l, s) = head.shallowAppend(currentFrom, currentUntil, list, rest)
          currentFrom = f
          currentUntil = u
          list = l
          stack = s
        case (head::tail)::rest ⇒
          val (f, u, l, s) = head.shallowAppend(currentFrom, currentUntil, list, tail::rest)
          currentFrom = f
          currentUntil = u
          list = l
          stack = s
        case _ ⇒ ???
      }
    }
    list
  }
  protected def shallowAppend(from: Long, until: Long, prev: List[Char], stack: List[List[ReplacedString]]): (Long, Long, List[Char], List[List[ReplacedString]])
}
object ReplacedString {
  object Empty extends ReplacedString {
    override val length: Long = 0
    override def shallowAppend(from: Long, until: Long, prev: List[Char], stack: List[List[ReplacedString]]): (Long, Long, List[Char], List[List[ReplacedString]]) = (from, until, prev, stack)
  }
  case class Id(char: Char) extends ReplacedString {
    override val length: Long = 1
    override protected def shallowAppend(from: Long, until: Long, prev: List[Char], stack: List[List[ReplacedString]]): (Long, Long, List[Char], List[List[ReplacedString]]) = {
      if ((from until until).contains(0L)) (from - 1L, until - 1L, char::prev, stack)
      else (from - 1L, until - 1L, prev, stack)
    }
  }
  case class Replaced(str: String) extends ReplacedString {
    override val length: Long = str.length
    override protected def shallowAppend(from: Long, until: Long, prev: List[Char], stack: List[List[ReplacedString]]): (Long, Long, List[Char], List[List[ReplacedString]]) = {
      if (from < str.length && 0 < until) (from - length, until - length, (math.max(0, from.toInt) until math.min(str.length, until.toInt)).foldLeft(prev){case (acc, r) ⇒ str(r)::acc}, stack)
      else (from - length, until - length, prev, stack)
    }
  }
  object Succ {
    def apply(from: String, replacer: Replacer): ReplacedString = {
      val replaced = from.map(replacer.replaced).filter(_.length != 0).toList
      if (replaced.isEmpty) Empty
      else if (replaced.length == 1) replaced.head
      else {
        val length = replaced.map(_.length).foldLeft(Some(0L): Option[Long]){case (acc, len) ⇒ acc.map(_ + len).filter(_ <= 1000000000000000000L)}.getOrElse(1000000000000000001L)
        new Succ(replaced, length)
      }
    }
  }
  class Succ(private val replaced: List[ReplacedString], override val length: Long) extends ReplacedString {
    override protected def shallowAppend(from: Long, until: Long, prev: List[Char], stack: List[List[ReplacedString]]): (Long, Long, List[Char], List[List[ReplacedString]]) = {
      if (length <= from || until <= 0) (from - length, until - length, prev, stack)
      else if (length != 0) (from, until, prev, replaced::stack)
      else (from, until, prev, stack)
    }
  }
}


Measured memory_bytes: 535344