def __init__(self, mapping, inv_mapping, l_edges, r_edges, s2_edges,
                 s3_edges):
        N = len(s2_edges)
        ss2 = [None] * len(s2_edges)
        ss3 = [None] * len(s3_edges)
        ll = [None] * len(l_edges)
        rr = [None] * len(r_edges)
        for i in range(N):
            ss2[s2_edges[i]] = i
            ss3[s3_edges[i]] = i
            ll[l_edges[i]] = i
            rr[r_edges[i]] = i

        if mapping[0].is_orientation_cover():
            self._veech_group = EvenArithmeticSubgroup_Permutation(
                ss2, ss3, ll, rr)
        else:
            self._veech_group = OddArithmeticSubgroup_Permutation(
                ss2, ss3, ll, rr)
        self._l_edges = l_edges
        self._li_edges = ll
        self._r_edges = r_edges
        self._ri_edges = rr
        self._s2_edges = s2_edges
        self._s2i_edges = ss2
        self._s3_edges = s3_edges
        self._s3i_edges = ss3

        self._mapping = mapping
        self._inv_mapping = inv_mapping
    def as_permutation_group(self):
        r"""
        Return self as an arithmetic subgroup defined in terms of the
        permutation action of `SL(2,\ZZ)` on its right cosets.

        This method uses Todd-Coxeter enumeration (via the method
        :meth:`~todd_coxeter`) which can be extremely slow for arithmetic
        subgroups with relatively large index in `SL(2,\ZZ)`.

        EXAMPLES::

            sage: G = Gamma(3)
            sage: P = G.as_permutation_group(); P
            Arithmetic subgroup of index 24
            sage: G.ncusps() == P.ncusps()
            True
            sage: G.nu2() == P.nu2()
            True
            sage: G.nu3() == P.nu3()
            True
            sage: G.an_element() in P
            True
            sage: P.an_element() in G
            True
        """
        _, _, l_edges, s2_edges = self.todd_coxeter()
        n = len(l_edges)
        s3_edges = [None] * n
        r_edges = [None] * n
        for i in xrange(n):
            ii = s2_edges[l_edges[i]]
            s3_edges[ii] = i
            r_edges[ii] = s2_edges[i]
        if self.is_even():
            from sage.modular.arithgroup.arithgroup_perm import EvenArithmeticSubgroup_Permutation
            g = EvenArithmeticSubgroup_Permutation(S2=s2_edges,
                                                   S3=s3_edges,
                                                   L=l_edges,
                                                   R=r_edges)
        else:
            from sage.modular.arithgroup.arithgroup_perm import OddArithmeticSubgroup_Permutation
            g = OddArithmeticSubgroup_Permutation(S2=s2_edges,
                                                  S3=s3_edges,
                                                  L=l_edges,
                                                  R=r_edges)
        g.relabel()
        return g
    def as_permutation_group(self):
        r"""
        Return self as an arithmetic subgroup defined in terms of the
        permutation action of `SL(2,\ZZ)` on its right cosets.

        This method uses Todd-Coxeter enumeration (via the method
        :meth:`~todd_coxeter`) which can be extremely slow for arithmetic
        subgroups with relatively large index in `SL(2,\ZZ)`.

        EXAMPLES::

            sage: G = Gamma(3)
            sage: P = G.as_permutation_group(); P
            Arithmetic subgroup of index 24
            sage: G.ncusps() == P.ncusps()
            True
            sage: G.nu2() == P.nu2()
            True
            sage: G.nu3() == P.nu3()
            True
            sage: G.an_element() in P
            True
            sage: P.an_element() in G
            True
        """
        _, _, l_edges, s2_edges = self.todd_coxeter()
        n = len(l_edges)
        s3_edges = [None] * n
        r_edges = [None] * n
        for i in xrange(n):
            ii = s2_edges[l_edges[i]]
            s3_edges[ii] = i
            r_edges[ii] = s2_edges[i]
        if self.is_even():
            from sage.modular.arithgroup.arithgroup_perm import EvenArithmeticSubgroup_Permutation
            g = EvenArithmeticSubgroup_Permutation(
                S2=s2_edges, S3=s3_edges, L=l_edges, R=r_edges)
        else:
            from sage.modular.arithgroup.arithgroup_perm import OddArithmeticSubgroup_Permutation
            g = OddArithmeticSubgroup_Permutation(
                S2=s2_edges, S3=s3_edges, L=l_edges, R=r_edges)
        g.relabel()
        return g