[med-svn] [r-cran-phangorn] 01/07: Imported Upstream version 2.0.4

Andreas Tille tille at debian.org
Thu Jul 7 11:12:56 UTC 2016


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository r-cran-phangorn.

commit fb6f81b79563278edc3399ec8a747caca4e28a60
Author: Andreas Tille <tille at debian.org>
Date:   Thu Jul 7 13:05:04 2016 +0200

    Imported Upstream version 2.0.4
---
 DESCRIPTION                                     |   26 +-
 MD5                                             |  169 +-
 NAMESPACE                                       |   54 +-
 NEWS                                            |  110 +-
 R/Coalescent.R                                  |    2 +-
 R/Densi.R                                       |  144 +-
 R/SH.R                                          |   51 +
 R/ancestral_pml.R                               |  102 ++
 R/bootstrap.R                                   |  238 +++
 R/cladePar.R                                    |    2 +-
 R/clanistic.R                                   |   26 +-
 R/dist.p.R                                      |    2 +-
 R/distSeq.R                                     |   98 +-
 R/distTree.R                                    |   96 +-
 R/fitch.R                                       |  178 +-
 R/hadamard.R                                    |    8 +-
 R/modelTest.R                                   |   89 +-
 R/networx.R                                     |  893 +++++++---
 R/parsimony.R                                   |   76 +-
 R/phyDat.R                                      |  173 +-
 R/phylo.R                                       | 2092 ++++++++++++-----------
 R/sankoff.R                                     |   10 +-
 R/simSeq.R                                      |   12 +-
 R/treeManipulation.R                            |  286 +---
 R/treedist.R                                    |  484 +++++-
 README.md                                       |   10 +-
 TODO                                            |   15 -
 build/vignette.rds                              |  Bin 335 -> 375 bytes
 inst/doc/Ancestral.R                            |   15 +-
 inst/doc/Ancestral.Rnw                          |    1 +
 inst/doc/Ancestral.pdf                          |  Bin 237029 -> 260891 bytes
 inst/doc/IntertwiningTreesAndNetworks.R         |  123 ++
 inst/doc/IntertwiningTreesAndNetworks.Rmd       |  190 ++
 inst/doc/IntertwiningTreesAndNetworks.html      |  249 +++
 inst/doc/Networx.R                              |    9 +-
 inst/doc/Networx.Rmd                            |   40 +-
 inst/doc/Networx.html                           |  167 +-
 inst/doc/Trees.R                                |  155 +-
 inst/doc/Trees.Rnw                              |  144 +-
 inst/doc/Trees.pdf                              |  Bin 138040 -> 167890 bytes
 inst/doc/phangorn-specials.R                    |   19 +-
 inst/doc/phangorn-specials.Rnw                  |   37 +-
 inst/doc/phangorn-specials.pdf                  |  Bin 157302 -> 180115 bytes
 inst/extdata/trees/RAxML_bipartitions.woodmouse |    1 +
 inst/extdata/trees/RAxML_bootstrap.woodmouse    | 1000 +++++++++++
 inst/extdata/trees/woodmouse.fasta              |   30 +
 inst/extdata/trees/woodmouse.mrbayes.nex.con    |    9 +
 inst/extdata/trees/woodmouse.mrbayes.nex.run1.t | 1021 +++++++++++
 inst/extdata/trees/woodmouse.mrbayes.nex.run2.t | 1021 +++++++++++
 inst/extdata/trees/woodmouse.nxs                |  517 ++++++
 man/Ancestors.Rd                                |    9 +-
 man/addConfidences.Rd                           |   73 +
 man/allTrees.Rd                                 |   60 +-
 man/ancestral.pml.Rd                            |    4 +-
 man/as.splits.Rd                                |   15 +-
 man/bootstrap.pml.Rd                            |   34 +-
 man/consensusNet.Rd                             |    7 +-
 man/cophenetic.networx.Rd                       |   25 +
 man/delta.score.Rd                              |   57 +
 man/dfactorial.Rd                               |   56 +-
 man/dist.hamming.Rd                             |   31 +-
 man/dist.p.Rd                                   |    6 +-
 man/distanceHadamard.Rd                         |    4 +-
 man/lento.Rd                                    |    3 +-
 man/maxCladeCred.Rd                             |   72 +
 man/midpoint.Rd                                 |    3 +-
 man/modelTest.Rd                                |   24 +-
 man/neighborNet.Rd                              |    2 +-
 man/nni.Rd                                      |    2 +-
 man/parsimony.Rd                                |    5 +-
 man/phangorn-package.Rd                         |   84 +-
 man/phyDat.Rd                                   |   21 +-
 man/plot.networx.Rd                             |   47 +-
 man/pml.Rd                                      |   44 +-
 man/pml.fit.Rd                                  |    8 +-
 man/simSeq.Rd                                   |    2 +-
 man/superTree.Rd                                |    2 +-
 man/treedist.Rd                                 |   46 +-
 src/Makevars                                    |    4 +-
 src/dist.c                                      |    2 +-
 src/fitch.c                                     |   66 +-
 src/ml.c                                        |  331 ++--
 src/phangorn.c                                  |  111 +-
 src/sankoff.c                                   |    2 +-
 tests/testthat/test_distances.R                 |   18 +
 tests/testthat/test_parsimony.R                 |    5 +-
 tests/testthat/test_pml.R                       |   61 +
 tests/testthat/test_splits.R                    |   23 +
 tests/testthat/test_treeManipulation.R          |   35 +
 tests/testthat/test_treedist.R                  |   73 +-
 vignettes/Ancestral.Rnw                         |    1 +
 vignettes/IntertwiningTreesAndNetworks.Rmd      |  190 ++
 vignettes/Networx.Rmd                           |   40 +-
 vignettes/Trees.RData                           |  Bin 51886 -> 164438 bytes
 vignettes/Trees.Rnw                             |  144 +-
 vignettes/phangorn-specials.Rnw                 |   37 +-
 vignettes/phangorn.bib                          |  316 +++-
 97 files changed, 9830 insertions(+), 2569 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index a10e037..944dc6b 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,21 +1,29 @@
 Package: phangorn
 Title: Phylogenetic Analysis in R
-Version: 1.99.14
-Date: 2015-07-09
-Author: Klaus Schliep, Emmanuel Paradis
+Version: 2.0.4
+Date: 2016-06-20
+Authors at R: c(person("Klaus", "Schliep", email="klaus.schliep at gmail.com", role = c("aut", "cre")), 
+  person("Emmanuel", "Paradis", role = c("aut")), 
+  person("Alastair", "Potts", role = c("aut")), 
+  person("Michelle", "Kendall", email="m.kendall at imperial.ac.uk", role = c("ctb")))
 Maintainer: Klaus Schliep <klaus.schliep at gmail.com>
 Description: Phylogenetic analysis in R: Estimation of phylogenetic
         trees and networks using Maximum Likelihood, Maximum Parsimony,
         distance methods and Hadamard conjugation.
-Depends: R (>= 3.0.0), ape (>= 3.3)
-Imports: quadprog, igraph (>= 0.6), Matrix, parallel, nnls, methods,
-        utils, stats, graphics, grDevices
-Suggests: testthat, seqLogo, seqinr, xtable, flashClust, rgl, knitr
+Depends: R (>= 3.0.0), ape (>= 3.5)
+Imports: quadprog, igraph (>= 1.0), Matrix, parallel, nnls, methods,
+        utils, stats, graphics, grDevices, fastmatch
+Suggests: testthat, seqLogo, seqinr, xtable, flashClust, rgl, knitr,
+        rmarkdown, Biostrings
 ByteCompile: TRUE
 License: GPL (>= 2)
 VignetteBuilder: utils, knitr
 URL: https://github.com/KlausVigo/phangorn
 Repository: CRAN
 NeedsCompilation: yes
-Packaged: 2015-07-09 14:57:03 UTC; klaus
-Date/Publication: 2015-07-09 18:11:29
+Packaged: 2016-06-20 15:44:07 UTC; klaus
+Author: Klaus Schliep [aut, cre],
+  Emmanuel Paradis [aut],
+  Alastair Potts [aut],
+  Michelle Kendall [ctb]
+Date/Publication: 2016-06-21 08:32:40
diff --git a/MD5 b/MD5
index a2a4a4f..9156cd4 100644
--- a/MD5
+++ b/MD5
@@ -1,48 +1,53 @@
-6935e0c843976a470143b72ada3f1785 *DESCRIPTION
-2d67e088ea29f95611ee42b755b256e0 *NAMESPACE
-d091257060fa258698275d7f93abfb41 *NEWS
-115bc297835dcaab7d32527fcacb2061 *R/Coalescent.R
-874ee7c405b1384b2f04828ac27574ef *R/Densi.R
+1b369c1893556a9402077452b8e55651 *DESCRIPTION
+2552be19064d4d91f8600cfc228052bd *NAMESPACE
+d5f86a348bb7b8b442738f553682d61d *NEWS
+9441c4e1029cac2a635d71e9acad4ffb *R/Coalescent.R
+63bb6ba4ff0d5fa9c07ab8f7e014faca *R/Densi.R
+0708ebbd9a9a0ba33f932d172d01ecc6 *R/SH.R
 f916be823b9a838d49145695b0a37aa1 *R/SOWH.R
-188e8e2a81eb0c50cc6b7cda6d2c9b98 *R/cladePar.R
-5a95cd8530b05882c63f5d48073d7d3f *R/clanistic.R
-e4992df0ce2eaeb1380543eed22aa769 *R/dist.p.R
-31db0490edd334101645270e922c3341 *R/distSeq.R
-0693ec904c923ea37447ec460d2a86f7 *R/distTree.R
-ecbb9305836be819d53745855d9ab3ff *R/fitch.R
-86e1095878e3b46eca343d1804a6957e *R/hadamard.R
-75c515f0fcb9127a033df76e071eb2ca *R/modelTest.R
+8b8f9aeefc014d7ff3d0cd51077f4650 *R/ancestral_pml.R
+f0570fdfa97da0f51b063b88ce85057d *R/bootstrap.R
+089d06695316d8734e5647d50eaa2b12 *R/cladePar.R
+b308a91826087b5dfcbc2075a0cc3a90 *R/clanistic.R
+62d2375bf3497590ad11af0de6e77efa *R/dist.p.R
+857b3f1c2ad9d97648c81b20105b4d2a *R/distSeq.R
+fbf4c9f43a5cb52edf3779f125115cd9 *R/distTree.R
+cff63aa886a22f913ad0c01b53ff9fb8 *R/fitch.R
+3c0ccfb95517188a1d8f4059b7f192d2 *R/hadamard.R
+42fe926e668d07ef6aee042b4a69de95 *R/modelTest.R
 c4c58c9e35b58e21176f482fd6150002 *R/neighborNet.R
-4fbe2e2c5b83e638962921d0b75d4203 *R/networx.R
-6c4a570cf453429cfe60b3f0d23ee69b *R/parsimony.R
-7d2d79ba2ac0f697caa372f487a0f06a *R/phyDat.R
-8579b368fcf48fa7fa0ffed2daf1576b *R/phylo.R
-ef07cb79ed0ece0caa494ed7c566e17b *R/sankoff.R
-bd5ce765336904ef9fd6ee286dc42220 *R/simSeq.R
+2426acbef78a4ea50e95c20df9b64b5e *R/networx.R
+f411f2c21b87776125e0d3c510e17b26 *R/parsimony.R
+fc739a28612271d61f81d221e01a0005 *R/phyDat.R
+974b4bdd5db6a33a750f6bce183f47ed *R/phylo.R
+4832725b6e807c67398b7c25621161d8 *R/sankoff.R
+eec6086aac90ebcb9403402682295c9b *R/simSeq.R
 2b4d6884b4ee2b92e617cea76f79d3da *R/sysdata.rda
-e59cce6bb3c64d7853ce58450f92f7fb *R/treeManipulation.R
-c7639eb4e9f2d2749b4e4aa54555bc75 *R/treedist.R
+979aea186a4b879b66420ed49a25285d *R/treeManipulation.R
+39801dcd237ea83998e2ed1e82fb59b8 *R/treedist.R
 c925e4cd5ce95bf91968fc909d6eef76 *R/zzz.R
-76c6c00aad6e70113fca211f6ee04c6d *README.md
-df6481d8fdef70e63bfc09054cbb7bab *TODO
-c0bb685510ddd82f07347d07b3468cfc *build/vignette.rds
+058f733944f5c56b40167cb2f3dd29bc *README.md
+2222bf60c7d441a496a74fe403b025f4 *build/vignette.rds
 4a92b07bcd170e85bd237e460acafa93 *data/Laurasiatherian.RData
 4b269c2e640293341b9b1c04d4dd7f4e *data/chloroplast.RData
 19f84425e8caaf9f605490cdff17dd81 *data/yeast.RData
 b4d3fa3f40aae3a68846d1f28274e9a0 *inst/CITATION
 61b3722df2ead748e0db8595428412a1 *inst/README
-cd23e5801a1f3632bf0cdd76e5242279 *inst/doc/Ancestral.R
-0b18e27e3877621f05e6f78c89a0f5d2 *inst/doc/Ancestral.Rnw
-bfd8e0dfe0c57e211e4600e8221b530d *inst/doc/Ancestral.pdf
-8d18b0e4a292379ba270a7a26f4d041e *inst/doc/Networx.R
-6cf134802b4b98bb286e71f135ead8bd *inst/doc/Networx.Rmd
-80f428b2d03d8874db4e9071225057b9 *inst/doc/Networx.html
-6e9e97e846668cbf1e077067764e6283 *inst/doc/Trees.R
-e3f16cf1e79426ba67016beed7ee6011 *inst/doc/Trees.Rnw
-46d2167ad02c1ee4670cd07e6420876c *inst/doc/Trees.pdf
-1d5112656a0fe77fd68081a8a81474b9 *inst/doc/phangorn-specials.R
-6e60535c60981d4f5492b73ebf7344df *inst/doc/phangorn-specials.Rnw
-1c3fda481fca1865b5a0b6dae6667885 *inst/doc/phangorn-specials.pdf
+56efa08410f500fc3b4851b71058ad27 *inst/doc/Ancestral.R
+bf3e208e4fceec83ea3d522adb1b0272 *inst/doc/Ancestral.Rnw
+74d40684ccc50a3970cdfb50d2ad72d8 *inst/doc/Ancestral.pdf
+0862fe6de86381ba4ad9c8d1b4b02198 *inst/doc/IntertwiningTreesAndNetworks.R
+af3eb8b8f4e4512cb5e22c8cec8538eb *inst/doc/IntertwiningTreesAndNetworks.Rmd
+7a58319240ce93cc06c335f3237b7a0d *inst/doc/IntertwiningTreesAndNetworks.html
+d24a83a2803108ede87eff4de3c13ae8 *inst/doc/Networx.R
+4d2150a5608862c1eff7000e4096e44c *inst/doc/Networx.Rmd
+9f24fa87e64cd7ef1056fa34b0d5d0d7 *inst/doc/Networx.html
+1effe50d23f90af16c248d52ddedda58 *inst/doc/Trees.R
+5aa283308c069783e018a708a19c6439 *inst/doc/Trees.Rnw
+6119d31f15debb53dda3436a6acbdcb6 *inst/doc/Trees.pdf
+ef0fbc15af66dff9fb288de1abbf8901 *inst/doc/phangorn-specials.R
+25becba1a0c2b64b7166f0b5eb72c4f2 *inst/doc/phangorn-specials.Rnw
+8aab7335a82edfd290c74b4a6c911efc *inst/doc/phangorn-specials.pdf
 3009f9da02a198cb557d435cc5ad8c7f *inst/extdata/Blosum62.dat
 72f496d4c6e937ffe744d25bd8891313 *inst/extdata/Dayhoff.dat
 5aa357dab0e72b27023e4302bc37dbad *inst/extdata/FLU.dat
@@ -59,66 +64,82 @@ ddc4bd45521cd72848aaf2f79b90ac6e *inst/extdata/lg.dat
 917303a3df098f9137c651de0afa78fa *inst/extdata/mtArt.dat
 1cd5e39670b86d32b5fe5c27dcc79648 *inst/extdata/mtREV24.dat
 0ca0d0e987fcebf847a876779eddd934 *inst/extdata/mtmam.dat
+2212d49c7269978890887be3686c12f9 *inst/extdata/trees/RAxML_bipartitions.woodmouse
+000df141b844795d38e5a755aa360f97 *inst/extdata/trees/RAxML_bootstrap.woodmouse
+129e8c41182f3557b1b9911625e100b9 *inst/extdata/trees/woodmouse.fasta
+421488c1ce8687879f64a350fca6d055 *inst/extdata/trees/woodmouse.mrbayes.nex.con
+d83fc4958acba1f1d0ca4092393c5b3d *inst/extdata/trees/woodmouse.mrbayes.nex.run1.t
+e185a8c9c7aed17a3e216cb78d517fd4 *inst/extdata/trees/woodmouse.mrbayes.nex.run2.t
+01399608c5cc2927ebed0659ac78863d *inst/extdata/trees/woodmouse.nxs
 87fa1533c4dfe7074237cfa2196bcbeb *inst/extdata/wag.dat
-985da8b17504af26eff230a7160f208e *man/Ancestors.Rd
+3f0079d336b3fd0bc1209681ce725421 *man/Ancestors.Rd
 bda5669b71de975e1309d909c495b71f *man/Laurasiatherian.Rd
 4d6fb151c28a597eadc0d4ec2c59a504 *man/NJ.Rd
 5dd84777963b553e8c89bddc951b17c8 *man/SH.test.Rd
 b3418f878911164dd974046f0492c79c *man/SOWH.test.Rd
-6403c950d8f9700d3fe1c847970461ef *man/allTrees.Rd
-2c88d4ded0156a68c44cee9e8fc290b4 *man/ancestral.pml.Rd
-52ca504c035177a8ac1dbe43fc8e90d5 *man/as.splits.Rd
+0ad5edc3e25f1b6bb10c816e8b866320 *man/addConfidences.Rd
+7e03e8af0658fc2b19d1e51b0fad7a26 *man/allTrees.Rd
+c7080f03a162f87e0c700028bd699516 *man/ancestral.pml.Rd
+9f8c3cdeffbbbdc184680e0b797cfca2 *man/as.splits.Rd
 3b53888e5f37fd54344286a9175d8dc2 *man/bab.Rd
-1a6c4849b1cd2c672e93ad940d1e8652 *man/bootstrap.pml.Rd
+7c2aead89db45adc53a75fbecb93e90e *man/bootstrap.pml.Rd
 22ad0ef60c2edd8b3d003f170f2fa15a *man/chloroplast.Rd
 4361615c7d1dc7beb8a4e6118505423c *man/cladePar.Rd
-8d3c6fd646d8a64e29dc79791692a388 *man/consensusNet.Rd
+5befa0cf9c4edc213566b3f60f8838ed *man/consensusNet.Rd
+55baf4b98181f03c2c1489a98d504e2d *man/cophenetic.networx.Rd
+c090d7ec936738daaea76e99f1f9bab0 *man/delta.score.Rd
 5868068eb5f8be4302c0c3caadd25943 *man/densiTree.Rd
 f44e43abbbf7707821627c8e88f6e9fa *man/designTree.Rd
-924c4e906042d64ac4fc4907af8c6cf1 *man/dfactorial.Rd
-da8a199fb9669c127cedfc3e58a650ad *man/dist.hamming.Rd
-e7e01cc12be2fac182ff773826ad286f *man/dist.p.Rd
-4f8fa46c2cf1f904d1b85f35fc4db884 *man/distanceHadamard.Rd
+b888d59a2b1fe266b098544b8ac86eed *man/dfactorial.Rd
+1e97d5bbdae42152778a84aff952a8cd *man/dist.hamming.Rd
+c240de2acabd4c5ccec785a09d21608c *man/dist.p.Rd
+789d097683def6234f407e69cc3ee9b2 *man/distanceHadamard.Rd
 72abceeb247f22b3da6560df0c20468a *man/getClans.Rd
 c1cacff95f20b574c03126d3f8e24106 *man/hadamard.Rd
-9c306689d9d7cd539d8d1055b35e24a2 *man/lento.Rd
-f24a38210a0e90d3241e27514a6f5b8a *man/midpoint.Rd
-0d51482b4a6375d72d220b80a667f917 *man/modelTest.Rd
-5a825bb21eeef78dccf760a5ee0aca26 *man/neighborNet.Rd
-94cd3c21e4dd4a6919db7fde5146a711 *man/nni.Rd
-f1ffe19a44e661d78c1bff049213d230 *man/parsimony.Rd
-06d3770fff0d07f19393875735cfa004 *man/phangorn-package.Rd
-71f4c68026c05fc0467f8d2366e629de *man/phyDat.Rd
-d7eac237d2e8950f6aca364bdc349542 *man/plot.networx.Rd
-cb484368c04bf20d286dedf974c83da1 *man/pml.Rd
-f8182027284ceba292fc437e87af3fad *man/pml.fit.Rd
+f8cf4238c40481ee6c09cc935fc07f12 *man/lento.Rd
+734851dec63f4aab42447cd0e31b4641 *man/maxCladeCred.Rd
+a4d9197a0880a1d6b12d2e9371d5cd53 *man/midpoint.Rd
+a7d146d4074b23c6ceb162f602f2a669 *man/modelTest.Rd
+7c85721291853f713eac8637c358f7a5 *man/neighborNet.Rd
+4dcf6f133fbbc6c0e3e43413d33ea3f7 *man/nni.Rd
+974c5df5eec7ea710deffd027a37e43e *man/parsimony.Rd
+ad095b45d2e89f45bc9938857c0bbe6d *man/phangorn-package.Rd
+40aabd33c9dc2db426fd36fe2cc61cf5 *man/phyDat.Rd
+fa86e2334aabf74dcdc7fd15ce78bbb4 *man/plot.networx.Rd
+ddc71ef3ac07e482ef2c97bff7cb1e97 *man/pml.Rd
+7aeb801f22ae8c8f712052e432ebf564 *man/pml.fit.Rd
 9506d15a81467d18f40bb4741b3d9d28 *man/pmlCluster.Rd
 8b06bdee57c510a690ea04b40bac4844 *man/pmlMix.Rd
 ff67d17fa29bf88cea645905334c5ecc *man/pmlPart.Rd
 bfc83a71d7de4e1c0b994b8b9c853439 *man/read.aa.Rd
-eaadcb69db59ca4c512eeb6258013714 *man/simSeq.Rd
+ae8bb6597edcdb96eeb86b5367cc4d5f *man/simSeq.Rd
 2e7848b9bac018bde56302f70066a49a *man/splitsNetwork.Rd
-2614e984b5c5aa40d9364d3542172654 *man/superTree.Rd
-9f0dd1accd30d7b177038b787d3a3296 *man/treedist.Rd
+2abee82ad55769e4bf99f0a2f0dc102e *man/superTree.Rd
+345fb2ad0be13f59ee5de23ccc3b60ae *man/treedist.Rd
 64399c9fb7fb25d103c25aa925ab7a10 *man/upgma.Rd
 b97649fe8b91a0632a1ded89a6f43125 *man/yeast.Rd
-9a8672b7759d360a54c251d1866b3e05 *src/Makevars
-56d140fd1f0fceb9031c4ad70dfb96f1 *src/dist.c
-c658fdd18a82e58979b0105e0747e8b3 *src/fitch.c
-63c45a73f83920a12ab7f921555a5e11 *src/ml.c
-a573d9543f40a6a32c5af7c14ad8993a *src/phangorn.c
+9a8d913f59a18a676121ea930cbe958f *src/Makevars
+c73230a47eefd569a5a63e6b2e43b736 *src/dist.c
+fc069fca9f2d8216cd6f7f458af13721 *src/fitch.c
+36ec67f90b9d4d79ddca24440c56b099 *src/ml.c
+e79d2a91b347507dccb722295db682ef *src/phangorn.c
 d8e5c864aa0b122ce426a67479d3a610 *src/read_aa.c
-fb760099aedbfcf9df0e638780df4cf3 *src/sankoff.c
+ebbc6aa310a27020920560e78f71ad72 *src/sankoff.c
 7d1eaef831fb2372b367f5be1b0a5790 *tests/testthat.R
-ee456463a48eac9fb661c9b0b00f8aba *tests/testthat/test_parsimony.R
+85915294ad9354b55ae10dd2f00ea595 *tests/testthat/test_distances.R
+ee0d53cf5ddd4840ec6649eef91b2df7 *tests/testthat/test_parsimony.R
 3b6b3635995a131b5beb515ae2897e28 *tests/testthat/test_phyDat.R
-a2f72d835a2eb1ad694dc19f1f48242f *tests/testthat/test_treedist.R
-0b18e27e3877621f05e6f78c89a0f5d2 *vignettes/Ancestral.Rnw
-6cf134802b4b98bb286e71f135ead8bd *vignettes/Networx.Rmd
-9608eda76927e9438fa12a63ef8692cd *vignettes/Trees.RData
-e3f16cf1e79426ba67016beed7ee6011 *vignettes/Trees.Rnw
+9e246e3c61392cb3d4fcd76669e237e3 *tests/testthat/test_pml.R
+feb64ac20ca2b3749fe89fd5cb4d3863 *tests/testthat/test_splits.R
+9d0145ac2a13bcb4f1f4099e25d8cb45 *tests/testthat/test_treeManipulation.R
+b6a732e1ab1ab285f66aca5a22720039 *tests/testthat/test_treedist.R
+bf3e208e4fceec83ea3d522adb1b0272 *vignettes/Ancestral.Rnw
+af3eb8b8f4e4512cb5e22c8cec8538eb *vignettes/IntertwiningTreesAndNetworks.Rmd
+4d2150a5608862c1eff7000e4096e44c *vignettes/Networx.Rmd
+a8250afd3b341e6c3f889e9454d5bc5f *vignettes/Trees.RData
+5aa283308c069783e018a708a19c6439 *vignettes/Trees.Rnw
 6af5f4d4c2e93469cc19d46a97ab5d0f *vignettes/exdna.txt
 1ca8b1d97a011a9d0ecd9630d548dfb3 *vignettes/movie.gif
-6e60535c60981d4f5492b73ebf7344df *vignettes/phangorn-specials.Rnw
-baba59abae9999be96bcc36d17793385 *vignettes/phangorn.bib
+25becba1a0c2b64b7166f0b5eb72c4f2 *vignettes/phangorn-specials.Rnw
+d8f77ef2f47f4ca67f5e3e85ae952f12 *vignettes/phangorn.bib
 d3069d1eff9e70bed655b8962bf4ee2b *vignettes/primates.dna
diff --git a/NAMESPACE b/NAMESPACE
index 9f83d9a..76a1ded 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -2,44 +2,60 @@ useDynLib(phangorn, .registration=TRUE)
 
 importFrom(ape, as.DNAbin, as.phylo, plot.phylo, as.prop.part, nj,old2new.phylo, dist.dna,
     new2old.phylo, cophenetic.phylo, is.rooted, unroot, root, is.binary.tree, as.alignment,
-    di2multi, multi2di, .uncompressTipLabel, .compressTipLabel, prop.part, 
+    di2multi, multi2di, .uncompressTipLabel, .compressTipLabel, prop.part, Ntip,
     postprocess.prop.part, speciesTree, plotPhyloCoor, cladogram.plot, phylogram.plot,
     node.depth.edgelength, drop.tip, stree, rtree, is.ultrametric, .PlotPhyloEnv,
     nodelabels, edgelabels, BOTHlabels, read.nexus.data, write.nexus.data, 
-    read.dna, write.dna, reorder.phylo, dist.nodes, collapse.singles, rotate)
-importFrom(igraph, graph, graph.adjacency, layout.kamada.kawai, plot.igraph,
-    get.shortest.paths, set.edge.attribute, vcount, graph.edgelist, topological.sort) 
+    read.dna, write.dna, reorder.phylo, dist.nodes, collapse.singles, rotate, prop.clades,
+    fastme.bal, fastme.ols, Nnode, image.DNAbin, ONEwise)
+# as.AAbin, as.phyDat.AAbin, image.AAbin
+importFrom(igraph, graph, graph_from_adjacency_matrix, layout_with_kk, plot.igraph,
+    shortest_paths, set.edge.attribute, set_edge_attr, decompose, components, groups,
+    vcount, graph.edgelist, graph_from_edgelist, topo_sort) 
+#layout.kamada.kawai, graph.adjacency, get.shortest.paths, topological.sort,
+
+
+
 importFrom(Matrix, Matrix, sparseMatrix, spMatrix, crossprod, solve) #, %*%
-#importFrom(fastmatch, fmatch)
+importFrom(fastmatch, fmatch)
 importFrom(nnls, nnls)
-importFrom(parallel, mclapply)
+#importFrom(parallel, mclapply, detectCores)
+import(parallel)
 importFrom(quadprog, solve.QP, solve.QP.compact)
 #importFrom(rgl, open3d, segments3d, spheres3d, rgl.texts)
-#importFrom(Rcpp, evalCpp)
-importFrom(stats, AIC, logLik, reorder, update, optim, optimize, constrOptim, na.omit, 
+importFrom(stats, AIC, BIC, logLik, reorder, update, optim, optimize, constrOptim, na.omit, 
            cophenetic, hclust, as.dist, pchisq, reshape, qgamma, pgamma, model.matrix,
-           aggregate, lm.fit, xtabs, quantile) 
+           aggregate, lm.fit, xtabs, quantile, sd) 
 importFrom(graphics, plot.new, plot.window, text, par, plot, abline, strwidth, axis, title, segments, 
            points, image, matplot, legend, hist) 
-importFrom(utils, read.table, download.file, citation, stack, installed.packages, write.table) 
-importFrom(grDevices, rgb, rainbow, adjustcolor)
+importFrom(utils, read.table, download.file, citation, stack, installed.packages, write.table, combn) 
+importFrom(grDevices, rgb, rainbow, adjustcolor, col2rgb)
 importFrom(methods, hasArg)
+#importFrom(Rcpp, evalCpp)
+#importMethodsFrom(Biostrings,as.matrix)
+#importFrom(Biostrings,DNAMultipleAlignment)
+#importFrom(Biostrings,RNAMultipleAlignment)
+#importFrom(Biostrings,AAMultipleAlignment)
+
 
 export(pml, optim.pml, pml.control, parsimony, optim.parsimony, pratchet, NJ, UNJ, PNJ, 
     phyDat, cbind.phyDat, read.phyDat, write.phyDat, as.Matrix, as.phyDat, as.splits, as.networx,
     dfactorial, ldfactorial, hadamard, nni, allSitePattern, allSplits, fhm, 
     distanceHadamard, treedist, sankoff, fitch, h2st, h4st, dist.logDet, dist.hamming, 
-    dist.ml, dist.p, upgma, wpgma, write.nexus.splits, read.nexus.splits, write.splits, pmlPart, 
+    dist.ml, dist.p, upgma, wpgma, write.nexus.splits, read.nexus.splits,
+    read.nexus.networx, write.nexus.networx, write.splits, pmlPart, 
     pmlCluster, pmlMix, pmlPen, read.aa, allTrees, designTree, designSplits, nnls.tree,
     nnls.splits, nnls.phylo, nnls.networx, neighborNet, pmlPart2multiPhylo,
-    splitsNetwork, simSeq, SH.test, bootstrap.pml, bootstrap.phyDat, RF.dist, rNNI, 
+    splitsNetwork, simSeq, SH.test, bootstrap.pml, bootstrap.phyDat, RF.dist, wRF.dist, 
+    KF.dist, path.dist, rNNI, 
     rSPR, plotBS, Ancestors, Descendants, mrca.phylo, Children, Siblings, pace, modelTest, 
     lento, compatible, acgt2ry, ancestral.pars, ancestral.pml, CI, RI, getClans, getSlices,
     getClips, getDiversity, midpoint, pruneTree, acctran, getRoot, plotAnc, consensusNet, 
     bab, random.addition, diversity, baseFreq, densiTree, superTree, coalSpeciesTree, 
-    pml.fit, pml.init, pml.free, edQt, lli, cladePar, addConfidences, countCycles, 
-    SOWH.test, plot.networx, presenceAbsence, as.networx.splits, addTrivialSplits,
-    phyDat2alignment, AICc, readDist, writeDist, discrete.gamma)
+    pml.fit, pml.init, pml.free, edQt, lli, cladePar, addConfidences, createLabel,
+    countCycles, SOWH.test, plot.networx, presenceAbsence, as.networx.splits, addTrivialSplits,
+    phyDat2alignment, AICc, readDist, writeDist, discrete.gamma, matchSplits,
+    removeUndeterminedSites, phyDat2MultipleAlignment, delta.score, maxCladeCred)
 
 S3method('[', splits)          
 S3method(addConfidences, phylo)
@@ -49,6 +65,7 @@ S3method(AICc, pml)
 S3method(as.character, phyDat)
 S3method(as.data.frame, phyDat)
 S3method(anova, pml)
+S3method(BIC, pml)
 S3method(c, phyDat)
 S3method(c, splits)
 S3method(cbind, phyDat)
@@ -56,11 +73,15 @@ S3method(unique, phyDat)
 S3method(as.matrix, splits)
 S3method(as.Matrix, splits) 
 S3method(as.networx, splits)
+S3method(as.networx, phylo)
 #S3method(as.igraph, networx)
 S3method(as.phyDat, DNAbin)
 S3method(as.phyDat, alignment)
 S3method(as.phyDat, data.frame)
 S3method(as.phyDat, matrix)
+S3method(as.phyDat, MultipleAlignment)
+S3method(as.MultipleAlignment, phyDat)
+#S3method(as.AAbin, phyDat) # momentan raus
 S3method(as.DNAbin, phyDat)
 S3method(as.phylo, splits)
 S3method(as.splits, phylo)
@@ -70,6 +91,7 @@ S3method(as.splits, networx)
 S3method(as.prop.part, splits)
 S3method(cophenetic, networx)
 S3method(cophenetic, splits)
+S3method(image, phyDat)
 S3method(logLik, pml)
 S3method(logLik, pmlPart)
 S3method(logLik, pmlMix)
diff --git a/NEWS b/NEWS
index a860529..aa4130a 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,112 @@
-     CHANGES in PHANGORN VERSION 1.99-14
+    CHANGES in PHANGORN VERSION 2.0.4
+     
+NEW FEATURES
+
+    o new weighted Robinson-Foulds (1979) distance wRF, suggested by Michelle Kendall
+    
+      and normalized Robinson-Foulds suggested by Sereina Rutschmann
+
+    o codon model "YN98" can be called directly, improved documentation
+
+    o bootstrap.phyDat got an new argument jumble, 
+    
+      which randomizes input order of sequences
+    
+OTHER CHANGES
+
+    o more unit tests
+    
+    
+
+     CHANGES in PHANGORN VERSION 2.0.3
+
+NEW FEATURES 
+
+    o new function maxCladeCred computing the maximum clade credibility tree
+     
+      from a sample of trees
+
+    o function read.nexus.networx and write.nexus.networx to import / export 
+    
+      phylogenetic networx to SplitsTree
+      
+    o function as.AAbin.phyDat to exchange data with the new AAbin class from ape   
+    
+    o likelihood ratchet (Vos 2003) topology optimisation in optim.pml 
+    
+    o with KF.dist (Kuhner & Felsenstein) and path.dist can be used like RF.dist  
+
+BUG FIXES
+
+    o improvements to optim.pml to avoid numerical problems, 
+    
+      can now handle much more taxa (still experimantal)
+
+OTHER CHANGES
+    
+    o mrca.phylo can be used like mrca from ape (faster for large trees)
+    
+    o individual splits can be colored in lento plots (suggested by France Thouzé)
+    
+    o plot.networx now (silently) returns a networx object with some of the graphics
+    
+      parameters, more plot options
+    
+    o lots of small changes to make handling and identifying splits, edges in 
+     
+      trees and networks easier
+
+    o plotBS has a new argument frame and arguments BStrees can be empty
+    
+    o new vignette IntertwiningTreesAndNetworks
+      
+      
+
+     CHANGES in PHANGORN VERSION 2.0.2
+
+OTHER CHANGES
+ 
+    o phangorn now suggests only the Biostrings and not depends on it
+    
+    o some improvements to bab (branch and bound), may be faster 
+    
+    
+
+     CHANGES in PHANGORN VERSION 2.0.0
+
+NEW FEATURES    
+    
+    o as.phyDat.MultipleAlignment to excange data with Biostrings
+    
+    o dist.ml can now compute distances using a discrete gamma model
+    
+      and the "F81" model.
+
+    o optim.pml got a new rearrangement argument and can now 
+    
+      use a stochastic rearrangements similar to Nguyen et al. (2015)
+
+BUG FIXES
+
+    o plotBS may double counted edges when rooted trees were in the sample 
+    
+OTHER CHANGES
+
+    o optim.pml uses more C code and should be more robust  
+
+    o more unit tests
+    
+    o baseFreq got additional parameter 'all' similar to base.freq in ape 
+    
+    o lots of little improvements in the manual and help files
+    
+    o modelTest now also shows AIC weights and model="all" will test
+    
+      all available models
+
+
+
+     CHANGES in PHANGORN VERSION 1.99.14
  
 NEW FEATURES
 
diff --git a/R/Coalescent.R b/R/Coalescent.R
index eee4a4a..f962566 100644
--- a/R/Coalescent.R
+++ b/R/Coalescent.R
@@ -22,7 +22,7 @@ ancstat = function(phy, x){
   nTips=length(phy$tip.label)
   pa=phy$edge[,1]
   ch=phy$edge[,2]
-  res[1:nTips, ] = contrast[as.numeric(x)[match(phy$tip, names(x))],, drop=FALSE]
+  res[1:nTips, ] = contrast[as.numeric(x)[match(phy$tip.label, names(x))],, drop=FALSE]
   for(i in 1:length(pa)){
     res[pa[i],] = res[pa[i],] | res[ch[i],]    
   }
diff --git a/R/Densi.R b/R/Densi.R
index be7087d..aa71547 100644
--- a/R/Densi.R
+++ b/R/Densi.R
@@ -1,8 +1,8 @@
 getAges <- function(x){  
   fun=function(x) max(node.depth.edgelength(x))  
   height=NULL
-  if(class(x)=="phylo") height <- fun(x)
-  if(class(x)=="multiPhylo"){
+  if(inherits(x,"phylo")) height <- fun(x)
+  if(inherits(x,"multiPhylo")){
     if(!is.null(attr(x, "TipLabel"))){
       x = unclass(x)
       x = .uncompressTipLabel(x)  
@@ -18,24 +18,35 @@ getAges <- function(x){
 }
 
 
+# now more memoryefficient
 # from phytools code by Liam Revell with a few changes
 my.supertree<-function(trees,method=c("pratchet","optim.parsimony"), trace=0, ...){
   # set method
   method<-method[1]
   # some minor error checking
-  if(!class(trees)=="multiPhylo") stop("trees must be object of class 'multiPhylo.'")
+  if(!inherits(trees,"multiPhylo")) stop("trees must be object of class 'multiPhylo.'")
+  
+  labels <- lapply(trees, function(x)sort(x$tip.label))
+  ulabels <- unique(labels)
+  lul <- length(ulabels)
   # compute matrix representation phylogenies
-  X<-list() # list of bipartitions
+  X<-vector("list", lul) # list of bipartitions
   characters<-0 # number of characters
-  for(i in 1:length(trees)){
-    temp<-prop.part(trees[[i]]) # find all bipartitions
+  weights <- NULL
+  species<-trees[[1]]$tip.label
+  for(i in 1:lul){
+    pos <- match(labels, ulabels[i])
+    ind <- which(!is.na(pos))  
+    temp<-prop.part(trees[ind]) # find all bipartitions
     # create matrix representation of trees[[i]] in X[[i]]
-    X[[i]]<-matrix(0,nrow=length(trees[[i]]$tip),ncol=length(temp)-1)
+    X[[i]]<-matrix(0,nrow=length(trees[[ind[1]]]$tip.label),ncol=length(temp)-1)
     for(j in 1:ncol(X[[i]])) X[[i]][c(temp[[j+1]]),j]<-1
     rownames(X[[i]])<-attr(temp,"labels") # label rows
-    if(i==1) species<-trees[[i]]$tip.label
-    else species<-union(species,trees[[i]]$tip.label) # accumulate labels
+#    if(i==1) species<-trees[[ind[1]]]$tip.label
+#    else 
+        species<-union(species,trees[[ind[1]]]$tip.label) # accumulate labels
     characters<-characters+ncol(X[[i]]) # count characters
+    weights <- c(weights, attr(temp, "number")[-1])
   }
   XX<-matrix(data="?",nrow=length(species),ncol=characters,dimnames=list(species))
   j<-1
@@ -47,12 +58,13 @@ my.supertree<-function(trees,method=c("pratchet","optim.parsimony"), trace=0, ..
   # compute contrast matrix for phangorn
   contrast<-matrix(data=c(1,0,0,1,1,1),3,2,dimnames=list(c("0","1","?"),c("0","1")),byrow=TRUE)
   # convert XX to phyDat object
-  XX<-phyDat(XX,type="USER",contrast=contrast) 
+  XX<-phyDat(XX,type="USER",contrast=contrast, compress=FALSE) 
+  attr(XX, "weight") <- weights 
   # estimate supertree
   if(method=="pratchet"){
     if(hasArg(start)){
       start<-list(...)$start
-      if(class(start)=="phylo"){
+      if(inherits(start,"phylo")){
         supertree<-pratchet(XX,all=TRUE, trace=0, ...)
       } else {
         if(start=="NJ") start<-NJ(dist.hamming(XX))
@@ -68,16 +80,16 @@ my.supertree<-function(trees,method=c("pratchet","optim.parsimony"), trace=0, ..
         supertree<-do.call(pratchet,args)
       }
     } else supertree<-pratchet(XX,all=TRUE, trace=0, ...)
-    if(class(supertree)=="phylo")
+    if(inherits(supertree,"phylo"))
       if(trace>0)message(paste("The MRP supertree, optimized via pratchet(),\nhas a parsimony score of ",
                     attr(supertree,"pscore")," (minimum ",characters,")",sep=""))
-    else if(class(supertree)=="multiPhylo")
+    else if(inherits(supertree,"multiPhylo"))
       if(trace>0)message(paste("pratchet() found ",length(supertree)," supertrees\nwith a parsimony score of ",
                     attr(supertree[[1]],"pscore")," (minimum ",characters,")",sep=""))
   } else if(method=="optim.parsimony"){
     if(hasArg(start)){
       start<-list(...)$start
-      if(class(start)=="phylo"){
+      if(inherits(start,"phylo")){
         supertree<-optim.parsimony(tree=start,data=XX, trace=0, ...)
       } else {
         if(start=="NJ") start<-NJ(dist.hamming(XX))
@@ -93,10 +105,10 @@ my.supertree<-function(trees,method=c("pratchet","optim.parsimony"), trace=0, ..
       start<-random.addition(XX) # rtree(n=length(XX),tip.label=names(XX))
       supertree<-optim.parsimony(tree=start,data=XX, trace=0, ...)
     }
-    if(class(supertree)=="phylo")
+    if(inherits(supertree,"phylo"))
       if(trace>0)message(paste("The MRP supertree, optimized via optim.parsimony(),\nhas a parsimony score of ",
                     attr(supertree,"pscore")," (minimum ",characters,")",sep=""))
-    else if(class(supertree)=="multiPhylo")
+    else if(inherits(supertree,"multiPhylo"))
       if(trace>0)message(paste("optim.parsimony() found ",length(supertree)," supertrees\nwith a parsimony score of ",
                     attr(supertree[[1]],"pscore")," (minimum ",characters,")",sep=""))
   }
@@ -104,11 +116,96 @@ my.supertree<-function(trees,method=c("pratchet","optim.parsimony"), trace=0, ..
 }
 
 
+my.supertree.Old<-function(trees,method=c("pratchet","optim.parsimony"), trace=0, ...){
+    # set method
+    method<-method[1]
+    # some minor error checking
+    if(!inherits(trees,"multiPhylo")) stop("trees must be object of class 'multiPhylo.'")
+    # compute matrix representation phylogenies
+    X<-list() # list of bipartitions
+    characters<-0 # number of characters
+    for(i in 1:length(trees)){
+        temp<-prop.part(trees[[i]]) # find all bipartitions
+        # create matrix representation of trees[[i]] in X[[i]]
+        X[[i]]<-matrix(0,nrow=length(trees[[i]]$tip.label),ncol=length(temp)-1)
+        for(j in 1:ncol(X[[i]])) X[[i]][c(temp[[j+1]]),j]<-1
+        rownames(X[[i]])<-attr(temp,"labels") # label rows
+        if(i==1) species<-trees[[i]]$tip.label
+        else species<-union(species,trees[[i]]$tip.label) # accumulate labels
+        characters<-characters+ncol(X[[i]]) # count characters
+    }
+    XX<-matrix(data="?",nrow=length(species),ncol=characters,dimnames=list(species))
+    j<-1
+    for(i in 1:length(X)){
+        # copy each of X into supermatrix XX
+        XX[rownames(X[[i]]),c(j:((j-1)+ncol(X[[i]])))]<-X[[i]][1:nrow(X[[i]]),1:ncol(X[[i]])]
+        j<-j+ncol(X[[i]])
+    }
+    # compute contrast matrix for phangorn
+    contrast<-matrix(data=c(1,0,0,1,1,1),3,2,dimnames=list(c("0","1","?"),c("0","1")),byrow=TRUE)
+    # convert XX to phyDat object
+    XX<-phyDat(XX,type="USER",contrast=contrast) 
+    # estimate supertree
+    if(method=="pratchet"){
+        if(hasArg(start)){
+            start<-list(...)$start
+            if(inherits(start,"phylo")){
+                supertree<-pratchet(XX,all=TRUE, trace=0, ...)
+            } else {
+                if(start=="NJ") start<-NJ(dist.hamming(XX))
+                else if(start=="random") start<-rtree(n=length(XX),tip.label=names(XX))
+                else {
+                    warning("do not recognize that option for start; using random starting tree")
+                    tree<-rtree(n=length(XX),tip.label=names(XX))
+                }
+                args<-list(...)
+                args$start<-start
+                args$data<-XX
+                args$all<-TRUE
+                supertree<-do.call(pratchet,args)
+            }
+        } else supertree<-pratchet(XX,all=TRUE, trace=0, ...)
+        if(inherits(supertree,"phylo"))
+            if(trace>0)message(paste("The MRP supertree, optimized via pratchet(),\nhas a parsimony score of ",
+                                     attr(supertree,"pscore")," (minimum ",characters,")",sep=""))
+        else if(inherits(supertree,"multiPhylo"))
+            if(trace>0)message(paste("pratchet() found ",length(supertree)," supertrees\nwith a parsimony score of ",
+                                     attr(supertree[[1]],"pscore")," (minimum ",characters,")",sep=""))
+    } else if(method=="optim.parsimony"){
+        if(hasArg(start)){
+            start<-list(...)$start
+            if(inherits(start,"phylo")){
+                supertree<-optim.parsimony(tree=start,data=XX, trace=0, ...)
+            } else {
+                if(start=="NJ") start<-NJ(dist.hamming(XX))
+                else if(start=="random") start<-rtree(n=length(XX),tip.label=names(XX))
+                else {
+                    warning("do not recognize that option for tree; using random starting tree")
+                    start<-rtree(n=length(XX),tip.label=names(XX))
+                }
+                supertree<-optim.parsimony(tree=start,data=XX,...)
+            }			
+        } else {
+            if(trace>0)message("no input starting tree or option for optim.parsimony; using random addition tree")
+            start<-random.addition(XX) # rtree(n=length(XX),tip.label=names(XX))
+            supertree<-optim.parsimony(tree=start,data=XX, trace=0, ...)
+        }
+        if(inherits(supertree,"phylo"))
+            if(trace>0)message(paste("The MRP supertree, optimized via optim.parsimony(),\nhas a parsimony score of ",
+                                     attr(supertree,"pscore")," (minimum ",characters,")",sep=""))
+        else if(inherits(supertree,"multiPhylo"))
+            if(trace>0)message(paste("optim.parsimony() found ",length(supertree)," supertrees\nwith a parsimony score of ",
+                                     attr(supertree[[1]],"pscore")," (minimum ",characters,")",sep=""))
+    }
+    return(supertree)
+}
+
+
 # we want a rooted supertree
-superTree = function(tree, method="optim.parsimony", rooted=TRUE, ...){
+superTree = function(tree, method="pratchet", rooted=TRUE, ...){
   fun = function(x){
     x=reorder(x, "postorder")
-    nTips = length(x$tip)
+    nTips = length(x$tip.label)
     x$edge[x$edge>nTips] = x$edge[x$edge>nTips] + 2L
     l=nrow(x$edge)
     oldroot = x$edge[l,1L]
@@ -124,7 +221,7 @@ superTree = function(tree, method="optim.parsimony", rooted=TRUE, ...){
   class(tree)="multiPhylo"
   res = my.supertree(tree, method=method, ...)
   if(rooted){
-    if(class(res)=="multiPhylo"){
+    if(inherits(res,"multiPhylo")){
       res = lapply(res, root, "ZZZ")
       res = lapply(res, drop.tip, "ZZZ")  
       class(res) = "multiPhylo"
@@ -134,7 +231,7 @@ superTree = function(tree, method="optim.parsimony", rooted=TRUE, ...){
       res = drop.tip(res, "ZZZ")  
     }
   }
-  if(class(res)=="multiPhylo"){
+  if(inherits(res,"multiPhylo")){
     fun = function(x){
       x$edge.length <- rep(.1, nrow(x$edge)) 
       x
@@ -153,12 +250,14 @@ superTree = function(tree, method="optim.parsimony", rooted=TRUE, ...){
 
 
 densiTree <- function(x, type="cladogram", alpha=1/length(x), consensus=NULL, optim=FALSE, scaleX=FALSE, col=1, width=1, cex=.8, ...) {
-  if(class(x)!="multiPhylo")stop("x must be of class multiPhylo")
+  if(!inherits(x,"multiPhylo"))stop("x must be of class multiPhylo")
   compressed <- ifelse(is.null(attr(x, "TipLabel")), FALSE, TRUE)
   if(is.null(consensus))consensus <- superTree(x)
+  if(inherits(consensus,"multiPhylo")) consensus = consensus[[1]]
+  type <- match.arg(type, c("phylogram", "cladogram"))
   consensus = reorder(consensus, "postorder")
   e2 = reorder(consensus)$edge[,2]
-  nTip = as.integer(length(consensus$tip))
+  nTip = as.integer(length(consensus$tip.label))
   tiporder = e2[e2<=nTip]   
   maxBT = max(getAges(x))
   if(scaleX) maxBT=1.0
@@ -175,6 +274,7 @@ densiTree <- function(x, type="cladogram", alpha=1/length(x), consensus=NULL, op
   tip.order = yy[1:nTip]
   for (treeindex in 1:length(x)) {
     tmp <- reorder(x[[treeindex]], "postorder")
+    if(!compressed) tip.order <- match(tmp$tip.label, consensus$tip.label)
     xy <- plotPhyloCoor(tmp, tip.order=tiporder, ...)
     xx = xy[,1]
     yy = xy[,2]
diff --git a/R/SH.R b/R/SH.R
new file mode 100644
index 0000000..9a8652c
--- /dev/null
+++ b/R/SH.R
@@ -0,0 +1,51 @@
+SH.test <- function (..., B = 10000, data = NULL)
+{
+    fits <- list(...)
+    p = 1
+    if (inherits(fits[[1]],"pmlPart"))
+        #       class(fits[[1]]) == "pmlPart") 
+    {
+        fits = fits[[1]]$fits
+        p = length(fits)
+    }
+    k = length(fits)
+    if (is.null(data))
+        data = fits[[1]]$data
+    res = NULL
+    for (h in 1:p) {
+        if (p > 1)
+            data = fits[[h]]$data
+        weight = attr(data, "weight")
+        lw = length(weight)
+        siteLik = matrix(0, lw, k)
+        for (i in 1:k) siteLik[, i] = update(fits[[i]], data = data)$site
+        ntree = k
+        Lalpha <- drop(crossprod(siteLik, weight))
+        Talpha <- max(Lalpha) - Lalpha
+        M <- matrix(NA, k, B)
+        #        S <- matrix(NA, k, B)
+        wvec <- rep(1L:lw, weight)
+        size = length(wvec)
+        for (i in 1:B) {
+            boot = tabulate(sample(wvec, replace=TRUE), nbins=lw)
+            M[, i] <- crossprod(siteLik, boot)
+        }
+        M <- M - rowMeans(M)
+        #        for (i in 1:B) for (j in 1:ntree) S[j, i] <- max(M[j, i] - M[, i])
+        S = matrix(apply(M,2,min), k, B, byrow=TRUE)
+        S = M - S
+        count <- numeric(ntree)
+        for (j in 1:ntree) count[j] <- sum(S[j, ] > Talpha[j])
+        count <- count/B
+        trees <- 1:k
+        if (p == 1)
+            res = cbind(trees, Lalpha, Talpha, count)
+        else res = rbind(res, cbind(h, trees[-h], Lalpha[-h],
+                                    Talpha[-h], count[-h]))
+    }
+    if (p == 1)
+        colnames(res) <- c("Trees", "ln L", "Diff ln L", "p-value")
+    else colnames(res) <- c("Partition", "Trees", "ln L", "Diff ln L",
+                            "p-value")
+    res
+}
\ No newline at end of file
diff --git a/R/ancestral_pml.R b/R/ancestral_pml.R
new file mode 100644
index 0000000..b7331a3
--- /dev/null
+++ b/R/ancestral_pml.R
@@ -0,0 +1,102 @@
+#
+# ancestral sequences ML
+#
+ancestral.pml <- function (object, type=c("ml", "bayes")) 
+{
+    call <- match.call()
+    type <- match.arg(type)
+    pt <- match.arg(type, c("ml", "bayes"))   
+    tree = object$tree 
+    
+    INV <- object$INV
+    inv <- object$inv
+    
+    data = getCols(object$data, tree$tip.label) 
+    if (is.null(attr(tree, "order")) || attr(tree, "order") == 
+        "cladewise") 
+        tree <- reorder(tree, "postorder")
+    q = length(tree$tip.label)
+    node <- tree$edge[, 1]
+    edge <- tree$edge[, 2]
+    m = length(edge) + 1  # max(edge)
+    w = object$w
+    g = object$g
+    l = length(w)    
+    nr <- attr(data, "nr")
+    nc <- attr(data, "nc")
+    dat = vector(mode = "list", length = m*l)
+    result = vector(mode = "list", length = m)
+    dim(dat) <- c(l,m)
+    
+    x = attributes(data)
+    label = as.character(1:m)
+    nam = tree$tip.label
+    label[1:length(nam)] = nam
+    x[["names"]] = label
+    
+    
+    tmp = length(data)
+    result = new2old.phyDat(data) 
+    eig = object$eig
+    
+    bf = object$bf
+    el <- tree$edge.length
+    P <- getP(el, eig, g)
+    nr <- as.integer(attr(data, "nr"))
+    nc <- as.integer(attr(data, "nc"))
+    node = as.integer(node - min(node))
+    edge = as.integer(edge - 1)
+    nTips = as.integer(length(tree$tip.label))
+    mNodes = as.integer(max(node) + 1)
+    contrast = attr(data, "contrast")
+    nco = as.integer(dim(contrast)[1])
+    for(i in 1:l)dat[i,(q + 1):m] <- .Call("LogLik2", data, P[i,], nr, nc, node, edge, nTips, mNodes, contrast, nco, PACKAGE = "phangorn")
+    
+    parent <- tree$edge[, 1]
+    child <- tree$edge[, 2]
+    nTips = min(parent) - 1
+    
+    for(i in 1:l){     
+        for (j in (m - 1):1) {
+            if (child[j] > nTips){
+                tmp2 = (dat[[i, parent[j]]]/(dat[[i,child[j]]] %*% P[[i,j]]))
+                dat[[i, child[j]]] = (tmp2 %*% P[[i,j]]) * dat[[i, child[j]]]  
+            }
+        }
+    }
+    for (j in unique(parent)) {
+        tmp <- matrix(0, nr, nc)
+        if(inv>0) tmp = as.matrix(INV) * inv
+        for(i in 1:l){  
+            tmp = tmp + w[i] * dat[[i, j]]                                 
+        }
+        if (pt == "bayes") tmp = tmp * rep(bf, each=nr)
+        tmp = tmp / rowSums(tmp)
+        result[[j]] = tmp
+    } 
+    attributes(result) = x
+    attr(result, "call") <- call
+    result 
+}
+
+
+fast.tree  = function(tree, node){
+    parent = c(node, Ancestors(tree, node))
+    children = Descendants(tree, parent, 'children')
+    l = sapply(children, length)
+    edge = cbind(rep(parent, l), unlist(children))
+    obj = list(edge=edge, Nnode=sum(l>0), tip.label=as.character(edge[is.na(match(edge[,2], edge[,1])),2]))
+    class(obj) = 'phylo'
+    obj
+}
+
+# schneller ???
+fast.tree2  = function(tree, node){
+    parent = c(node, Ancestors(tree, node))
+    edge = tree$edge 
+    ind = match(edge[,1], parent)
+    edge=edge[which(!is.na(ind)),] 
+    obj = list(edge=edge, Nnode=length(parent), tip.label=as.character(edge[is.na(match(edge[,2], edge[,1])),2]))
+    class(obj) = 'phylo'
+    obj
+}
diff --git a/R/bootstrap.R b/R/bootstrap.R
new file mode 100644
index 0000000..f472f57
--- /dev/null
+++ b/R/bootstrap.R
@@ -0,0 +1,238 @@
+bootstrap.pml = function (x, bs = 100, trees = TRUE, multicore=FALSE, mc.cores = NULL, ...) 
+{
+    if(multicore && is.null(mc.cores)){
+        mc.cores <- detectCores()
+    }
+    
+    data = x$data
+    weight = attr(data, "weight")
+    v = rep(1:length(weight), weight)
+    BS = vector("list", bs)
+    for (i in 1:bs) BS[[i]] = tabulate(sample(v, replace = TRUE), 
+                                       length(weight))
+    pmlPar <- function(weights, fit, trees = TRUE, ...) {
+        data = fit$data
+        ind <- which(weights > 0)
+        data <- getRows(data, ind)
+        attr(data, "weight") <- weights[ind]
+        fit = update(fit, data = data)
+        fit = optim.pml(fit, ...)
+        if (trees) {
+            tree = fit$tree
+            return(tree)
+        }
+        attr(fit, "data") = NULL
+        fit
+    }
+    eval.success <- FALSE
+    if (!eval.success & multicore) {
+        res <- mclapply(BS, pmlPar, x, trees = trees, ..., mc.cores = mc.cores)
+        eval.success <- TRUE
+    }
+    if (!eval.success) res <- lapply(BS, pmlPar, x, trees = trees, ...)
+    if (trees) {
+        class(res) = "multiPhylo"
+        res = .compressTipLabel(res) # save memory
+    }
+    res
+}
+
+
+bootstrap.phyDat <- function (x, FUN, bs = 100, multicore=FALSE, mc.cores = NULL, jumble=TRUE, ...) 
+{
+    if(multicore && is.null(mc.cores)){
+        mc.cores <- detectCores()
+    }
+    weight = attr(x, "weight")
+    v = rep(1:length(weight), weight)
+    BS = vector("list", bs)
+    for(i in 1:bs)BS[[i]]=tabulate(sample(v, replace=TRUE),length(weight)) 
+    if(jumble){
+        J = vector("list", bs)
+        l = length(x)
+        for(i in 1:bs) J[[i]] = list(BS[[i]], sample(l))
+    }
+    fitPar <- function(weights, data, ...){     
+        ind <- which(weights > 0)
+        data <- getRows(data, ind)
+        attr(data, "weight") <- weights[ind]
+        FUN(data,...)        
+    }
+    fitParJumble <- function(J, data, ...){     
+        ind <- which(J[[1]] > 0)
+        data <- getRows(data, ind)
+        attr(data, "weight") <- J[[1]][ind]
+        data <- subset(data, J[[2]])
+        FUN(data,...)        
+    }
+    if(multicore){
+        if(jumble) res <- mclapply(J, fitPar, x, ..., mc.cores = mc.cores) 
+        else res <- mclapply(BS, fitPar, x, ..., mc.cores = mc.cores) 
+    }        
+    else{
+        if(jumble) res <- lapply(J, fitParJumble, x, ...) 
+        else res <- lapply(BS, fitPar, x, ...)
+    } 
+    if(class(res[[1]]) == "phylo"){
+        class(res) <- "multiPhylo"   
+        res = .compressTipLabel(res) # save memory
+    }
+    res 
+}
+
+
+matchEdges = function(tree1, tree2){
+    bp1 = bip(tree1)
+    bp2 = bip(tree2)
+    l = length(tree1$tip.label)
+    fn = function(x, y){
+        if(x[1]==1)return(x)
+        else return(y[-x])
+    } 
+    bp1[] = lapply(bp1, fn, 1:l)
+    bp2[] = lapply(bp2, fn, 1:l)
+    match(bp1, bp2)
+}
+
+
+checkLabels <- function(tree, tip){
+    ind <- match(tip, tree$tip.label)
+    if (any(is.na(ind)) | length(tree$tip.label) != length(tip))
+        stop("tree has different labels")
+    tree$tip.label <- tree$tip.label[ind]
+    ind2 <- match(1:length(ind), tree$edge[, 2])
+    tree$edge[ind2, 2] <- order(ind)
+    tree
+}
+
+
+plotBS <- function (tree, BStrees, type = "unrooted", bs.col = "black", 
+                    bs.adj = NULL, p=50, frame="none",...) 
+{
+    type <- match.arg(type, c("phylogram", "cladogram", "fan", 
+                              "unrooted", "radial"))
+    if (type == "phylogram" | type == "cladogram") {
+        if (!is.rooted(tree) & !is.null(tree$edge.length)) 
+            tree2 = midpoint(tree)
+        else tree2=tree
+        plot(tree2, type = type, ...)
+    }
+    else plot(tree, type = type, ...)
+    
+    if(hasArg(BStrees)){
+        BStrees <- .uncompressTipLabel(BStrees)
+        if(any(unlist(lapply(BStrees, is.rooted)))){
+            BStrees <- lapply(BStrees, unroot)   
+        }
+        x = prop.clades(tree, BStrees)
+        x = round((x/length(BStrees)) * 100)
+        tree$node.label = x
+    }
+    else{
+        if(is.null(tree$node.label))stop("You need to supply BStrees or tree needs 
+        needs BS-values as node.label")
+        x <- tree$node.label
+    }
+    
+    label = c(rep(0, length(tree$tip.label)), x)
+    ind <- get("last_plot.phylo", envir = .PlotPhyloEnv)$edge[, 
+                                                              2]
+    if (type == "phylogram" | type == "cladogram") {
+        root = getRoot(tree)
+        label = c(rep(0, length(tree$tip.label)), x)
+        label[root] = 0
+        ind2 = matchEdges(tree2, tree)
+        label = label[ind2]
+        ind = which(label > p)
+        #        browser()
+        if (is.null(bs.adj)) 
+            bs.adj = c(1, 1)
+        if(length(ind)>0)nodelabels(text = label[ind], node = ind, frame = frame, 
+                                    col = bs.col, adj = bs.adj, ...)
+    }
+    else {
+        if (is.null(bs.adj)) 
+            bs.adj = c(0.5, 0.5)
+        ind2 = which(label[ind]>p)
+        if(length(ind2>0))edgelabels(label[ind][ind2],ind2, frame = frame, col = bs.col, 
+                                     adj = bs.adj, ...)
+    }
+    invisible(tree)
+}
+
+
+maxCladeCred <- function(x, tree=TRUE, part=NULL, rooted=TRUE){
+    if(inherits(x, "phylo")) x <- c(x)
+    if(!rooted){
+        x <- lapply(x, unroot) 
+        class(x) <- "multiPhylo"
+        x <- .compressTipLabel(x)
+    }    
+    if(is.null(part))pp <- prop.part(x)
+    else pp <- part
+    pplabel <- attr(pp, "labels")
+    if(!rooted)pp <- oneWise(pp)
+    x <- .uncompressTipLabel(x)
+    class(x) <- NULL
+    m <- max(attr(pp, "number"))
+    nb <- log( attr(pp, "number") / m )
+    l <-  length(x)
+    res <- numeric(l)
+    for(i in 1:l){
+        tmp <- checkLabels(x[[i]], pplabel)
+        ppi <- prop.part(tmp)  # trees[[i]]
+        if(!rooted)ppi <- oneWise(ppi)
+        indi <- fmatch(ppi, pp)
+        if(any(is.na(indi))) res[i] <- -Inf
+        else res[i] <- sum(nb[indi])
+    }
+    if(tree) {
+        k <- which.max(res)
+        tr <- x[[k]]
+        attr(tr, "clade.credibility") <- res[k]
+        return(tr)
+    }    
+    res
+}
+
+
+mcc <- maxCladeCred
+
+
+cladeMatrix <- function(x, rooted=FALSE){
+    if(!rooted){
+        x <- .uncompressTipLabel(x)
+        x <- lapply(x, unroot) 
+        class(x) <- "multiPhylo"
+        x <- .compressTipLabel(x)
+    }    
+    pp <- prop.part(x)
+    pplabel <- attr(pp, "labels")
+    if(!rooted)pp <- oneWise(pp)
+    x <- .uncompressTipLabel(x)
+    class(x) <- NULL
+    nnodes <- sapply(x, Nnode)
+    l <-  length(x)
+    from <- cumsum(c(1, nnodes[-l]))
+    to <- cumsum(nnodes)
+    
+    ivec <- integer(to[l])
+    pvec <- c(0,to)
+    
+    res <- vector("list", l)
+    k=1
+    for(i in 1:l){
+        ppi <- prop.part(x[[i]])  
+        if(!rooted)ppi <- oneWise(ppi)
+        indi <- sort(fmatch(ppi, pp))
+        ivec[from[i]:to[i]] = indi
+    }
+    X <- sparseMatrix(i=ivec, p=pvec, dims=c(length(pp),l))
+    list(X=X, prop.part=pp)
+}
+
+
+moving_average <- function(x, window=50){
+     cx <- c(0, cumsum(x))
+     (cx[(window+1):length(cx)] - cx[1:(length(cx)-window)])/(window)
+}
diff --git a/R/cladePar.R b/R/cladePar.R
index 3905205..35da6c5 100644
--- a/R/cladePar.R
+++ b/R/cladePar.R
@@ -1,7 +1,7 @@
 cladePar = function(tree, node, edge.color="red", tip.color=edge.color, edge.width = 1, edge.lty = 1, x=NULL, plot=FALSE, ...){
     if(is.null(x)){
         m = max(tree$edge)
-        x=list(edge=data.frame(color=rep("black",m), width = rep(1, m), lty =  rep(1, m), stringsAsFactors = FALSE),tip=rep("black", length(tree$tip)))         
+        x=list(edge=data.frame(color=rep("black",m), width = rep(1, m), lty =  rep(1, m), stringsAsFactors = FALSE),tip=rep("black", length(tree$tip.label)))         
     }
     ind = Descendants(tree,node,"all")
     x$edge$color[ind] = edge.color
diff --git a/R/clanistic.R b/R/clanistic.R
index 4d44847..02c6c1a 100644
--- a/R/clanistic.R
+++ b/R/clanistic.R
@@ -6,7 +6,7 @@ getClans = function (tree)
 	if (is.rooted(tree)) 
         tree = unroot(tree)
     bp = bip(tree)
-    nTips = length(tree$tip)
+    nTips = length(tree$tip.label)
     root = nTips + 1
     bp[root] = NULL
     X = matrix(0, length(bp) - nTips, nTips)
@@ -23,7 +23,7 @@ getClans = function (tree)
         }
     }
     res <- rbind(diag(nTips), 1 - diag(nTips), X, 1 - X)
-    colnames(res) <- tree$tip
+    colnames(res) <- tree$tip.label
     if (!is.null(nl)) 
         rownames(res) = nl
     res
@@ -31,7 +31,7 @@ getClans = function (tree)
 
 
 getSlices <- function(tree){
-    nTips = length(tree$tip)
+    nTips = length(tree$tip.label)
     clans = getClans(tree)
     m = dim(clans)[1]
     X = tcrossprod(clans)
@@ -61,7 +61,7 @@ getSlices <- function(tree){
         }
     }
     if(k<nSlices) result = result[1:(k-1),] 
-    colnames(result) <- tree$tip
+    colnames(result) <- tree$tip.label
     result   
 }
 
@@ -71,7 +71,7 @@ getClips = function (tree, all = TRUE)
     if (any(is.na(tree$edge.length))) 
         return(NULL)
     dm = cophenetic(tree)
-    tips = tree$tip
+    tips = tree$tip.label
     nTips = length(tips)
     res = numeric(nTips)
     result = NULL
@@ -252,13 +252,13 @@ getDiv <- function(tree, x, native=NULL){
 getDiversity <- function (tree, x, norm = TRUE, var.names = NULL, labels="new") 
 {
     k = 1
-    if(class(tree) == "multiPhylo") 
+    if(inherits(tree,"multiPhylo")) 
         k = length(tree)
     l = attr(x, "nr")
     tmp = matrix(0, k * l, 12)
 
     tnam = 1
-    if (class(tree) == "multiPhylo") {
+    if (inherits(tree,"multiPhylo")) {
         tnam = names(tree)
         if (is.null(tnam)) 
             tnam = 1:length(tree)
@@ -274,7 +274,7 @@ getDiversity <- function (tree, x, norm = TRUE, var.names = NULL, labels="new")
     o = 1
     ok= 0
     for (i in 1:k) {
-        if (class(tree) == "multiPhylo") 
+        if (inherits(tree,"multiPhylo")) 
             tmptree = tree[[i]]
         else tmptree = tree
         if (is.rooted(tmptree)) 
@@ -385,7 +385,7 @@ diversity <- function(tree, X){
 
 
     l = dim(X)[2]
-    m <- ifelse(class(tree)=="multiPhylo", length(tree), 1)
+    m <- ifelse(inherits(tree,"multiPhylo"), length(tree), 1)
     
     contr = as.list(rep("contr.dummy", l))
     names(contr) = names(X)
@@ -403,10 +403,10 @@ diversity <- function(tree, X){
     dimnames(fd) = list(colnames(tmp), tnames)
     res = stack(data.frame(fd))
 
-    if(m>1)nt = rep(sapply(tree, function(x)length(x$tip)), each=dim(fd)[1])    
-    else nt = rep(length(tree$tip), each=dim(fd)[1]) 
-    if(m>1)res2 = as.vector(sapply(tree, function(x,y)colSums(y[x$tip,,drop=FALSE]) , y=tmp))
-    else res2 = colSums(tmp[tree$tip,,drop=FALSE])
+    if(m>1)nt = rep(sapply(tree, function(x)length(x$tip.label)), each=dim(fd)[1])    
+    else nt = rep(length(tree$tip.label), each=dim(fd)[1]) 
+    if(m>1)res2 = as.vector(sapply(tree, function(x,y)colSums(y[x$tip.label,,drop=FALSE]) , y=tmp))
+    else res2 = colSums(tmp[tree$tip.label,,drop=FALSE])
     result <- data.frame(tree = res[,2], variable=rep(colnames(tmp),m), pscore=res[,1], ntips=nt, natives=res2)
     result
 }
diff --git a/R/dist.p.R b/R/dist.p.R
index 081aa23..a12d7b9 100644
--- a/R/dist.p.R
+++ b/R/dist.p.R
@@ -1,7 +1,7 @@
 
 dist.p <- function (x, cost="polymorphism", ignore.indels=TRUE) 
 {
-    if (class(x) != "phyDat") 
+    if (!inherits(x,"phyDat")) 
         stop("x has to be element of class phyDat")
 
     l = length(x)
diff --git a/R/distSeq.R b/R/distSeq.R
index ce8a825..0c955dc 100644
--- a/R/distSeq.R
+++ b/R/distSeq.R
@@ -3,7 +3,7 @@
 #
 dist.hamming <- function (x, ratio = TRUE, exclude = "none") 
 {
-    if (class(x) != "phyDat") 
+    if (!inherits(x,"phyDat")) 
         stop("x has to be element of class phyDat")
     l = length(x)
 
@@ -70,9 +70,99 @@ dist.hamming <- function (x, ratio = TRUE, exclude = "none")
 
 
 
-dist.ml <- function (x, model = "JC69", exclude = "none", bf = NULL, Q = NULL, ...) 
+dist.ml <- function (x, model = "JC69", exclude = "none", bf = NULL, Q = NULL, k=1L, shape=1, ...) 
 {
-    if (class(x) != "phyDat") 
+    if (!inherits(x,"phyDat")) 
+        stop("x has to be element of class phyDat")
+    l = length(x)
+    d = numeric((l * (l - 1))/2)
+    v = numeric((l * (l - 1))/2)
+    contrast <- attr(x, "contrast")
+    con = rowSums(contrast > 0) < 2
+    if (exclude == "all") {
+        index = con[x[[1]]]
+        for (i in 2:l) index = index & con[x[[i]]]
+        index = which(index)
+        x = subset(x, , index)
+    }
+    nc <- as.integer(attr(x, "nc"))
+    nr <- as.integer(attr(x, "nr"))
+    #    model <- match.arg(model, c("JC69", "WAG", "JTT", "LG", "Dayhoff", "cpREV", "mtmam", "mtArt", "MtZoa", "mtREV24"))
+    model <- match.arg(model, c("JC69", "F81", .aamodels))
+    #    if (!is.na(match(model, c("WAG", "JTT", "LG", "Dayhoff", "cpREV", "mtmam", "mtArt", "MtZoa", "mtREV24")))) 
+    if (!is.na(match(model, .aamodels))) 
+        getModelAA(model, bf = is.null(bf), Q = is.null(Q))
+    if(is.null(bf) && model=="F81") bf <- baseFreq(x)
+    if (is.null(bf)) 
+        bf <- rep(1/nc, nc)
+    if (is.null(Q)) 
+        Q <- rep(1, (nc - 1) * nc/2L)
+    
+    bf = as.double(bf)
+    eig <- edQt(Q = Q, bf = bf)
+    pos = 1
+    k = as.integer(k)
+    w = as.double(w <- rep(1/k, k))
+    g = as.double(discrete.gamma(shape,k))
+    fun <- function(s) -(nc - 1)/nc * log(1 - nc/(nc - 1) * s)
+    eps <- (nc - 1)/nc
+    n = as.integer(dim(contrast)[1])
+    ind1 = rep(1:n, n:1)
+    ind2 = unlist(lapply(n:1, function(x) seq_len(x) + n - x))
+    li <- as.integer(length(ind1))
+    weight = as.double(attr(x, "weight"))
+    ll.0 = as.double(weight * 0)
+    if (exclude == "pairwise") {
+        index = con[ind1] & con[ind2]
+        index = which(!index)
+    }
+    tmp = (contrast %*% eig[[2]])[ind1, ] * (contrast %*% (t(eig[[3]]) * bf))[ind2, ]
+    tmp2 = vector("list", k)
+    wdiag = .Call("PWI", as.integer(1:n), as.integer(1:n), as.integer(n), 
+                  as.integer(n), rep(1, n), as.integer(li), PACKAGE = "phangorn")
+    wdiag = which(wdiag > 0)
+    
+    tmp2 = vector("list", k)
+    for (i in 1:(l - 1)) {
+        for (j in (i + 1):l) {
+            w0 = .Call("PWI", as.integer(x[[i]]), as.integer(x[[j]]), 
+                       nr, n, weight, li, PACKAGE = "phangorn")
+            if (exclude == "pairwise") 
+                w0[index] = 0.0
+            ind = w0 > 0
+            
+            old.el <- 1 - (sum(w0[wdiag])/sum(w0))
+            if (old.el > eps) 
+                old.el <- 10
+            else old.el <- fun(old.el)
+            #        sind = sum(ind)
+            #           browser()
+            
+            for(lk in 1:k) tmp2[[lk]] <- tmp[ind, , drop = FALSE]
+            # FS0 verwenden!!!        
+            res <- .Call("FS5", eig, nc, as.double(old.el), w, g, tmp2, as.integer(k), as.integer(sum(ind)), 
+                         bf, w0[ind], ll.0[ind], PACKAGE = "phangorn")
+            d[pos] <- res[1] # res[[1]]
+            v[pos] <- res[2] # res[[2]]
+            pos = pos + 1
+        }
+    }
+    attr(d, "Size") <- l
+    if (is.list(x)) 
+        attr(d, "Labels") <- names(x)
+    else attr(d, "Labels") <- colnames(x)
+    attr(d, "Diag") <- FALSE
+    attr(d, "Upper") <- FALSE
+    attr(d, "call") <- match.call()
+    attr(d, "variance") <- v
+    class(d) <- "dist"
+    return(d)
+}
+
+
+dist.mlOld <- function (x, model = "JC69", exclude = "none", bf = NULL, Q = NULL, ...) 
+{
+    if (!inherits(x,"phyDat")) 
         stop("x has to be element of class phyDat")
     l = length(x)
     d = numeric((l * (l - 1))/2)
@@ -157,7 +247,7 @@ dist.ml <- function (x, model = "JC69", exclude = "none", bf = NULL, Q = NULL, .
    
 dist.logDet = function (x) 
 {
-    if (class(x) != "phyDat") 
+    if (!inherits(x,"phyDat")) 
         stop("x has to be element of class phyDat")
     weight <- attr(x, "weight")
     contrast <- attr(x, 'contrast')
diff --git a/R/distTree.R b/R/distTree.R
index 38d0142..2667649 100644
--- a/R/distTree.R
+++ b/R/distTree.R
@@ -19,6 +19,83 @@
 }
 
 
+upgma.edge.length <- function(x, dm, method="average"){
+    METHODS <- c("average", "single", "complete") # , "mcquitty"
+    i.meth <- match.arg(method, METHODS)
+    X <- designTree(x, "rooted", TRUE)
+    labels <- x$tip
+    if(is.matrix(dm) || inherits(dm, "dist")){
+        dm <- as.matrix(dm)[labels,labels]
+        dm <- dm[lower.tri(dm)]
+    }
+    ind <- X at i+1
+    node <- X at p 
+    X at x[] <- 1
+    nh <- numeric(max(x$edge))
+    Y = X*dm
+    for(i in 1:(length(node)-1)){
+        pos = ind[(node[i]+1):node[i+1]]
+        tmp <- switch(i.meth,
+                      average = mean(Y[pos, i]),
+                      single = min(Y[pos, i]),
+                      complete = max(Y[pos, i]))
+        nh[X at nodes[i]] = tmp
+    }
+    x$edge.length <- (nh[x$edge[,1]] - nh[x$edge[,2]]) /2
+    x
+}
+
+
+upgma_nni <- function(d, method="average", opt="min", trace=0, mc.cores=2L)
+{
+    METHODS <- c("average", "single", "complete") # , "mcquitty"
+    method <- match.arg(method, METHODS)
+    OPT <- c("min", "ls")
+    opt <- match.arg(opt, OPT)
+    tree <- upgma(d, method=method)
+    labels <- tree$tip.label
+    nTips <- length(labels)
+    y <- as.matrix(d)[labels,labels]
+    y <- y[lower.tri(y)]
+    best.tree <- tree
+    bestLS <- sum((coph(best.tree)-y)^2)
+    bestME <- sum(best.tree$edge.length)
+    run.nni = TRUE
+    count_nni = 0
+    print(count_nni)
+    while (run.nni) {
+        trees <- nni(best.tree)
+        trees <- .uncompressTipLabel(trees)
+        trees <- unclass(trees)
+        nni.trees <- lapply(trees, upgma.edge.length, y, method=method)
+        ind <- which(sapply(nni.trees, function(x)!any(x$edge.length<0)))
+        if (length(ind)==0)return(best.tree)
+        nni.trees <- nni.trees[ind]
+        if(opt == "min"){
+            ME <- sapply(nni.trees, function(x)sum(x$edge.length))
+            if (any(ME < bestME)){
+                bestME <- min(ME)
+                count_nni = count_nni + 1
+                best.tree <- nni.trees[[which.min(ME)]]
+                print(bestME)
+            }
+            else run.nni = FALSE
+        }
+        else{
+            LS <- sapply(nni.trees, function(x) sum((coph(x)-y)^2))
+            if (any(LS < bestLS)){
+                bestLS <- min(LS)
+                count_nni = count_nni + 1
+                best.tree <- nni.trees[[which.min(LS)]]
+                print(bestLS)
+            }
+            else run.nni = FALSE
+        }
+    }
+    best.tree
+}
+
+
 NJ_old <- function(x) 
 {
     x = as.matrix(x)
@@ -238,7 +315,7 @@ designUltra <- function (tree, sparse=TRUE)
         tree = reorder(tree, "postorder")
     leri = allChildren(tree)
     bp = bip(tree)
-    n = length(tree$tip)
+    n = length(tree$tip.label)
     l = tree$Nnode   
     nodes = integer(l)
     k = 1L
@@ -279,10 +356,10 @@ designUnrooted2 <- function (tree, sparse=TRUE)
         tree = reorder(tree, "postorder")
     leri = allChildren(tree)
     bp = bip(tree)
-    n = length(tree$tip)
+    n = length(tree$tip.label)
     l = tree$Nnode   
     nodes = integer(l)
-    nTips = as.integer(length(tree$tip))
+    nTips = as.integer(length(tree$tip.label))
     k = nTips
     u=numeric( n * (n - 1)/2)
     v=numeric( n * (n - 1)/2)
@@ -354,7 +431,7 @@ nnls.tree <- function(dm, tree, rooted=FALSE, trace=1){
     tree = reorder(tree, "postorder")
     dm = as.matrix(dm)
     k = dim(dm)[1]
-    labels = tree$tip
+    labels = tree$tip.label
     dm = dm[labels,labels]
     y = dm[lower.tri(dm)]
     #computing the design matrix from the tree   
@@ -373,14 +450,14 @@ nnls.tree <- function(dm, tree, rooted=FALSE, trace=1){
     Dmat <- crossprod(X) # cross-product computations
     dvec <- crossprod(X, y)
     betahat <- as.vector(solve(Dmat, dvec))
-    
+    betahattmp = betahat
     bhat = numeric(max(tree$edge))
     bhat[as.integer(lab)] = betahat
     betahat = bhat[tree$edge[,1]] - bhat[tree$edge[,2]]
     
     if(!any(betahat<0)){
         if(!rooted){
-            RSS = sum((y-(X%*%betahat))^2)    
+            RSS = sum((y-(X%*%betahattmp))^2)    
             if(trace)print(paste("RSS:", RSS))
             attr(tree, "RSS") = RSS
         }
@@ -499,13 +576,16 @@ nnls.splitsOld <- function(x, dm, trace=0){
     x
 }  
 
+
 nnls.networx <- function(x, dm){
-    spl <- attr(x, "splits")
+#    spl <- attr(x, "splits")
+    spl <- x$splits
     spl2 <- nnls.splits(spl, dm)
     weight <- attr(spl, "weight")
     weight[] <- 0
     weight[match(spl2, spl)] = attr(spl2, "weight")
-    attr(attr(x, "splits"), "weight") <- weight
+#    attr(attr(x, "splits"), "weight") <- weight
+    attr(x$splits, "weight") <- weight
     x$edge.length = weight[x$splitIndex]
     x
 }
diff --git a/R/fitch.R b/R/fitch.R
index 16bae9e..c3ee924 100644
--- a/R/fitch.R
+++ b/R/fitch.R
@@ -1,9 +1,9 @@
 fitch <- function (tree, data, site="pscore") 
 { 
-    if (class(data) != "phyDat") 
+    if (!inherits(data,"phyDat")) 
         stop("data must be of class phyDat")
     levels <- attr(data, "levels")
-    if(class(tree)=="multiPhylo"){ 
+    if(inherits(tree,"multiPhylo")){ 
         TL = attr(tree,"TipLabel")
         if (!is.null(TL)){
             data <- subset(data, TL)
@@ -17,15 +17,16 @@ fitch <- function (tree, data, site="pscore")
     d = attributes(data)
     data <- as.integer(data)
     attributes(data) <- d
-    if(class(tree)=="phylo") return(fit.fitch(tree, data, site))
-    {
+    if(inherits(tree,"phylo")) return(fit.fitch(tree, data, site))
+    else{
         if(is.null(attr(tree,"TipLabel"))){
             tree = unclass(tree)
             return(sapply(tree, fit.fitch, data, site))
         }    
         else{
+            tree = .uncompressTipLabel(tree)
             tree = unclass(tree)
-#            tree = lapply(tree, reorder, "postorder")
+            tree = lapply(tree, reorder, "postorder")
             site = ifelse(site == "pscore", 1L, 0L) 
             on.exit(.C("fitch_free"))
             .C("fitch_init", as.integer(data), as.integer(nTips*nr), as.integer(m), as.double(weight), as.integer(nr)) 
@@ -35,7 +36,7 @@ fitch <- function (tree, data, site="pscore")
 }
 
 
-fit.fitch <- function (tree, data, returnData = c("pscore", "site", "data")) 
+fit.fitch <- function (tree, data, returnData = c("pscore", "site", "data"))
 {
     if (is.null(attr(tree, "order")) || attr(tree, "order") == 
         "cladewise") 
@@ -46,7 +47,7 @@ fit.fitch <- function (tree, data, returnData = c("pscore", "site", "data"))
     edge <- tree$edge[, 2]
     weight = attr(data, "weight")
     m = max(tree$edge) 
-    q = length(tree$tip)
+    q = length(tree$tip.label)
     result <- .Call("FITCH", data[, tree$tip.label], as.integer(nr), as.integer(node), as.integer(edge), as.integer(length(edge)), as.double(weight), as.integer(m), as.integer(q))
     if (returnData == "site") return(result[[2]])
     pscore <- result[[1]]
@@ -71,18 +72,18 @@ fnodesNew2 <- function (EDGE, nTips, nr)
 
 
 # SPR und bab kompakter
-fnodesNew5 <- function (EDGE, nTips, nr) 
+fnodesNew5 <- function (EDGE, nTips, nr, m= as.integer(max(EDGE)+1L)) 
 {
     node <- EDGE[, 1]
     edge <- EDGE[, 2]
-    n = length(node)
-    m= as.integer(max(EDGE)+1L)
-    m2 = 2L*n
-    root0 <- as.integer(node[n]) 
-    .Call("FNALL5", as.integer(nr), node, edge, as.integer(n), as.integer(m), as.integer(m2), as.integer(root0))
+    n = length(node)              # in C
+    m2 = 2L*n                     # in C
+    root0 <- as.integer(node[n])  # in C 
+    .Call("FNALL5", as.integer(nr), node, edge, as.integer(n), as.integer(m), as.integer(m2), as.integer(root0), PACKAGE="phangorn")
 }   
 
 
+
 random.addition <- function(data, method="fitch") 
 {
     label <- names(data)
@@ -98,7 +99,7 @@ random.addition <- function(data, method="fitch")
     storage.mode(nr) <- "integer"
     n <- length(data) #- 1L
      
-    data <- subset(data,,order(attr(data, "weight"), decreasing=TRUE))   
+    data <- subset(data, ,order(attr(data, "weight"), decreasing=TRUE))   
     data <- prepareDataFitch(data) 
     weight <- attr(data, "weight")
 
@@ -132,14 +133,15 @@ fast.fitch <- function (tree,  nr, ps = TRUE)
 
 
 fitch.spr <- function(tree, data){
-  nTips = as.integer(length(tree$tip))
+  nTips = as.integer(length(tree$tip.label))
   nr = attr(data, "nr")
   minp = fast.fitch(tree, nr, TRUE)
-  
+  m=max(tree$edge)
   for(i in 1:nTips){
     treetmp = dropTip(tree, i)   
     edge = treetmp$edge[,2] 
-    score = fnodesNew5(treetmp$edge, nTips, nr)[edge]   
+#    score = fnodesNew5(treetmp$edge, nTips, nr)[edge]
+    score <- .Call("FNALL6", as.integer(nr), treetmp$edge[,1], edge, as.integer(m+1L), PACKAGE="phangorn")[edge]
     score <- .Call("FITCHTRIP3", as.integer(i), as.integer(nr), as.integer(edge),  as.double(score), as.double(minp))  
     
     if(min(score)<minp){
@@ -149,16 +151,17 @@ fitch.spr <- function(tree, data){
       #   print(paste("new",minp))
     }
   }
-  m=max(tree$edge)
   root <- getRoot(tree) 
   ch = allChildren(tree)
   for(i in (nTips+1L):m){
       if(i!=root){
           tmp = dropNode(tree, i, all.ch=ch)
           if(!is.null(tmp)){
-          edge = tmp[[1]]$edge[,2]                          
+          edge = tmp[[1]]$edge[,2] 
+          
           blub = fast.fitch(tmp[[2]], nr, TRUE)
-          score = fnodesNew5(tmp[[1]]$edge, nTips, nr)[edge] + blub
+          score <- .Call("FNALL6", as.integer(nr), tmp[[1]]$edge[,1], edge, as.integer(m+1L), PACKAGE="phangorn")[edge] + blub
+#          score = fnodesNew5(tmp[[1]]$edge, nTips, nr)[edge] + blub
           score <- .Call("FITCHTRIP3", as.integer(i), as.integer(nr), as.integer(edge), as.double(score), as.double(minp))    
           if(min(score)<minp){
               nt = which.min(score)
@@ -174,7 +177,7 @@ fitch.spr <- function(tree, data){
 
 # raus oder richten
 fitch.spr2 <- function(tree, data){
-    nTips = as.integer(length(tree$tip))
+    nTips = as.integer(length(tree$tip.label))
     nr = attr(data, "nr")
     minp = fast.fitch(tree, nr, TRUE)
     
@@ -270,7 +273,7 @@ indexNNI2 <- function(tree){
 # weniger Speicher 2 Zeilen weinger 
 fitch.nni <- function (tree, data, ...) 
 {
-    nTips = as.integer(length(tree$tip)) # auskommentieren?
+    nTips = as.integer(length(tree$tip.label)) # auskommentieren?
     INDEX <- indexNNI2(tree)    
     nr = attr(data, "nr")
     weight <- attr(data, "weight")
@@ -301,7 +304,7 @@ fitch.nni <- function (tree, data, ...)
 
 
 optim.fitch <- function(tree, data, trace=1, rearrangements = "SPR", ...) {
-    if(class(tree)!="phylo") stop("tree must be of class phylo") 
+    if(!inherits(tree,"phylo")) stop("tree must be of class phylo") 
     if(!is.binary.tree(tree)){
         tree <- multi2di(tree)
         attr(tree, "order") <- NULL  
@@ -314,7 +317,7 @@ optim.fitch <- function(tree, data, trace=1, rearrangements = "SPR", ...) {
     if (class(data)[1] != "phyDat") stop("data must be of class phyDat")
 
     rt = FALSE
-    nTips = as.integer(length(tree$tip))
+    nTips = as.integer(length(tree$tip.label))
 
     nr = attr(data, "nr")    
     pis <- parsinfo(data)
@@ -324,7 +327,7 @@ optim.fitch <- function(tree, data, trace=1, rearrangements = "SPR", ...) {
     
     nr = attr(data, "nr")
    
-    data <- subset(data,tree$tip,order(attr(data, "weight"), decreasing=TRUE))   
+    data <- subset(data,tree$tip.label,order(attr(data, "weight"), decreasing=TRUE))   
     dat <- prepareDataFitch(data) 
     weight <- attr(data, "weight")
 
@@ -422,7 +425,7 @@ getOrder <- function (x)
 }
 
 
-bab <- function (data, tree = NULL, trace = 1, ...) 
+bab_old <- function (data, tree = NULL, trace = 1, ...) 
 {
     o = order(attr(data, "weight"), decreasing = TRUE)
     data = subset(data, , o)
@@ -491,14 +494,14 @@ bab <- function (data, tree = NULL, trace = 1, ...)
 
         tmpTree <- trees[[a]][[b]]
         edge = tmpTree[,2]  
-        score = fnodesNew5(tmpTree, nTips, nr)[edge] + mms0[a+1L] 
-        score <- .Call("FITCHTRIP3", as.integer(inord[a+1L]), as.integer(nr), as.integer(edge), as.double(score), as.double(bound))    
+        score = fnodesNew5(tmpTree, nTips, nr, M[a])[edge] + mms0[a+1L] 
+        score <- .Call("FITCHTRIP3", as.integer(inord[a+1L]), as.integer(nr), as.integer(edge), as.double(score), as.double(bound), PACKAGE="phangorn")    
                    
         ms = min(score)
         if(ms<=bound){
             if((a+1L)<nTips){
                 ind = (1:L[a])[score<=bound]
-                for(i in 1:length(ind))trees[[a+1]][[i]] <- .Call("AddOne", tmpTree, as.integer(inord[a+1L]), as.integer(ind[i]), as.integer(L[a]), as.integer(M[a])) 
+                for(i in 1:length(ind))trees[[a+1]][[i]] <- .Call("AddOne", tmpTree, as.integer(inord[a+1L]), as.integer(ind[i]), as.integer(L[a]), as.integer(M[a]), PACKAGE="phangorn") 
                 l = length(ind)
                 os = order(score[ind], decreasing=TRUE)                 
                 PSC = rbind(PSC, cbind(rep(a+1, l), os, score[ind][os] ))
@@ -506,7 +509,7 @@ bab <- function (data, tree = NULL, trace = 1, ...)
             else{
                 ind = which(score==ms) 
                 tmp <- vector("list", length(ind)) 
-                for(i in 1:length(ind))tmp[[i]] <- .Call("AddOne", tmpTree, as.integer(inord[a+1L]), as.integer(ind[i]), as.integer(L[a]), as.integer(M[a]))
+                for(i in 1:length(ind))tmp[[i]] <- .Call("AddOne", tmpTree, as.integer(inord[a+1L]), as.integer(ind[i]), as.integer(L[a]), as.integer(M[a]), PACKAGE="phangorn")
 
                 if(ms < bound){
                      bound = ms
@@ -528,3 +531,118 @@ bab <- function (data, tree = NULL, trace = 1, ...)
     return(result)
 }
 
+
+
+bab <- function (data, tree = NULL, trace = 1, ...) 
+{
+    o = order(attr(data, "weight"), decreasing = TRUE)
+    data = subset(data, , o)
+    nr <- attr(data, "nr")
+    pis <- parsinfo(data)
+    p0 <- sum(attr(data, "weight")[pis[, 1]] * pis[, 2])
+    if (length(pis) > 0) 
+        data <- getRows(data, c(1:nr)[-pis[, 1]], TRUE)
+    # added compressSites
+    data <- compressSites(data)
+    
+    tree <- pratchet(data, start = tree, trace = trace - 1, ...)
+    data <- subset(data, tree$tip.label) 
+    nr <- as.integer(attr(data, "nr"))
+    inord <- getOrder(data)
+    lb <- lowerBound(data)
+    nTips <- m <- length(data)
+    
+    nr <- as.integer(attr(data, "nr"))
+    TMP <- matrix(0, m, nr)
+    for (i in 4:m) {
+        TMP[i, ] = lowerBound(subset(data, inord[1:i]))
+    }
+    
+    weight <- as.double(attr(data, "weight"))
+    data <- prepareDataFitch(data)
+    m = nr*(2L*nTips - 2L)
+    on.exit(.C("fitch_free"))
+    .C("fitch_init", as.integer(data), as.integer(nTips*nr), as.integer(m), as.double(weight), as.integer(nr))
+    mmsAmb = 0
+    mmsAmb = TMP %*% weight  
+    mmsAmb = mmsAmb[nTips] - mmsAmb
+    mms0 = 0 
+    mms0 = mms0 + mmsAmb
+    
+    minPars = mms0[1]
+    kPars = 0
+    
+    if (trace) 
+        print(paste("lower bound:", p0 + mms0[1]))
+    bound <- fast.fitch(tree, nr)
+    if (trace) 
+        print(paste("upper bound:", bound + p0))
+    
+    startTree <- structure(list(edge = structure(c(rep(nTips+1L, 3), as.integer(inord)[1:3]), .Dim = c(3L, 2L)), 
+                                tip.label = tree$tip.label, Nnode = 1L), .Names = c("edge", "tip.label", "Nnode"), class = "phylo", order = "postorder")
+    
+    trees <- vector("list", nTips)
+    trees[[3]] <- list(startTree$edge)
+    for(i in 4:nTips) trees[[i]] <- vector("list", (2L*i) - 5L) # new
+    
+    # index M[i] is neues node fuer edge i+1
+    # index L[i] is length(node) tree mit i+1 
+    L = as.integer( 2L*(1L:nTips) -3L ) 
+    M = as.integer( 1L:nTips + nTips - 1L )    
+    
+#   PSC = matrix(0, sum(sapply(trees, length)), 3)    
+#   PSC[1,] = c(3,1,0)  
+    
+    PSC <- matrix(c(3,1,0), 1, 3)
+    PSC[1,3] <- fast.fitch(startTree, nr)
+    
+    k = 4L
+    Nnode = 1L
+    npsc = 1
+    
+    result <- list() 
+    while (npsc > 0) {
+        a = PSC[npsc,1]
+        b = PSC[npsc,2]
+        PSC = PSC[-npsc,, drop=FALSE]  
+        
+        tmpTree <- trees[[a]][[b]]
+        edge = tmpTree[,2]  
+        score = fnodesNew5(tmpTree, nTips, nr, M[a])[edge] + mms0[a+1L] 
+        score <- .Call("FITCHTRIP3", as.integer(inord[a+1L]), as.integer(nr), as.integer(edge), as.double(score), as.double(bound), PACKAGE="phangorn")    
+        
+        ms = min(score)
+        if(ms<=bound){
+            if((a+1L)<nTips){
+                ind = (1:L[a])[score<=bound]
+                trees[[a+1]][1:length(ind)] <- .Call("AddOnes", tmpTree, as.integer(inord[a+1L]), as.integer(ind), as.integer(L[a]), as.integer(M[a]), PACKAGE="phangorn") 
+                l = length(ind)
+#                os = order(score[ind], decreasing=TRUE)     
+                os = seq_len(l)
+                PSC = rbind(PSC, cbind(rep(a+1, l), os, score[ind] ))
+#                PSC = rbind(PSC, cbind(rep(a+1, l), os, score[ind][os] ))
+            }
+            else{
+                ind = which(score==ms) 
+                tmp <- vector("list", length(ind)) 
+                tmp[1:length(ind)] <- .Call("AddOnes", tmpTree, as.integer(inord[a+1L]), as.integer(ind), as.integer(L[a]), as.integer(M[a]), PACKAGE="phangorn")
+                
+                if(ms < bound){
+                    bound = ms
+                    if(trace)cat("upper bound:", bound, "\n") 
+                    result = tmp    
+                    PSC = PSC[PSC[,3]<(bound+1e-8),]  
+                    
+                }
+                else result = c(result, tmp)  
+            }
+        }    
+        npsc = nrow(PSC)
+    }
+    for(i in 1:length(result)){
+        result[[i]] = structure(list(edge = result[[i]], Nnode = nTips-2L), .Names = c("edge", "Nnode"), class = "phylo", order = "postorder")
+    }
+    attr(result, "TipLabel") = tree$tip.label
+    class(result) <- "multiPhylo"
+    return(result)
+}
diff --git a/R/hadamard.R b/R/hadamard.R
index 533ac8f..f940fc6 100644
--- a/R/hadamard.R
+++ b/R/hadamard.R
@@ -75,11 +75,11 @@ split2seq = function(q){
 
 distanceHadamard <- function (dm, eps = 0.001) 
 {
-    if (class(dm) == "dist") {
+    if (inherits(dm,"dist")) {
         n <- attr(dm, "Size")
         Labels = attr(dm, "Labels")
     }
-    if (class(dm) == "matrix") {
+    if (inherits(dm,"matrix")) {
         n <- dim(dm)[1]
         Labels <- colnames(dm)
         dm <- dm[lower.tri(dm)]
@@ -112,7 +112,7 @@ distanceHadamard <- function (dm, eps = 0.001)
 h4st = function(obj, levels=c('a','c','g','t')){
     if (is.matrix(obj)) 
         obj = as.data.frame(t(obj))
-    if (class(obj) == "phyDat") 
+    if (inherits(obj,"phyDat")) 
         obj = as.data.frame(t(as.character(obj)))    
     #    if(is.matrix(obj)) obj = as.data.frame(t(obj))
     #    DNA = as.data.frame(obj)
@@ -165,7 +165,7 @@ h4st = function(obj, levels=c('a','c','g','t')){
 
 h2st <- function (obj, eps=0.001) 
 {
-    if (class(obj) != "phyDat") stop("Error") 
+    if (!inherits(obj,"phyDat")) stop("Error") 
     if (attr(obj,"nc") != 2)stop("Error")
     nr = attr(obj, "nr") #n
     p = length(obj) #p
diff --git a/R/modelTest.R b/R/modelTest.R
index 2fae133..da93060 100644
--- a/R/modelTest.R
+++ b/R/modelTest.R
@@ -1,11 +1,21 @@
-modelTest2 <- function (object, tree = NULL, model = c("JC", "F81", "K80", 
-    "HKY", "SYM", "GTR"), G = TRUE, I = TRUE, k = 4, freq=FALSE, 
+aic.weights <- function(aic){
+    diff.aic <- aic-min(aic)
+    exp(-0.5 * diff.aic) / sum(exp(-0.5 * diff.aic))
+}
+
+
+modelTest <- function (object, tree = NULL, model = c("JC", "F81", "K80", 
+    "HKY", "SYM", "GTR"), G = TRUE, I = TRUE, FREQ=FALSE, k = 4, 
     control = pml.control(epsilon = 1e-08, maxit = 10, trace = 1), 
-    multicore = FALSE, mc.cores = getOption("mc.cores", 1L)) 
+    multicore = FALSE, mc.cores = NULL) 
 {    
-    if (class(object) == "phyDat") 
+#    multicore = mc.cores > 1L
+    if(multicore && is.null(mc.cores)){
+        mc.cores <- detectCores()
+    }
+    if (inherits(object,"phyDat")) 
         data = object
-    if (class(object) == "pml") {
+    if (inherits(object,"pml")) {
         data = object$data
         if (is.null(tree)) 
             tree = object$tree
@@ -16,6 +26,8 @@ modelTest2 <- function (object, tree = NULL, model = c("JC", "F81", "K80",
                                            "TIM1", "TIM2e", "TIM2", "TIM3e", "TIM3", "TVMe", "TVM", 
                                            "SYM", "GTR")
     if(attr(data, "type")=="AA") type = .aamodels   
+    
+    if( (length(model)==1) && model == "all") model <- type
     model = match.arg(model, type, TRUE)
     
     env = new.env()
@@ -32,13 +44,12 @@ modelTest2 <- function (object, tree = NULL, model = c("JC", "F81", "K80",
     fit = pml(tree, data)
     fit = optim.pml(fit, control = control)
     l = length(model)
-    if(attr(fit$data, "type")=="DNA")freq=FALSE    
-    n = 1L + sum(I + G + (G & I) + freq + (freq & I) + (freq & G) + (freq & G & I))
+    if(attr(fit$data, "type")=="DNA")FREQ=FALSE    
+    n = 1L + sum(I + G + (G & I) + FREQ + (FREQ & I) + (FREQ & G) + (FREQ & G & I))
     nseq = sum(attr(data, "weight"))
     
     
-    
-    fitPar = function(model, fit, G, I, k, freq) {
+    fitPar = function(model, fit, G, I, k, FREQ) {
         m = 1
         res = matrix(NA, n, 6)
         res = as.data.frame(res)
@@ -58,10 +69,10 @@ modelTest2 <- function (object, tree = NULL, model = c("JC", "F81", "K80",
         trees[[m]] = fittmp$tree
         m = m + 1
         if (I) {
-            if(trace>0)print(paste(model, "+I", sep = ""))
+            if(trace>0)print(paste0(model, "+I"))
             fitI = optim.pml(fittmp, model = model, optInv = TRUE, 
                              control = control)
-            res[m, 1] = paste(model, "+I", sep = "")
+            res[m, 1] = paste0(model, "+I")
             res[m, 2] = fitI$df
             res[m, 3] = fitI$logLik
             res[m, 4] = AIC(fitI)
@@ -72,11 +83,11 @@ modelTest2 <- function (object, tree = NULL, model = c("JC", "F81", "K80",
             m = m + 1
         }
         if (G) {
-            if(trace>0)print(paste(model, "+G", sep = ""))
+            if(trace>0)print(paste0(model, "+G"))
             fitG = update(fittmp, k = k)
             fitG = optim.pml(fitG, model = model, optGamma = TRUE, 
                              control = control)
-            res[m, 1] = paste(model, "+G", sep = "")
+            res[m, 1] = paste0(model, "+G")
             res[m, 2] = fitG$df
             res[m, 3] = fitG$logLik
             res[m, 4] = AIC(fitG)
@@ -87,11 +98,11 @@ modelTest2 <- function (object, tree = NULL, model = c("JC", "F81", "K80",
             m = m + 1
         }
         if (G & I) {
-            if(trace>0)print(paste(model, "+G+I", sep = ""))
+            if(trace>0)print(paste0(model, "+G+I"))
             fitGI = update(fitI, k = k)
             fitGI = optim.pml(fitGI, model = model, optGamma = TRUE, 
                               optInv = TRUE, control = control)
-            res[m, 1] = paste(model, "+G+I", sep = "")
+            res[m, 1] = paste0(model, "+G+I")
             res[m, 2] = fitGI$df
             res[m, 3] = fitGI$logLik
             res[m, 4] = AIC(fitGI)
@@ -101,11 +112,11 @@ modelTest2 <- function (object, tree = NULL, model = c("JC", "F81", "K80",
             trees[[m]] = fitGI$tree
             m = m + 1
         }
-        if (freq) {
-            if(trace>0)print(paste(model, "+F", sep = ""))
+        if (FREQ) {
+            if(trace>0)print(paste0(model, "+F"))
             fitF = optim.pml(fittmp, model = model, optBf = TRUE, 
                              control = control)
-            res[m, 1] = paste(model, "+F", sep = "")
+            res[m, 1] = paste0(model, "+F")
             res[m, 2] = fitF$df
             res[m, 3] = fitF$logLik
             res[m, 4] = AIC(fitF)
@@ -115,12 +126,12 @@ modelTest2 <- function (object, tree = NULL, model = c("JC", "F81", "K80",
             trees[[m]] = fitF$tree
             m = m + 1
         }
-        if (freq & I) {
-            if(trace>0)print(paste(model, "+I+F", sep = ""))
+        if (FREQ & I) {
+            if(trace>0)print(paste0(model, "+I+F"))
             fitIF <- update(fitF, inv = fitI$inv)
             fitIF = optim.pml(fitIF, model = model, optBf = TRUE, optInv = TRUE,
                               control = control)
-            res[m, 1] = paste(model, "+I+F", sep = "")
+            res[m, 1] = paste0(model, "+I+F")
             res[m, 2] = fitIF$df
             res[m, 3] = fitIF$logLik
             res[m, 4] = AIC(fitIF)
@@ -130,12 +141,12 @@ modelTest2 <- function (object, tree = NULL, model = c("JC", "F81", "K80",
             trees[[m]] = fitIF$tree
             m = m + 1
         }
-        if (freq & G) {
-            if(trace>0)print(paste(model, "+G+F", sep = ""))
+        if (FREQ & G) {
+            if(trace>0)print(paste0(model, "+G+F"))
             fitGF <- update(fitF, k=k, shape=fitG$shape)
             fitGF = optim.pml(fitGF, model = model, optBf = TRUE, optGamma = TRUE, 
                               control = control)
-            res[m, 1] = paste(model, "+G+F", sep = "")
+            res[m, 1] = paste0(model, "+G+F")
             res[m, 2] = fitGF$df
             res[m, 3] = fitGF$logLik
             res[m, 4] = AIC(fitGF)
@@ -145,12 +156,12 @@ modelTest2 <- function (object, tree = NULL, model = c("JC", "F81", "K80",
             trees[[m]] = fitGF$tree
             m = m + 1
         }
-        if (freq & G & I) {
-            if(trace>0)print(paste(model, "+G+I+F", sep = ""))
+        if (FREQ & G & I) {
+            if(trace>0)print(paste0(model, "+G+I+F"))
             fitGIF <- update(fitIF, k=k)
-            fitGIF = optim.pml(fitGIF, model = model, optBf = TRUE, optInv = TRUE, , optGamma = TRUE, 
+            fitGIF = optim.pml(fitGIF, model = model, optBf = TRUE, optInv = TRUE, optGamma = TRUE, 
                                control = control)
-            res[m, 1] = paste(model, "+G+I+F", sep = "")
+            res[m, 1] = paste0(model, "+G+I+F")
             res[m, 2] = fitGIF$df
             res[m, 3] = fitGIF$logLik
             res[m, 4] = AIC(fitGIF)
@@ -160,8 +171,6 @@ modelTest2 <- function (object, tree = NULL, model = c("JC", "F81", "K80",
             trees[[m]] = fitGIF$tree
             m = m + 1
         }
-        
-        
         list(res, trees, calls)
     }
     eval.success <- FALSE
@@ -171,21 +180,27 @@ modelTest2 <- function (object, tree = NULL, model = c("JC", "F81", "K80",
         #            warning("package 'parallel' not found or GUI is used, \n      analysis is performed in serial")
         #       }
         #        else {
-        RES <- mclapply(model, fitPar, fit, G, I, k, freq, mc.cores=mc.cores)
+        RES <- mclapply(model, fitPar, fit, G, I, k, FREQ, mc.cores=mc.cores)
         eval.success <- TRUE
         #        }
     }
     if (!eval.success) 
-        RES <- lapply(model, fitPar, fit, G, I, k, freq)
+        RES <- lapply(model, fitPar, fit, G, I, k, FREQ)
     #   res <- RES <- lapply(model, fitPar, fit, G, I, k, freq)    
-    RESULT = matrix(NA, n * l, 6)
+#    RESULT = matrix(NA, n * l, 6)
+#    RESULT = as.data.frame(RESULT)
+#    colnames(RESULT) = c("Model", "df", "logLik", "AIC", "AICc", "BIC")
+    RESULT = matrix(NA, n * l, 8)
     RESULT = as.data.frame(RESULT)
-    colnames(RESULT) = c("Model", "df", "logLik", "AIC", "AICc", "BIC")
-    for (i in 1:l) RESULT[((i - 1) * n + 1):(n * i), ] = RES[[i]][[1]]
+    colnames(RESULT) = c("Model", "df", "logLik", "AIC", "AICw", "AICc", "AICcw", "BIC")
+    
+    for (i in 1:l) RESULT[((i - 1) * n + 1):(n * i), c(1,2,3,4,6,8)] = RES[[i]][[1]]
+    RESULT[,5] <- aic.weights(RESULT[,4])
+    RESULT[,7] <- aic.weights(RESULT[,6])
     for(i in 1:l){
         for(j in 1:n){
             mo = RES[[i]][[1]][j,1]
-            tname = paste("tree_", mo, sep = "")
+            tname = paste0("tree_", mo)
             tmpmod = RES[[i]][[3]][[j]]
             tmpmod["tree"] = call(tname)
             if(!is.null(tmpmod[["k"]]))tmpmod["k"] = k
@@ -199,3 +214,5 @@ modelTest2 <- function (object, tree = NULL, model = c("JC", "F81", "K80",
 }
 
 
+
+
diff --git a/R/networx.R b/R/networx.R
index 896bbb8..0d24075 100644
--- a/R/networx.R
+++ b/R/networx.R
@@ -8,7 +8,7 @@ as.splits <- function (x, ...){
 
 
 as.Matrix <- function (x, ...){
-    if (class(x) == "Matrix") return(x)
+    if (inherits(x,"Matrix")) return(x)
     UseMethod("as.Matrix")
 }
 
@@ -54,25 +54,37 @@ print.splits <- function (x, maxp = getOption("max.print"),
     result
 }
 
-
-orderSplitLabel = function(x, order){
-    label = attr(x, "labels")
-    nTips = length(label)
-    ord = match(label, order)
+changeOrder <- function(x, labels){
+    oldL <- attr(x, "labels")
+    ind <- match(oldL,labels)
     for(i in 1:length(x))
-        x[[i]] = sort(ord[x[[i]]])
-    attr(x, "labels") = order
-    x
+        x[[i]] <- sort(ind[x[[i]]])
+    if(!is.null(attr(x, "cycle")))
+        attr(x, "cycle") <- ind[attr(x, "cycle")]
+    attr(x, "labels") <- labels
+    x    
 }
 
 
-presenceAbsence <- function(x, y){
+#orderSplitLabel = function(x, order){
+#    label = attr(x, "labels")
+#    nTips = length(label)
+#    ord = match(label, order)
+#    for(i in 1:length(x))
+#        x[[i]] = sort(ord[x[[i]]])
+#    attr(x, "labels") = order
+#    x
+#}
+
+
+# returns order of x$edge
+presenceAbsenceOld <- function(x, y){
     X <- as.splits(x)
     Y <- as.splits(y)
     labels <- attr(X, "labels") 
-    if(class(x)[1] == "phylo") X <- X[x$edge[,2]]
-    if(class(y)[1] == "phylo") Y <- Y[y$edge[,2]]
-    Y <- orderSplitLabel(Y, labels)
+    #    if(inherits(x,"phylo")) X <- X[x$edge[,2]]
+    #    if(inherits(y,"phylo")) Y <- Y[y$edge[,2]]
+    Y <- changeOrder(Y, labels) # orderSplitLabel
     nTips <- length(labels)
     X <- oneWise(X, nTips)
     Y <- oneWise(Y, nTips)
@@ -81,10 +93,34 @@ presenceAbsence <- function(x, y){
     if(inherits(x, "networx")){
         res <- res[x$splitIndex]    
     }    
+    if(class(x)[1]=="phylo"){
+        # res <- res[x$edge[,2]]
+        x$node.label = res[-c(1:length(labels))]
+        return(x)
+    }
     res            
 }
 
 
+presenceAbsence <- function(x,y){
+    spl <- as.splits(y)
+    l <- length(spl)
+    attr(spl, "confidences") <- rep(1, l)
+    addConfidences(x, y)
+}
+
+
+matchSplits <- function(x, y, as.in=TRUE){
+    tiplabel <- attr(x, "label")
+    if(any(is.na(match(tiplabel, attr(y, "label"))))) stop("x and y have different labels!")
+    nTips <- length(tiplabel)
+    y <- changeOrder(y, tiplabel)
+    y <- SHORTwise(y, nTips)
+    if(as.in) return(match(SHORTwise(x, nTips), y, nomatch = 0L) > 0L)
+    match(SHORTwise(x, nTips), y)
+}
+
+
 optCycle <- function(splits, tree){
     tips = tree$tip.label
     tree = reorder(tree)
@@ -152,27 +188,39 @@ c.splits <- function (..., recursive=FALSE)
 }
 
 
+## as.splits.phylo
 # computes splits from phylo
 as.splits.phylo <- function(x, ...){
-    result = bip(x)
+    result <- bip(x)
     if(!is.null(x$edge.length)){
-        edge.weights = numeric(max(x$edge))
-        edge.weights[x$edge[,2]] = x$edge.length
-        attr(result, "weights") = edge.weights
+        edge.weights <- numeric(max(x$edge))
+        edge.weights[x$edge[,2]] <- x$edge.length
+        attr(result, "weights") <- edge.weights
     }
-    attr(result, "labels") <- x$tip
-    class(result) = c('splits', 'prop.part')
+    if(!is.null(x$node.label)){
+        conf <- x$node.label
+        if(is.character(conf)) conf <- as.numeric(conf)
+        if(max(na.omit(conf)) > (1 + 1e-8))conf <- conf / 100
+        #if(!is.null(scale)) conf <- conf / scale
+        attr(result, "confidences") <- c(rep(1, length(x$tip.label)), conf)
+#        attr(result, "confidences") <- c(rep("", length(x$tip.label)), x$node.label)
+    }    
+    attr(result, "labels") <- x$tip.label
+    class(result) <- c('splits', 'prop.part')
     result 
 }
 
 
 # computes splits from multiPhylo object (e.g. bootstrap, MCMC etc.)
+# unrooted trees
 as.splits.multiPhylo <- function(x, ...){
-    if(class(x)=="multiPhylo")x = .uncompressTipLabel(x)
-    lx = length(x)
-    if(class(x)=="multiPhylo")class(x)='list'  # prop.part allows not yet multiPhylo
-    firstTip = x[[1]]$tip[1]
-    x = lapply(x, root, firstTip) # old trick  
+#    if(inherits(x,"multiPhylo"))x = .uncompressTipLabel(x)
+#    if(inherits(x,"multiPhylo"))class(x)='list'  # prop.part allows not yet multiPhylo
+#    firstTip = x[[1]]$tip[1]
+#    x = lapply(x, root, firstTip) # old trick 
+    lx <-  length(x)
+    x <- lapply(x, unroot)
+    class(x) <- "multiPhylo"
     splits <- prop.part(x)
     class(splits)='list'
     weights = attr(splits, 'number')    
@@ -183,7 +231,8 @@ as.splits.multiPhylo <- function(x, ...){
     for(i in 1:l) splitTips[[i]] = i
     result = c(splitTips,splits)
     attr(result, "weights") = c(rep(lx, l), weights)
-    attr(result, "confidences") <- attr(result, "weights")
+    attr(result, "confidences") <- attr(result, "weights") / lx
+    attr(result, "summary") <- list(confidences="ratio", ntrees=l, clades=FALSE) 
     attr(result, "labels") <- lab
     class(result) = c('splits', 'prop.part')
     result  
@@ -193,9 +242,9 @@ as.splits.multiPhylo <- function(x, ...){
 as.splits.prop.part <- function(x, ...){
     if(is.null(attr(x, "number")))  
         attr(x, "weights") = rep(1, length(x)) 
-	  else{ 
+	 else{ 
         attr(x, "weights") = attr(x, "number")
-        attr(x, "confidences") = attr(x, "number") 
+        attr(x, "confidences") = attr(x, "number") / attr(x, "number")[1] 
    	}    
     class(x) = c('splits', 'prop.part')	
     x
@@ -203,7 +252,8 @@ as.splits.prop.part <- function(x, ...){
 
 
 as.splits.networx <- function(x, ...){
-    if(!is.null(attr(x, "splits")))attr(x, "splits")
+#    if(!is.null(attr(x, "splits")))attr(x, "splits")
+    if(!is.null(x$splits)) x$splits
     else warning("No split object included!")    
 }
 
@@ -215,7 +265,7 @@ as.prop.part.splits <- function(x, ...){
     x
 }
 
-
+## as.splits.phylo
 as.phylo.splits <- function (x, result = "phylo", ...) 
 {
     result <- match.arg(result, c("phylo", "all"))
@@ -507,25 +557,48 @@ splits2design <- function(obj, weight=NULL){
 }
 
 
+hC <- function(g, set){
+    intersec = NULL
+    allEdges = NULL
+    fromTo <- set
+    l = length(set)
+    sptmp = shortest_paths(g, fromTo[l], fromTo[1], output=c("epath"))$epath[[1]]
+    sptmp = as.vector(sptmp)
+    allEdges = sptmp
+    for(i in 2:length(set)){
+        sptmp = shortest_paths(g, fromTo[i-1], fromTo[i], output=c("epath"))$epath[[1]]
+        sptmp = as.vector(sptmp)
+        intersec = c(intersec, intersect(allEdges, sptmp) )
+        allEdges = c(allEdges, sptmp)
+    }
+    #    allEdges = unique(allEdges)
+    list(allEdges, unique(allEdges), intersec)
+}   
+
+
 addEdge <- function(network, desc, spl){   
     edge <- network$edge
     parent <- edge[,1]
     child <- edge[,2]
     nTips <- length(network$tip.label)
 
-    desc2 = SHORTwise(desc, nTips)    
+    desc2 <- SHORTwise(desc, nTips)    
     split <- desc2[spl]
         
-    index = network$splitIndex
-    ind = which(compatible2(split, desc2[index]) == 1)
-    if(is.null(ind)) return(network)
-    add = TRUE
+    index <- network$splitIndex
+    ind <- which(compatible2(split, desc2[index]) == 1)
+    if(is.null(ind) | (length(ind)==0)) return(network)
+    add <- TRUE
   
-    X = as.matrix(desc2)
-    rsX = rowSums(X)
-    z = X %*% X[spl,]
-    v = which((rsX == z)[index] == TRUE) 
+    X <- as.matrix(desc2)
+    rsX <- rowSums(X)
+    z <- X %*% X[spl,]
+    v <- which((rsX == z)[index] == TRUE) 
 
+    
+# intersection of shortest pathes of both partitions
+# best with similar to circNetwork with shortest_paths 
+    
     while(add){
         tmp = ind
         for(i in ind){          
@@ -538,6 +611,17 @@ addEdge <- function(network, desc, spl){
         }
         ind=tmp
     }    
+   
+
+    g = graph(t(network$edge[ind,]), directed=FALSE)
+    dec = decompose(g, min.vertices = 2)
+
+    #    fromTo <- sort(match(split[[1]], attr(desc, "cycle")))
+    #    sptmp = shortest_paths(g, fromTo[i-1], fromTo[i], 
+    #                           output=c("epath"))$epath[[1]]
+    #    sp2 = c(sp2, sptmp[-c(1, length(sptmp))])
+    #    sp0 = c(sp0, sptmp)
+    
     oldNodes = unique(as.vector(edge[ind,]))
     mNodes = max(network$edge)
     newNodes = (mNodes+1L) : (mNodes+length(oldNodes))
@@ -563,7 +647,7 @@ addEdge <- function(network, desc, spl){
     network   
 }
 
-
+## as.splits.phylo
 circNetwork <- function(x, ord=NULL){
     if(is.null(ord))ord = attr(x, "cycle")
     
@@ -575,7 +659,6 @@ circNetwork <- function(x, ord=NULL){
     res = stree(nTips, tip.label = attr(x, "labels"))
     res$edge[, 2] = ord
     res$edge.length=NULL
-#    browser()    
     x <- SHORTwise(x, nTips)    
     spRes <- as.splits(res)[res$edge[,2]]
     index = match(spRes, x)
@@ -631,7 +714,9 @@ circNetwork <- function(x, ord=NULL){
         sp0 = NULL
         
         for(i in 2:length(fromTo)){
-            sptmp = get.shortest.paths(g, fromTo[i-1], fromTo[i], 
+#            sptmp = get.shortest.paths(g, fromTo[i-1], fromTo[i], 
+#                                       output=c("epath"))$epath[[1]]            
+            sptmp = shortest_paths(g, fromTo[i-1], fromTo[i], 
                                        output=c("epath"))$epath[[1]]
             sp2 = c(sp2, sptmp[-c(1, length(sptmp))])
             sp0 = c(sp0, sptmp)
@@ -684,12 +769,12 @@ circNetwork <- function(x, ord=NULL){
         res$edge.length <- rep(1, nrow(res$edge))
         class(res) = c("networx", "phylo")
         attr(res, "order") = NULL
-        #browser() 
     }
     res$Nnode =  max(res$edge) - nTips
-    res$splitIndex = index 
     res$edge.length = weight[index]  # ausserhalb
-    attr(res, "splits") = x
+    res$splitIndex = index 
+#    attr(res, "splits") = x
+    res$splits = x
     class(res) = c("networx", "phylo")
     attr(res, "order") = NULL
     res    
@@ -706,7 +791,7 @@ as.networx <- function (x, ...)
 
 getOrdering <- function(x){
     tree = as.phylo(x)
-    nTips = length(tree$tip)
+    nTips = length(tree$tip.label)
     ord = reorder(tree)$edge[,2]
     ord = ord[ord<=nTips]
     ind = which(ord == 1L)
@@ -714,7 +799,7 @@ getOrdering <- function(x){
     ord  
 }
 
-
+## as.splits.phylo
 addTrivialSplits <- function(obj){
     label <- attr(obj, "label")
     nTips <- length(label)
@@ -734,7 +819,7 @@ addTrivialSplits <- function(obj){
 }
 
 
-as.networx.splits <- function(x, planar=FALSE, ...){
+as.networx.splits <- function(x, planar=FALSE, coord = c("none", "2D", "3D"), ...){
   label <- attr(x, "label")
   
   x = addTrivialSplits(x)
@@ -781,13 +866,37 @@ as.networx.splits <- function(x, planar=FALSE, ...){
     tmp$Nnode = max(tmp$edge) - nTips
     tmp$edge.length = weight[tmp$splitIndex]
     attr(x, "cycle") <- c.ord
-    attr(tmp, "splits") = x 
+#    attr(tmp, "splits") = x 
+    tmp$splits <- x
     class(tmp) = c("networx", "phylo")
     tmp <- reorder(tmp)
+    coord <- match.arg(coord)
+    vert <- switch(coord,
+           "none" = NULL,
+           "2D" = coords(tmp, dim="2D"),
+           "3D" = coords(tmp, dim="3D"))
+#    attr(tmp, "coords") <- coordinates
+    tmp$plot <- list(vertices=vert)
     tmp
 }
 
 
+#as.networx.phylo <- function(x, ...){
+#    spl <- as.splits(x)
+#    as.networx(x, ...)
+#}
+
+## as.splits.phylo
+as.networx.phylo <- function(x, ...){
+    spl <- as.splits(x)
+    spl <- spl[x$tree[,2]]
+    x$splitIndex <- 1:nrow(x$edge)
+    attr(x, "splits") = spl
+    class(x) <- c("networx", "phylo")
+    x
+}
+
+
 #as.igraph.networx <- function(x, directed=FALSE){
 #    graph(t(x$edge), directed=directed)
 #}
@@ -800,7 +909,7 @@ consensusNet <- function (obj, prob = 0.3, ...)
     w = attr(spl, "weights")
     ind = (w/l) > prob
     spl = spl[ind]
-    attr(spl, "confidences") = round((w/l)[ind]*100)
+    attr(spl, "confidences") = (w/l)[ind]
 #    attr(spl, "weights") = w[ind]
     res = as.networx(spl)  
     res$edge.labels = as.character(res$edge.length / l * 100)
@@ -809,60 +918,95 @@ consensusNet <- function (obj, prob = 0.3, ...)
 }
 
 
-addConfidences <- function (obj, phy) UseMethod("addConfidences")
+createLabel <- function(x, y, label_y, type="edge", nomatch=NA){
+    spl_x <- as.splits(x)
+    if(inherits(x, "phylo", TRUE)==1) spl_x <- spl_x[x$edge[,2]]
+    spl_y <- as.splits(y)
+    if(inherits(y, "phylo", TRUE)==1) spl_y <- spl_y[y$edge[,2]]
+    
+    tiplabel <- attr(spl_x, "label")
+    nTips <- length(tiplabel)
+    
+    spl_y <- changeOrder(spl_y, tiplabel)
+    spl_y <- SHORTwise(spl_y, nTips)
+    
+    ind <- match(SHORTwise(spl_x, nTips), spl_y)
+    pos <-  which(!is.na(ind))
+
+    res <- rep(nomatch, length(spl_x))
+    
+    if(length(label_y)==1L) label_y <- rep(label_y, length(spl_y))
+    res[pos] <- label_y[ind[pos]]
+    if(type=="edge" && inherits(x, "networx")){
+        return(res[x$splitIndex])
+    }
+    res  
+}
 
 
+addConfidences <- function (x, y, ...) UseMethod("addConfidences")
 
-addConfidences.splits <- function(obj, phy){
-    tiplabel <- attr(obj, "label")
-    obj = addTrivialSplits(obj) 
-    ind <- match(tiplabel, phy$tip.label)
-    if (any(is.na(ind)) | length(tiplabel) != length(phy$tip.label)) 
-        stop("trees have different labels")
-    phy$tip.label <- phy$tip.label[ind]
-    ind2 <- match(1:length(ind), phy$edge[, 2])
-    phy$edge[ind2, 2] <- order(ind)
-    
-    spl <- as.splits(phy)
-    
-    nTips <- length(tiplabel)
+
+# y now more general 
+addConfidences.splits <- function(x, y, ...){
+    tiplabel <- attr(x, "label")
+    nTips = length(tiplabel)
+#    x = addTrivialSplits(x) 
+    if(inherits(y,"phylo")){
+        ind <- match(tiplabel, y$tip.label)
+        if (any(is.na(ind)) | length(tiplabel) != length(y$tip.label)) 
+            stop("trees have different labels")
+        y$tip.label <- y$tip.label[ind]
+        ind2 <- match(1:length(ind), y$edge[, 2])
+        y$edge[ind2, 2] <- order(ind)
+    }
+    spl <- as.splits(y)
+    spl <- changeOrder(spl, tiplabel)
     spl <- SHORTwise(spl, nTips)
-    ind <- match(SHORTwise(obj, nTips), spl)
-    pos <-  which(ind > nTips)
-    confidences <- character(length(obj))
-    confidences[pos] <- phy$node.label[ind[pos] - nTips]
-    attr(obj, "confidences") <- confidences
-    obj  
+#    ind <- match(SHORTwise(x, nTips), spl)
+#    ind
+    ind <- match(SHORTwise(x, nTips), spl)
+    #    pos <-  which(ind > nTips)
+    pos <-  which(!is.na(ind))
+    confidences <- numeric(length(x))  #character 
+    confidences[pos] <- attr(spl, "confidences")[ind[pos]]
+    #        y$node.label[ind[pos] - nTips]
+    attr(x, "confidences") <- confidences
+    x  
 }
 
 
-addConfidences.networx <- function(obj, phy){
-    spl <- attr(obj, "splits")
-    spl <- addConfidences(spl, phy)
-    attr(obj, "splits") <- spl
-    obj    
+addConfidences.networx <- function(x, y, ...){
+    spl <- x$splits
+    spl <- addConfidences(spl, y, ...)
+    x$splits <- spl
+    x    
 }
 
-
-addConfidences.phylo <- function(obj, phy){
-    conf = attr(addConfidences(as.splits(obj), phy), "confidences")
-    nTips = length(obj$tip.label)
-    obj$node.label = conf[-c(1:nTips)]
-    obj      
+## as.splits.phylo
+addConfidences.phylo <- function(x, y, ...){
+#    call <- x$call
+    conf = attr(addConfidences(as.splits(x), y), "confidences")
+    if(is.character(conf)) conf <- as.numeric(conf)
+    nTips = length(x$tip.label)
+    x$node.label = conf[-c(1:nTips)]  * 100
+    x      
 } 
 
 
-reorder.networx <- function (x, order =  "cladewise", ...) 
+reorder.networx <- function (x, order =  "cladewise", index.only = FALSE, ...) 
 {
     order <- match.arg(order, c("cladewise", "postorder"))
     if (!is.null(attr(x, "order"))) 
         if (attr(x, "order") == order) 
             return(x)    
     g <- graph(t(x$edge))
-    if(order == "cladewise") neword <- topological.sort(g, "out")
-    else neword <- topological.sort(g, "in") 
+#    if(order == "cladewise") neword <- topological.sort(g, "out")
+#    else neword <- topological.sort(g, "in") 
+    if(order == "cladewise") neword <- topo_sort(g, "out")
+    else neword <- topo_sort(g, "in") 
     neworder <- order(match(x$edge[,1], neword))
-    
+    if(index.only) return(neworder)
     x$edge <- x$edge[neworder, ]
     if (!is.null(x$edge.length)) 
         x$edge.length <- x$edge.length[neworder]
@@ -882,42 +1026,45 @@ coords <- function(obj, dim="3D"){
     ind1 = which(!duplicated(obj$splitIndex))
 
     n = max(obj$edge)
-    adj = Matrix::spMatrix(n, n, i = obj$edge[,2], j = obj$edge[,1], x = rep(1, length(obj$edge.length)))
-    g = graph.adjacency(adj, "undirected")
+    adj = spMatrix(n, n, i = obj$edge[,2], j = obj$edge[,1], x = rep(1, length(obj$edge.length))) # Matrix::
+    g = graph_from_adjacency_matrix(adj, "undirected")
+#    g = graph.adjacency(adj, "undirected")
 ##########
 #    add this 
 #    g2 <- graph(t(obj$edge), directed=FALSE)
 #    g2 <- set.edge.attribute(g, "weight", value=rep(1, nrow(obj$edge))
     if(dim=="3D"){
-        coord <- layout.kamada.kawai(g, dim=3)
-        k = matrix(0, max(obj$split), 3)
+        coord <- layout_with_kk(g, dim=3)
+#        coord <- layout.kamada.kawai(g, dim=3)
+        k = matrix(0, max(obj$splitIndex), 3)
         for(i in ind1){
             tmp = coord[obj$edge[i, 2],] - coord[obj$edge[i, 1],]
-            k[obj$split[i], ] = kart2kugel(tmp[1], tmp[2], tmp[3])
+            k[obj$splitIndex[i], ] = kart2kugel(tmp[1], tmp[2], tmp[3])
         }
-        k[obj$split[ind1],1] = obj$edge.length[ind1] 
+        k[obj$splitIndex[ind1],1] = obj$edge.length[ind1] 
 
         res = matrix(0, vcount(g), 3)
-        for(i in 1:l){# unique(obj$split)
+        for(i in 1:l){# unique(obj$splitIndex)
             j = obj$edge[i,1]
             m = obj$edge[i,2]
-            p = obj$split[i]
+            p = obj$splitIndex[i]
             res[m,] = res[j,] + kugel2kart(k[p,1], k[p,2], k[p,3])     
         }            
     }
     else{
-        coord <- layout.kamada.kawai(g, dim=2)
-        k = matrix(0, max(obj$split), 2)
+        coord <- layout_with_kk(g, dim=2)
+#        coord <- layout.kamada.kawai(g, dim=2)
+        k = matrix(0, max(obj$splitIndex), 2)
         for(i in ind1){
             tmp = coord[obj$edge[i, 2],] - coord[obj$edge[i, 1],]
-            k[obj$split[i], ] = kart2kreis(tmp[1], tmp[2])
+            k[obj$splitIndex[i], ] = kart2kreis(tmp[1], tmp[2])
         }
-        k[obj$split[ind1],1] = obj$edge.length[ind1] 
+        k[obj$splitIndex[ind1],1] = obj$edge.length[ind1] 
         res = matrix(0, vcount(g), 2)
-        for(i in 1:l){# unique(obj$split)
+        for(i in 1:l){# unique(obj$splitIndex)
             j = obj$edge[i,1]
             m = obj$edge[i,2]
-            p = obj$split[i]
+            p = obj$splitIndex[i]
             res[m,] = res[j,] + kreis2kart(k[p,1], k[p,2])     
         }
     }  
@@ -966,61 +1113,89 @@ edgeLabels <- function(xx,yy,zz=NULL, edge){
         cbind(XX, YY)  
 }
 
-.check.pkg <- function (pkg) 
-{
-    if (pkg %in% rownames(installed.packages())) {
-        require(pkg, character.only = TRUE)
-        return(TRUE)
-    }
-    else return(FALSE)
-}
-
 
 plot.networx = function(x, type="3D", use.edge.length = TRUE, show.tip.label=TRUE,
     show.edge.label=FALSE, edge.label=NULL, show.node.label = FALSE, node.label=NULL,
-    show.nodes=FALSE, tip.color = "blue", 
-    edge.color="grey", edge.width = 3, edge.lty = 1,
-    font = 3, cex = 1, ...){
+    show.nodes=FALSE, tip.color = "black", 
+    edge.color="black", edge.width = 3, edge.lty = 1,
+    split.color=NULL, split.width = NULL, split.lty = NULL,
+    font = 3, cex = par("cex"), 
+    cex.node.label=cex, cex.edge.label=cex,
+    col.node.label = tip.color, col.edge.label = tip.color, 
+    font.node.label = font, font.edge.label = font,
+    ...){
     type = match.arg(type, c("3D", "2D")) 
     if(use.edge.length==FALSE) x$edge.length[] = 1
-    x = reorder(x)
+# test    
+#    x = reorder(x)
     nTips = length(x$tip.label)
-    conf = attr(attr(x, "splits"),"confidences") 
+    conf = attr(x$splits,"confidences") * 100
     index = x$splitIndex
     if(is.null(edge.label) & !is.null(conf))edge.label = conf[index]
     if(is.null(node.label))node.label = as.character(1:max(x$edge))
     if(show.tip.label)node.label[1:nTips] = ""
     
-    chk <- FALSE
-    
+    lspl <- max(x$splitIndex)
+    if(!is.null(split.color)){
+        if(length(split.color)!=lspl) stop("split.color must be same length as splits")
+        else edge.color <- split.color[x$splitIndex]
+    } 
+    if(!is.null(split.width)){
+        if(length(split.width)!=lspl) stop("split.color must be same length as splits")
+        else edge.width <- split.width[x$splitIndex]
+    } 
+    if(!is.null(split.lty)){
+        if(length(split.lty)!=lspl) stop("split.color must be same length as splits")
+        else edge.lty <- split.lty[x$splitIndex]
+    } 
     
+    chk <- FALSE
     
     if(type=="3D") chk <- requireNamespace("rgl", quietly = TRUE) #.check.pkg("rgl")
     if(!chk && type=="3D"){
         warning("type=\"3D\" requires the package \"rgl\"\n, plotting =\"2D\" instead!\n")
         type="2D"
     }
+    # use precomputed vertices when available
+    coord <- NULL
+    if(!is.null(x$.plot)) coord <- x$.plot$vertices
+    
     if(type=="3D") {
-        coord <- coords(x, dim="3D")
+        if(is.null(coord) || ncol(coord)!=3)        
+            coord <- coords(x, dim="3D")
         plotRGL(coord, x, show.tip.label=show.tip.label, show.edge.label=show.edge.label, 
              edge.label = edge.label, show.node.label = show.node.label, node.label=node.label, 
              show.nodes=show.nodes, tip.color = tip.color, edge.color=edge.color, 
-             edge.width = edge.width, font = font, cex = cex)
+             edge.width = edge.width, font = font, cex = cex, 
+             cex.node.label=cex.node.label, cex.edge.label=cex.edge.label,
+             col.node.label = col.node.label, col.edge.label = col.edge.label,
+             font.node.label = font.node.label, font.edge.label = font.edge.label)
     }
     else{
-	    coord <- coords(x, dim="2D")
+        if(is.null(coord) || ncol(coord)!=2)
+     	    coord <- coords(x, dim="2D")
 	    plot2D(coord, x, show.tip.label=show.tip.label, show.edge.label=show.edge.label, 
 	        edge.label = edge.label, show.node.label = show.node.label, node.label=node.label,
 	        show.nodes=show.nodes, tip.color = tip.color, edge.color=edge.color,
-	        edge.width = edge.width, edge.lty=edge.lty,font = font, cex = cex, add=FALSE)
-	}    
+	        edge.width = edge.width, edge.lty=edge.lty,font = font, cex = cex, 
+	        cex.node.label=cex.node.label, cex.edge.label=cex.edge.label,
+	        col.node.label = col.node.label, col.edge.label = col.edge.label,
+	        font.node.label = font.node.label, font.edge.label = font.edge.label,
+	        add=FALSE)
+    }   
+    x$.plot <- list(vertices = coord, edge.color=edge.color, edge.width=edge.width, edge.lty = edge.lty)
+    invisible(x)
 }
 
     
 plotRGL <- function(coords, net, show.tip.label=TRUE, 
         show.edge.label=FALSE, edge.label=NULL, show.node.label=FALSE, node.label=NULL,
         show.nodes=FALSE, tip.color = "blue", edge.color="grey", 
-        edge.width = 3, font = 3, cex = par("cex"), ...){
+        edge.width = 3, font = 3, cex = par("cex"), 
+        cex.node.label=cex,  cex.edge.label=cex,
+        col.node.label=tip.color, col.edge.label=tip.color,
+        font.node.label=font, font.edge.label=font,        
+        ...){
     
 #    chk <- .check.pkg("rgl")
 #    if(!chk) open3d <- segments3d <- spheres3d <- rgl.texts <- function(...)NULL
@@ -1037,8 +1212,8 @@ plotRGL <- function(coords, net, show.tip.label=TRUE,
     z = coords[,3]
      
     nTips = length(net$tip.label)
-    
-    segments3d(x[t(edge)],y[t(edge)],z[t(edge)], col=edge.color, lwd=edge.width) 
+  
+    segments3d(x[t(edge)],y[t(edge)],z[t(edge)], col=rep(edge.color, each=2), lwd=edge.width) 
     radius=0
     if(show.nodes){
         radius = sqrt((max(x)-min(x))^2 + (max(y)-min(y))^2 + (max(z)-min(z))^2) / 200    
@@ -1046,16 +1221,19 @@ plotRGL <- function(coords, net, show.tip.label=TRUE,
         spheres3d(x[-c(1:nTips)], y[-c(1:nTips)],z[-c(1:nTips)], radius=radius, color="magenta")
     }
     if(show.tip.label){
-      rgl.texts(x[1:nTips]+2.05*radius,y[1:nTips],z[1:nTips],net$tip.label, color=tip.color, cex=cex, font=font)
+        if(is.null(net$translate))   
+        rgl.texts(x[1:nTips]+2.05*radius,y[1:nTips],z[1:nTips],net$tip.label, color=tip.color, cex=cex, font=font)
+        else
+        rgl.texts(x[net$translate$node]+2.05*radius,y[net$translate$node],z[net$translate$node],net$tip.label, color=tip.color, cex=cex, font=font)    
     }
     if(show.edge.label){
 	    ec = edgeLabels(x, y, z, edge)
       if(is.null(edge.label)) edge.label = net$splitIndex
         #else edge.label = net$splitIndex    
-	    rgl.texts(ec[,1], ec[,2], ec[,3], edge.label, color=tip.color, cex=cex, font=font)     
+	    rgl.texts(ec[,1], ec[,2], ec[,3], edge.label, color=col.edge.label, cex=cex.edge.label, font=font.edge.label)     
     } 
     if(show.node.label){
-        rgl.texts(x, y, z, node.label, color=tip.color, cex=cex, font=font) 
+        rgl.texts(x, y, z, node.label, color=col.node.label, cex=cex.node.label, font=font.node.label) 
     }
 }
 
@@ -1063,7 +1241,12 @@ plotRGL <- function(coords, net, show.tip.label=TRUE,
 plot2D <- function(coords, net, show.tip.label=TRUE,  
        show.edge.label=FALSE, edge.label=NULL, show.node.label=FALSE, node.label=NULL,
        tip.color = "blue", edge.color="grey",                   
-       edge.width = 3, edge.lty=1, font = 3, cex = par("cex"), add=FALSE, ...){
+       edge.width = 3, edge.lty=1, 
+       font = 3, cex = par("cex"), 
+       cex.node.label=cex,  cex.edge.label=cex,
+       col.node.label=tip.color, col.edge.label=tip.color,
+       font.node.label=font, font.edge.label=font,
+       add=FALSE, ...){
    edge = net$edge
    label = net$tip.label
    xx = coords[,1]
@@ -1086,33 +1269,53 @@ plot2D <- function(coords, net, show.tip.label=TRUE,
    }
    cladogram.plot(edge, xx, yy, edge.color, edge.width, edge.lty)
    if(show.tip.label){
-        ind=match(1:nTips, edge[,2])
+        if(is.null(net$translate)) ind=match(1:nTips, edge[,2])
+        else ind=match(net$translate$node, edge[,2])
         pos = rep(4, nTips)
         XX <- xx[edge[ind, 1]] - xx[edge[ind, 2]]
         pos[XX>0] = 2
         YY <- yy[edge[ind, 1]] - yy[edge[ind, 2]]
         pos2 <- rep(3, nTips)
         pos2[YY>0] = 1
+# needed if tiplabels are not at internal nodes        
+        XX[is.na(XX)] = 0
+        YY[is.na(YY)] = 0
         pos[abs(YY)>abs(XX)] <- pos2[abs(YY)>abs(XX)] 	
-        text(xx[1:nTips], yy[1:nTips], labels=label, pos=pos, col=tip.color, cex=cex, font=font)
+        if(is.null(net$translate)) text(xx[1:nTips], yy[1:nTips], labels=label, pos=pos, col=tip.color, cex=cex, font=font)
+        else text(xx[net$translate$node], yy[net$translate$node], labels=label, pos=pos, col=tip.color, cex=cex, font=font)
     }
     if(show.edge.label){
 	    ec = edgeLabels(xx,yy, edge=edge)
 	    if(is.null(edge.label))edge.label = net$splitIndex
-	    text(ec[,1], ec[,2], labels=edge.label, col=tip.color, cex=cex, font=font)     
-	    } 
+	    
+	    # show only one edge label
+	    em <- apply(ec, 1, function(x)max(abs(x)))
+	    si <- net$splitIndex
+	    for(i in unique(si)){
+	        tmp <- si==i
+	        if(sum(tmp)>1){
+	            w <- which(tmp)
+	            wm <- which.max(em[w])
+	            edge.label[w[-wm]] <- ""
+	        }
+	    }
+	    
+	    text(ec[,1], ec[,2], labels=edge.label, col=col.edge.label, cex=cex.edge.label, font=font.edge.label)     
+	} 
     if(show.node.label){
-         text(xx, yy, labels=node.label, col=tip.color, cex=cex, font=font)    
+         text(xx, yy, labels=node.label, col=col.node.label, cex=cex.node.label, font=font.node.label)    
     }   
 }   
    
-    
+## as.splits.phylo    
 lento <- function (obj, xlim = NULL, ylim = NULL, main = "Lento plot", 
-    sub = NULL, xlab = NULL, ylab = NULL, bipart=TRUE, trivial=FALSE, ...) 
+    sub = NULL, xlab = NULL, ylab = NULL, bipart=TRUE, trivial=FALSE, col = rgb(0,0,0,.5), ...) 
 {
-    if (class(obj) == "phylo") 
-        obj = as.splits(obj)
-    if (class(obj) == "multiPhylo") 
+    if (inherits(obj,"phylo")){ 
+        if(inherits(obj,"phylo",TRUE)==1)  obj <- as.splits(obj)[obj$edge[,2]]
+        obj <- as.splits(obj)
+    }
+    if (inherits(obj,"multiPhylo")) 
         obj = as.splits(obj)    
     labels = attr(obj, "labels") 
     l = length(labels)
@@ -1120,6 +1323,7 @@ lento <- function (obj, xlim = NULL, ylim = NULL, main = "Lento plot",
         triv = sapply(obj, length)
         ind = logical(length(obj)) 
         ind[(triv >1) & (triv < (l-1))] = TRUE
+        if(length(col)==length(obj)) col=col[ind] 
         obj = obj[ind]
         }
     CM = compatible(obj)
@@ -1139,6 +1343,7 @@ lento <- function (obj, xlim = NULL, ylim = NULL, main = "Lento plot",
     ord = order(support, decreasing = TRUE)
     support = support[ord]
     conflict = conflict[ord]
+    if(length(col)==length(obj)) col=col[ord]
     plot.new()
     plot.window(xlim, ylim)
     title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...)
@@ -1156,10 +1361,11 @@ lento <- function (obj, xlim = NULL, ylim = NULL, main = "Lento plot",
         Circles = matrix(1, l, n)
         for(i in 1:n) Circles[obj[[ord[i]]],i] = 19   
 #    axis(4, labels=labels, at=at)
+        col = rep(col, each=l)
         text(x=n+.1,y=at, labels, pos=4, ...) 
-        points(X,Y,pch = as.numeric(Circles), col = rgb(0,0,0,.5), ...)
+        points(X,Y,pch = as.numeric(Circles), col = col, ...)
         }
-    invisible(cbind(support, conflict))
+    invisible(list(support = cbind(support, conflict), splits=obj[ord]))
     }
 
     
@@ -1201,25 +1407,31 @@ write.splits = function (x, file = "", zero.print = ".", one.print = "|", print.
 }
  
 
-write.nexus.splits <- function (obj, file = "", weights=NULL) 
+write.nexus.splits <- function (obj, file = "", weights=NULL, taxa=TRUE, append=FALSE) 
 {
-    if(is.null(weights))weight <- attr(obj, "weights")
     taxa.labels <- attr(obj, "labels")
-    ntaxa = length(taxa.labels)
-    nsplits = length(obj)
-    
+    ntaxa <- length(taxa.labels)
+    obj <- oneWise(obj, ntaxa)
+    ind <- which(sapply(obj, length)==ntaxa)
+    if(length(ind))obj <- obj[-ind] 
+    nsplits <- length(obj)    
+    if(is.null(weights))weight <- attr(obj, "weights") 
     if (is.null(weight)) 
         weight = numeric(nsplits) + 100
-    cat("#NEXUS\n\n", file = file)
+    if(!append){cat("#NEXUS\n\n", file = file)
     cat("[Splits block for Spectronet or Splitstree]\n", file = file, append = TRUE)
     cat("[generated by phangorn:\n", file = file, append = TRUE)
     cat(format(citation("phangorn"), "text"), "]\n\n",
-       file = file, append = TRUE)
-    cat(paste("BEGIN TAXA;\n\tDIMENSIONS NTAX=", ntaxa, ";\n", 
+       file = file, append = TRUE)}
+# TAXON BLOCK    
+    if(taxa){
+    cat(paste("BEGIN TAXA;\n\tDIMENSIONS ntax=", ntaxa, ";\n", 
         sep = ""), file = file, append = TRUE)
     cat("\tTAXLABELS", paste(taxa.labels, sep = " "), ";\nEND;\n\n", 
         file = file, append = TRUE)
-    cat(paste("BEGIN SPLITS;\n\tDIMENSIONS NSPLITS=", nsplits,
+    }
+# SPLITS BLOCK      
+    cat(paste("BEGIN SPLITS;\n\tDIMENSIONS ntax=", ntaxa, " nsplits=", nsplits,
         ";\n", sep = ""), file = file, append = TRUE)     
     format = "\tFORMAT labels=left weights=yes"
     fcon = fint = flab = FALSE
@@ -1241,8 +1453,12 @@ write.nexus.splits <- function (obj, file = "", weights=NULL)
     if(!is.null(attr(obj, "splitlabels"))) flab=TRUE
     format = paste(format, ";\n",  sep = "")
     cat(format, file = file, append = TRUE)
+    if(!is.null(attr(obj, "cycle"))){
+        cycle <- paste(attr(obj, "cycle"), collapse = " ")
+        cat("\tCYCLE\t", cycle, ";\n", sep="", file = file, append = TRUE)
+    }
     cat("\tMATRIX\n", file = file, append = TRUE)    
-    obj = oneWise(obj, ntaxa)
+    
     for (i in 1:nsplits){
         slab <- ifelse(flab, attr(obj, "splitlabels")[i], i)
         scon <- ifelse(fcon, paste(attr(obj, "confidences")[i], "\t"), "")
@@ -1254,17 +1470,254 @@ write.nexus.splits <- function (obj, file = "", weights=NULL)
 }
 
 
+write.nexus.networx <- function(obj, file = "", taxa=TRUE, splits=TRUE, append=FALSE){
+    if(!append){
+        cat("#NEXUS\n\n", file = file)
+        cat("[Splits block for Spectronet or Splitstree]\n", file = file, append = TRUE)
+        cat("[generated by phangorn:\n", file = file, append = TRUE)
+        cat(format(citation("phangorn"), "text"), "]\n\n",
+            file = file, append = TRUE)
+        }
+    ntaxa <- length(obj$tip.label)
+    # TAXON BLOCK    
+    if(taxa){
+        cat(paste("BEGIN TAXA;\n\tDIMENSIONS NTAX=", ntaxa, ";\n", 
+            sep = ""), file = file, append = TRUE)
+        if(splits)taxalabel <- attr(obj$splits, "labels")
+        else taxalabel <- obj$tip.label
+        cat("\tTAXLABELS", paste(taxalabel, sep = " "), ";\nEND;\n\n", 
+            file = file, append = TRUE)
+    }
+# SPLITS BLOCK    
+    spl <- obj$splits
+    if(splits){
+#        spl <- changeOrder(spl, obj$tip.label) # orderSplitLabel
+        write.nexus.splits(spl, file = file, weights=NULL, append = TRUE, taxa=FALSE) 
+    }
+    nvertices <- max(obj$edge)
+    
+    #    if(is.null(attr(obj, "coords")))   
+    if(is.null(obj$.plot$vertices)) vertices <- coords(obj, "2D")
+    else vertices <- obj$.plot$vertices
+    
+    # y-axis differs between R and SplitsTree
+    vertices[,2] <- -vertices[,2]
+    
+    if(is.null(obj$.plot)) edge.col <- obj$.plot$edge.color 
+    else edge.col=NULL 
+    nedges <- nrow(obj$edge)
+# NETWORK BLOCK
+    cat(paste("BEGIN NETWORK;\nDIMENSIONS ntax=", ntaxa,
+              "\tnvertices=", nvertices, "\tnedges=", nedges,";\n", sep = ""), file = file, append = TRUE)  
+    cat("DRAW to_scale;\n", file = file, append = TRUE)
+    cat("TRANSLATE\n", file = file, append = TRUE)
+    if(is.null(obj$translate)){
+        for(i in 1:ntaxa){
+            cat(i, " ", obj$tip.label[i], ",\n", sep="", file = file, append = TRUE)
+        }
+    }
+    else {
+        translate <- obj$translate
+        for(i in 1:nrow(translate)){
+            cat(translate$node[i], " ", translate$label[i], ",\n", sep="", file = file, append = TRUE)
+        }        
+    }
+    cat(";\nVERTICES\n", file = file, append = TRUE)
+    for(i in 1:nvertices){
+        cat(i, "\t", vertices[i,1], "\t", vertices[i,2], ",\n", sep="", file = file, append = TRUE)
+    }
+    if(!is.null(obj$tip.label)){
+    cat(";\nVLABELS\n", file = file, append = TRUE)
+    if(is.null(obj$translate)){    
+        for(i in 1:ntaxa){
+            cat(i, "\t", obj$tip.label[i], ",\n", sep="", file = file, append = TRUE)
+        }
+    }
+    else{
+        for(i in 1:nrow(translate)){
+            cat(translate[i,1], " ", translate[i,2], ",\n", sep="", file = file, append = TRUE)
+        }           
+    }     
+    }    
+# cnet$splitIndex if splits = TRUE    
+    cat(";\nEDGES\n", file = file, append = TRUE)
+    
+    if(is.null(obj$.plot$edge.color)) edge.col="black"
+    else edge.col <- obj$.plot$edge.color
+    if(length(edge.col)<nedges) edge.col <- rep(edge.col, length=nedges) 
+    
+    splI <- TRUE
+    if(is.null(obj$splitIndex))splI <- FALSE
+    for(i in 1:nedges){
+        ecoli = edge.col[i]
+        spInd <- ifelse(splI, paste("\ts=", obj$splitIndex[i], sep=""), "")
+        edgeCol <- ifelse(ecoli=="black", "", paste("\tfg=", paste(col2rgb(ecoli), collapse=" "), sep=""))
+        cat(i, "\t", obj$edge[i,1], "\t", obj$edge[i,2], spInd, edgeCol, ",\n", sep="", file = file, append = TRUE)
+        }
+    cat(";\n", file = file, append = TRUE)
+    cat("END;\n", file = file, append = TRUE)
+# force SplitsTree to accept the file    
+    cat("\nBEGIN st_Assumptions;\n    uptodate;\nEND; [st_Assumptions]\n", file = file, append = TRUE)
+}
+
+
+read.nexus.networx <- function(file, splits=TRUE){
+    spl <- NULL
+    if(splits)spl <-read.nexus.splits(file)
+    
+    X <- scan(file = file, what = "", sep = "\n", quiet = TRUE)
+    semico <- grep(";", X)
+    X=gsub("\\[(.*?)\\]", "", X) # get rid of comments
+    
+    netStart <- grep("BEGIN NETWORK;", X, ignore.case = TRUE)
+    netEnd <- grep("END;", X, ignore.case = TRUE)
+    netEnd <- netEnd[netEnd>netStart][1]
+    dims <- grep("DIMENSION", X, ignore.case = TRUE)
+    dims <- dims[(dims>netStart) & (dims<netEnd)]
+    
+    ntaxa = 0
+    nvertices = 0 
+    nedges = 0
+    
+    if(length(dims)>0){
+        tmp = X[dims]    
+        tmp = gsub("\\s+", "", tmp)
+        
+        ntaxa <- as.numeric(sub("(.+?)(ntax\\s*\\=\\s*)(\\d+)(.+)", 
+            "\\3", tmp, perl = TRUE, ignore.case = TRUE))
+        nvertices  <- as.numeric(sub("(.+?)(nvertices\\s*\\=\\s*)(\\d+)(.+)", 
+            "\\3", tmp, perl = TRUE, ignore.case = TRUE))
+        nedges <- as.numeric(sub("(.+?)(nedges\\s*\\=\\s*)(\\d+)(.+)", 
+            "\\3", tmp, perl = TRUE, ignore.case = TRUE))
+    }
+    transl <- grep("TRANSLATE", X, ignore.case = TRUE)
+    translation <- if (length(transl) == 1 && transl > netStart) TRUE
+    else FALSE
+    translate.nodes <- FALSE
+    if (translation) {
+        end <- semico[semico > transl][1]
+        x <- X[(transl + 1):end]
+        x <- unlist(strsplit(x, "[,; \t]"))
+        x <- x[nzchar(x)]
+        x <- gsub("['\']", "", x)
+        if(length(x) == 2*ntaxa){
+            TRANS <- matrix(x, ncol = 2, byrow = TRUE)
+            TRANS[, 2] <- gsub("['\"]", "", TRANS[, 2])
+            TRANS <- list(node=as.numeric(TRANS[,1]), label=TRANS[,2])
+#            translate.nodes <- TRUE
+        }
+        else{
+#            TRANS <- matrix(NA, nrow = ntaxa, ncol = 2)
+            y <- as.numeric(x)
+            node <- numeric(ntaxa)
+            label <- character(ntaxa)
+            k=1
+            for(i in 1:length(x)){
+                if(!is.na(y[i])) tmp <- y[i]
+                else{
+                    node[k] <- tmp
+                    label[k] <- x[i]
+#                    TRANS[k, ] <- c(tmp, x[i])
+                    k=k+1
+                }
+                
+            }
+            TRANS <- list(node=node, label=label)
+        }    
+#        n <- dim(TRANS)[1]
+    }
+    
+    
+    vert <- grep("VERTICES", X, ignore.case = TRUE)
+    start <- vert[vert>max(dims, netStart)][1] + 1
+    end <- semico[semico>start][1] -1
+    VERT <- matrix(0, nvertices, 3, dimnames = list(NULL, c("id", "x", "y")))
+    j=1
+    for(i in start:end){
+        tmp <- X[i]
+#        tmp <- sub("\\s+", "", tmp) 
+        tmp <- gsub("\\,", "", tmp)  
+        tmp <- strsplit(tmp, "[[:space:]]")[[1]]
+        VERT[j,1] <- as.numeric(tmp[1]) 
+        VERT[j,2] <- as.numeric(tmp[2])
+        VERT[j,3] <- as.numeric(tmp[3])
+        j=j+1
+    }
+    
+    edges <- grep("EDGES", X, ignore.case = TRUE)
+    start <- edges[edges>max(dims, netStart)][1] + 1
+    end <- semico[semico>start][1] -1
+    EDGE <- NULL
+    if(splits) EDGE <- matrix(0, nedges, 4, dimnames = list(NULL, c("id", "vert_id_2", "vert_id_2", "splits_id")))
+    else EDGE <- matrix(0, nedges, 3, dimnames = list(NULL, c("id", "vert_id_2", "vert_id_2")))
+    j=1
+    for(i in start:end){
+        tmp <- X[i]
+        tmp <- gsub("\\,", "", tmp)
+        #        tmp <- sub("\\s+", "", tmp) 
+        tmp <- strsplit(tmp, "[[:space:]]")[[1]]
+        EDGE[j,1] <- as.numeric(tmp[1]) 
+        EDGE[j,2] <- as.numeric(tmp[2])
+        EDGE[j,3] <- as.numeric(tmp[3])
+        if(splits){
+            EDGE[j,4] <- as.numeric(sub("s=", "", tmp[4], ignore.case = TRUE))
+        }    
+        j=j+1
+    }
+    
+    swapEdge <- function(x, old, new) {
+        x[x==new] <- -1L
+        x[x==old] <- new
+        x[x==-1L] <- old
+        x     
+    }
+    swapRow <- function(x, old, new) {
+        tmp <- x[old,]
+        x[old,] <- x[new,]
+        x[new,] <- tmp
+        x     
+    }
+    splitIndex <- if(ncol(EDGE)==4) EDGE[,4]
+    else NULL
+# quick and dirty   
+    el = sqrt(rowSums((VERT[EDGE[,2],c(2:3)] - VERT[EDGE[,3],c(2:3)])^2))
+    edge <- EDGE[,c(2:3)]
+    vert <- VERT[,c(2:3)]
+    
+    
+    if(translate.nodes){
+#        oldLabel <- as.integer(as.numeric(TRANS[,1]))
+        oldLabel <- as.integer(TRANS$node)
+        for(i in 1:ntaxa){
+            edge <- swapEdge(edge, oldLabel[i], i) 
+            vert <- swapRow(vert, oldLabel[i], i)
+        }
+    }
+    
+    # y-axis differs between in R and SplitsTree
+    vert[,2] <- -vert[,2]  
+#    translate=data.frame(as.numeric(TRANS[,1]), TRANS[,2], stringsAsFactors=FALSE)
+    plot <- list(vertices=vert)        
+    obj <- list(edge=edge, tip.label=TRANS$label, Nnode=max(edge)-ntaxa,
+        edge.length=el, splitIndex=splitIndex, splits=spl, translate=TRANS) 
+    obj$.plot <- list(vertices = vert, edge.color="black", edge.width=3, edge.lty = 1)
+    class(obj) <- c("networx", "phylo")
+    reorder(obj)
+    obj
+}
+
+
 read.nexus.splits <- function(file)
 {
     X <- scan(file = file, what = "", sep = "\n", quiet = TRUE)
     semico <- grep(";", X)
     X=gsub("\\[(.*?)\\]", "", X) # get rid of comments
     i1 <- grep("TAXLABELS", X, ignore.case = TRUE)    
-    taxlab <- TRUE 
+    taxlab <- ifelse(length(i1)>0, TRUE, FALSE) 
     if (taxlab) {
-        end <- semico[semico > i1][1]
-        x <- X[(i1 + 1):end] # assumes there's a 'new line' after "TRANSLATE"
-        ## x <- gsub("TRANSLATE", "", x, ignore.case = TRUE)
+        end <- semico[semico >= i1][1]
+        x <- X[(i1):end] # assumes not a 'new line' after "TRANSLATE"
+        x <- gsub("TAXLABELS", "", x, ignore.case = TRUE)
         x <- unlist(strsplit(x, "[,; \t]"))   
         x <- x[nzchar(x)]
         x <- gsub("['\"]", "", x)
@@ -1335,107 +1788,45 @@ read.nexus.splits <- function(file)
 }
 
 
-#
-# ancestral sequences ML
-#
-ancestral.pml <- function (object, type=c("ml", "bayes")) 
-{
-    call <- match.call()
-    type <- match.arg(type)
-    pt <- match.arg(type, c("ml", "bayes"))   
-    tree = object$tree 
-    
-    INV <- object$INV
-    inv <- object$inv
-    
-    data = getCols(object$data, tree$tip) 
-    if (is.null(attr(tree, "order")) || attr(tree, "order") == 
-        "cladewise") 
-        tree <- reorder(tree, "postorder")
-    q = length(tree$tip.label)
-    node <- tree$edge[, 1]
-    edge <- tree$edge[, 2]
-    m = length(edge) + 1  # max(edge)
-    w = object$w
-    g = object$g
-    l = length(w)    
-    nr <- attr(data, "nr")
-    nc <- attr(data, "nc")
-    dat = vector(mode = "list", length = m*l)
-    result = vector(mode = "list", length = m)
-    dim(dat) <- c(l,m)
-    
-    x = attributes(data)
-    label = as.character(1:m)
-    nam = tree$tip.label
-    label[1:length(nam)] = nam
-    x[["names"]] = label
-  
-    
-    tmp = length(data)
-    result = new2old.phyDat(data) 
-    eig = object$eig
-
-    bf = object$bf
-    el <- tree$edge.length
-    P <- getP(el, eig, g)
-    nr <- as.integer(attr(data, "nr"))
-    nc <- as.integer(attr(data, "nc"))
-    node = as.integer(node - min(node))
-    edge = as.integer(edge - 1)
-    nTips = as.integer(length(tree$tip))
-    mNodes = as.integer(max(node) + 1)
-    contrast = attr(data, "contrast")
-    nco = as.integer(dim(contrast)[1])
-    for(i in 1:l)dat[i,(q + 1):m] <- .Call("LogLik2", data, P[i,], nr, nc, node, edge, nTips, mNodes, contrast, nco, PACKAGE = "phangorn")
-
-    parent <- tree$edge[, 1]
-    child <- tree$edge[, 2]
-    nTips = min(parent) - 1
-   
-    for(i in 1:l){     
-        for (j in (m - 1):1) {
-            if (child[j] > nTips){
-                tmp2 = (dat[[i, parent[j]]]/(dat[[i,child[j]]] %*% P[[i,j]]))
-                dat[[i, child[j]]] = (tmp2 %*% P[[i,j]]) * dat[[i, child[j]]]  
-            }
+
+################################################################################
+# delta.score
+################################################################################
+# Calculated from mathematical description given in Gray et al. (2010) Phil.
+# Trans. Roy. Soc. B. 
+# delta.score reference: Holland et al. (2002) Mol. Biol. Evol.
+################################################################################ 
+
+
+# Calculating Delta and Q-residual scores 
+# internal
+delta.quartet <-
+    function(quartet,dist.dna) {
+        m1 <- dist.dna[quartet[1],quartet[2]] + dist.dna[quartet[3],quartet[4]]
+        m2 <- dist.dna[quartet[1],quartet[3]] + dist.dna[quartet[2],quartet[4]]
+        m3 <- dist.dna[quartet[1],quartet[4]] + dist.dna[quartet[2],quartet[3]]
+        m <- sort(c(m1,m2,m3),decreasing=T)
+        if((m[1]-m[3])!=0) {
+            ret <- (m[1]-m[2])/(m[1]-m[3])
+        } else {
+            ret <- 0
         }
+        return(ret)
     }
-    for (j in unique(parent)) {
-        tmp <- matrix(0, nr, nc)
-        if(inv>0) tmp = as.matrix(INV) * inv
-        for(i in 1:l){  
-            tmp = tmp + w[i] * dat[[i, j]]                                 
-        }
-        if (pt == "bayes") tmp = tmp * rep(bf, each=nr)
-        tmp = tmp / rowSums(tmp)
-        result[[j]] = tmp
-    } 
-    attributes(result) = x
-    attr(result, "call") <- call
-    result 
-}
 
 
-fast.tree  = function(tree, node){
-   parent = c(node, Ancestors(tree, node))
-   children = Descendants(tree, parent, 'children')
-   l = sapply(children, length)
-   edge = cbind(rep(parent, l), unlist(children))
-   obj = list(edge=edge, Nnode=sum(l>0), tip.label=as.character(edge[is.na(match(edge[,2], edge[,1])),2]))
-   class(obj) = 'phylo'
-   obj
-}
-
-# schneller ???
-fast.tree2  = function(tree, node){
-   parent = c(node, Ancestors(tree, node))
-   edge = tree$edge 
-   ind = match(edge[,1], parent)
-   edge=edge[which(!is.na(ind)),] 
-   obj = list(edge=edge, Nnode=length(parent), tip.label=as.character(edge[is.na(match(edge[,2], edge[,1])),2]))
-   class(obj) = 'phylo'
-   obj
-}
-
+delta.score <- function(x, arg="mean", ...) {
+        # dist.dna <- as.matrix(dist.dna(dna,"raw"))   
+        # dist.dna(dna,"raw") is equivalent to dist.hamming(as.phyDat(dna), exclude="all") 
+        dist.dna <- as.matrix(dist.hamming(x, ...))
+        # Number of quartets
+        # choose(length(names(x)),4)
+        # Create all quartets
+        all.quartets <- t(combn(names(x),4))
+        delta.values <- apply(all.quartets[,],1,delta.quartet,dist.dna)
+        if (!arg%in%c("all", "mean","sd")) stop("return options are: all, mean, or sd")
+        if (arg=='all') return(delta.values)
+        if (arg=='mean') return(mean(delta.values))
+        if (arg=='sd') return(sd(delta.values))
+    }
 
diff --git a/R/parsimony.R b/R/parsimony.R
index ebab78c..92c820d 100644
--- a/R/parsimony.R
+++ b/R/parsimony.R
@@ -36,7 +36,7 @@ ancestral.pars <- function (tree, data, type = c("MPR", "ACCTRAN"), cost=NULL)
         attr(res, "call") = call
         return(res)
     }
-    l = length(tree$tip)
+    l = length(tree$tip.label)
     
     x = attributes(data)
     m = dim(res)[2]
@@ -72,7 +72,7 @@ pace <- ancestral.pars
 mpr.help = function (tree, data, cost=NULL) 
 {   
     tree<- reorder(tree, "postorder")     
-    if (class(data) != "phyDat") 
+    if (!inherits(data,"phyDat")) 
         stop("data must be of class phyDat")    
     levels <- attr(data, "levels")
     l = length(levels)
@@ -113,13 +113,13 @@ mpr <- function(tree, data, cost=NULL){
     nr = att$nr
     nc = att$nc
     res <- mpr.help(tree,data,cost)
-    l = length(tree$tip)
+    l = length(tree$tip.label)
     m = length(res)
     label = as.character(1:m)
     nam = tree$tip.label
     label[1:length(nam)] = nam
     att[["names"]] = label
-    ntips = length(tree$tip)
+    ntips = length(tree$tip.label)
     contrast = att$contrast
     eps=5e-6
     rm = apply(res[[ntips+1]], 1, min)
@@ -220,12 +220,6 @@ compressSites <- function(data){
 }
 
 
-
-is.rooted2 = function(tree){
-    length(tree$edge[, 1][!match(tree$edge[, 1], tree$edge[, 2], 0)]) < 3
-}
-
-
 #
 # Branch and bound 
 #
@@ -284,32 +278,44 @@ upperBound <- function(x, cost=NULL){
 }
 
 
-CI <- function (tree, data, cost=NULL){
-    pscore = sankoffNew(tree, data, cost=cost)
+CI <- function (tree, data, cost = NULL, sitewise=FALSE) 
+{
+    if(sitewise) pscore = sankoffNew(tree, data, cost = cost, site="site")
+    else pscore = sankoffNew(tree, data, cost = cost)
     weight = attr(data, "weight")
-    data = subset(data, tree$tip.label) 
-    m = lowerBound(data, cost=cost)    
+    data = subset(data, tree$tip.label)
+    m = lowerBound(data, cost = cost)
+    if(sitewise){
+        return((m/pscore)[attr(data, "index")])
+    }
     sum(m * weight)/pscore
 }
 
 
-RI <- function (tree, data, cost=NULL)
+RI <- function (tree, data, cost = NULL, sitewise=FALSE) 
 {
-    pscore = sankoffNew(tree, data, cost=cost)
+    if(sitewise) pscore = sankoffNew(tree, data, cost = cost, site="site")
+    else pscore = sankoffNew(tree, data, cost = cost)
     data = subset(data, tree$tip.label)
     weight = attr(data, "weight")
-    m = lowerBound(data, cost=cost)
+    m = lowerBound(data, cost = cost)
+    g = upperBound(data, cost = cost)
+    if(sitewise){
+        res <- (g - pscore) / (g - m)
+#        res[is.nan(res)] <- 0
+        return(res[attr(data, "index")])
+    }
     m = sum(m * weight)
-    g = upperBound(data, cost=cost)
     g = sum(g * weight)
     (g - pscore)/(g - m)
 }
 
+
 # not used
 add.one <- function (tree, tip.name, i){
-    if (class(tree) != "phylo") 
+    if (!inherits(tree,"phylo")) 
         stop("tree should be an object of class 'phylo.'")
-    nTips = length(tree$tip)
+    nTips = length(tree$tip.label)
     tmpedge = tree$edge
     m = max(tmpedge)
     l = nrow(tmpedge)
@@ -330,7 +336,7 @@ add.one <- function (tree, tip.name, i){
     tmp
 }
 
-
+# in bab oder raus
 mmsNew0 <- function (x, Y) 
 {
     w <- attr(x, "weight")
@@ -473,7 +479,7 @@ prepareDataSankoff <- function(data){
 
 sankoff <- function (tree, data, cost = NULL, site = 'pscore') 
 {
-    if (class(data) != "phyDat") 
+    if (!inherits(data,"phyDat")) 
         stop("data must be of class phyDat")
     data <- prepareDataSankoff(data)
     levels <- attr(data, "levels")
@@ -484,8 +490,8 @@ sankoff <- function (tree, data, cost = NULL, site = 'pscore')
         cost <- cost - diag(l)
     }   
     for (i in 1:length(data)) storage.mode(data[[i]]) = "double"
-    if(class(tree)=="phylo") return(fit.sankoff(tree, data, cost, returnData =site))
-    if(class(tree)=="multiPhylo"){
+    if(inherits(tree,"phylo")) return(fit.sankoff(tree, data, cost, returnData =site))
+    if(inherits(tree,"multiPhylo")){
 	    if(is.null(tree$TipLabel))tree = unclass(tree)
 	    return(sapply(tree, fit.sankoff, data, cost, site))
     }    
@@ -509,9 +515,9 @@ fit.sankoff <- function (tree, data, cost, returnData = c("pscore", "site", "dat
     dat[1:q] = data[tree$tip.label]
     node = as.integer(node - 1)
     edge = as.integer(edge - 1)
-    nTips = as.integer(length(tree$tip))
+    nTips = as.integer(length(tree$tip.label))
     mNodes = as.integer(max(node) + 1)
-    tips = as.integer((1:length(tree$tip))-1)
+    tips = as.integer((1:length(tree$tip.label))-1)
     res <- .Call("sankoff3", dat, as.numeric(cost), as.integer(nr),as.integer(nc),
          node, edge, mNodes, tips, PACKAGE="phangorn")  
     root <- getRoot(tree) 
@@ -572,14 +578,14 @@ indexNNI <- function(tree){
     attr(edgeMatrix, 'root') <-cvector[[min(parent)]]  
     edgeMatrix
 }
-                   
+
         
 sankoff.nni = function (tree, data, cost, ...) 
 {   
     if(is.rooted(tree))tree<- reorder(unroot(tree), "postorder")     
     INDEX <-  indexNNI(tree)
     rootEdges <- attr(INDEX,"root")
-    if (class(data) != "phyDat") 
+    if (!inherits(data,"phyDat")) 
         stop("data must be of class phyDat")
     levels <- attr(data, "levels")
     l = length(levels)
@@ -686,7 +692,7 @@ pratchet <- function (data, start=NULL, method="fitch", maxit=1000, k=10, trace=
     for (i in 1:maxit) {
         bstrees <- bootstrap.phyDat(data, FUN, tree = tree, bs = 1, trace = trace, method=method, rearrangements=rearrangements, ...)
         trees <- lapply(bstrees, optim.parsimony, data, trace = trace, method=method, rearrangements=rearrangements, ...)
-        if(class(result)=="phylo")m=1
+        if(inherits(result,"phylo"))m=1
         else m = length(result)
         if(m>0) trees[2 : (1+m)] = result[1:m]
         pscores <- sapply(trees, function(data) attr(data, "pscore"))
@@ -718,7 +724,7 @@ pratchet <- function (data, start=NULL, method="fitch", maxit=1000, k=10, trace=
 
 
 optim.sankoff <- function(tree, data, cost=NULL, trace=1, ...) {
-    if(class(tree)!="phylo") stop("tree must be of class phylo") 
+    if(!inherits(tree,"phylo")) stop("tree must be of class phylo") 
     if(is.rooted(tree))tree <- unroot(tree)
     if(is.null(attr(tree, "order")) || attr(tree, "order") == "cladewise") tree <- reorder(tree, "postorder")
     if (class(data)[1] != "phyDat") stop("data must be of class phyDat")
@@ -756,7 +762,7 @@ optim.sankoff <- function(tree, data, cost=NULL, trace=1, ...) {
 #
 ptree <- function (tree, data, type = "ACCTRAN", retData = FALSE) 
 {
-    if (class(data) != "phyDat") 
+    if (!inherits(data,"phyDat")) 
         stop("data must be of class phyDat")
     if (is.null(attr(tree, "order")) || attr(tree, "order") == 
         "cladewise") 
@@ -769,11 +775,11 @@ ptree <- function (tree, data, type = "ACCTRAN", retData = FALSE)
     edge <- tree$edge[, 2]
     weight = attr(data, "weight")
     m = length(edge) + 1
-    q = length(tree$tip)
+    q = length(tree$tip.label)
     l = as.integer(length(edge))
-    nTips = length(tree$tip)
+    nTips = length(tree$tip.label)
     dat = tmp[[2]]
-    if (!is.rooted2(tree)) {
+    if (!is.rooted(tree)) {
         root = getRoot(tree)
         ind = edge[node == root]
         rSeq = .C("fitchTriplet", integer(nr), dat[, ind[1]], 
@@ -784,7 +790,7 @@ ptree <- function (tree, data, type = "ACCTRAN", retData = FALSE)
         as.integer(node[l:1L]), as.integer(edge[l:1L]), l, as.double(weight), 
         numeric(l), as.integer(nTips))
     el = result[[8]][l:1L]
-    if (!is.rooted2(tree)) {
+    if (!is.rooted(tree)) {
         ind2 = which(node[] == root)
         dat = matrix(result[[1]], nr, max(node))
         result <- .C("ACCTRAN3", result[[1]], as.integer(nr), 
diff --git a/R/phyDat.R b/R/phyDat.R
index bb93cf5..274e1b0 100644
--- a/R/phyDat.R
+++ b/R/phyDat.R
@@ -27,12 +27,16 @@ phyDat.default <- function (data, levels = NULL, return.index = TRUE, contrast =
         nam = row.names(data)
     else nam = names(data)
     if(is.null(nam))stop("data object must contain taxa names")
-    if (class(data) == "DNAbin") 
+    if (inherits(data,"DNAbin")) 
         data = as.character(data)
     if (is.matrix(data)) 
         data = as.data.frame(t(data), stringsAsFactors = FALSE)
-    if (is.vector(data))data = as.data.frame(t(data), stringsAsFactors = FALSE)
+# new 4.4.2016 bug fix (reported by Eli Levy Karin)     
+    if (is.vector(data) && !is.list(data))data = as.data.frame(t(data), stringsAsFactors = FALSE)
     else data = as.data.frame(data, stringsAsFactors = FALSE)
+#    data = data.frame(as.matrix(data), stringsAsFactors = FALSE)    
+    
+    
     if(length(data[[1]])==1) compress=FALSE 
     if(compress){
         ddd = fast.table(data)
@@ -101,7 +105,7 @@ phyDat.DNA = function (data, return.index = TRUE)
     if (is.matrix(data)) 
         nam = row.names(data)
     else nam = names(data)
-    if (class(data) == "DNAbin") 
+    if (inherits(data,"DNAbin")) 
         data = as.character(data)
     if (is.matrix(data)) 
         data = as.data.frame(t(data), stringsAsFactors = FALSE)
@@ -162,7 +166,7 @@ phyDat.AA <- function (data, return.index = TRUE)
 {
     if(is.matrix(data)) nam = row.names(data)
     else nam = names(data)  
-    if (class(data) == "DNAbin") 
+    if (inherits(data,"DNAbin")) 
         data = as.character(data)
     if (is.matrix(data)) 
         data = as.data.frame(t(data), stringsAsFactors = FALSE)
@@ -229,7 +233,7 @@ phyDat.codon <- function (data, return.index = TRUE)
 {
     if(is.matrix(data)) nam = row.names(data)
     else nam = names(data)  
-    if (class(data) == "DNAbin") 
+    if (inherits(data,"DNAbin")) 
         data = as.character(data)
 
     if (is.matrix(data)) 
@@ -304,7 +308,7 @@ phyDat.codon <- function (data, return.index = TRUE)
 
 
 as.phyDat <- function (x, ...){
-    if (class(x) == "phyDat") return(x)
+    if (inherits(x,"phyDat")) return(x)
     UseMethod("as.phyDat")
 }
 
@@ -343,6 +347,44 @@ phyDat2alignment <-  function(x){
 }
 
 
+as.phyDat.MultipleAlignment <- function(x, ...){
+    if (requireNamespace('Biostrings')){
+    if(inherits(x, "DNAMultipleAlignment"))
+        res <- phyDat.DNA(Biostrings::as.matrix(x))
+    if(inherits(x, "RNAMultipleAlignment"))
+        res <- phyDat.DNA(Biostrings::as.matrix(x))
+    if(inherits(x, "AAMultipleAlignment"))
+        res <- phyDat.AA(Biostrings::as.matrix(x))
+    return(res)
+    }
+    return(NULL)
+}
+
+
+as.MultipleAlignment <- function (x, ...){
+    if (inherits(x,"MultipleAlignment")) return(x)
+    UseMethod("as.MultipleAlignment")
+}
+
+
+as.MultipleAlignment.phyDat <- function(x){
+    if (requireNamespace('Biostrings')){
+    z = as.character(x)
+    nam = rownames(z)
+    type = attr(x, "type")
+    seq <- switch(type, 
+                  DNA = tolower(apply(z, 1, paste, collapse="")), 
+                  AA = toupper(apply(z, 1, paste, collapse="")))
+    if(type=="DNA") return(Biostrings::DNAMultipleAlignment(seq))
+    if(type=="AA") return(Biostrings::AAMultipleAlignment(seq))
+    }
+    return(NULL)
+}
+
+
+phyDat2MultipleAlignment <- as.MultipleAlignment.phyDat
+
+
 as.phyDat.matrix <- function (x, ...) phyDat(data=x, ...)
 
 
@@ -518,10 +560,16 @@ as.DNAbin.phyDat <- function (x, ...)
 }
 
 
+if (getRversion() >= "2.15.1") utils::globalVariables("as.AAbin")
+as.AAbin.phyDat <- function(x,...) {
+   if(attr(x, "type")=="AA") return(as.AAbin(as.character(x, ...)))
+   else stop("x must be a amino acid sequence")
+}
+
  
 phyDat <- function (data, type="DNA", levels=NULL, return.index = TRUE,...) 
 {
-    if (class(data) == "DNAbin") type <- "DNA"
+    if (inherits(data,"DNAbin")) type <- "DNA"
     pt <- match.arg(type, c("DNA", "AA", "CODON", "USER"))  
     if(pt=="DNA") dat <- phyDat.DNA(data, return.index=return.index,...)
     if(pt=="AA") dat <- phyDat.AA(data, return.index=return.index, ...)
@@ -553,7 +601,7 @@ c.phyDat <- function(...){
     levels <- attr(x[[1]], "levels")
     snames <- names(x[[1]])
     objNames<-as.character(object)
-    if(any(duplicated(objNames))) objNames <- paste(objNames,1:n,sep="")
+    if(any(duplicated(objNames))) objNames <- paste0(objNames, 1:n)
     tmp <- as.character(x[[1]])
     for(i in 2:n){
         match.names(snames,names(x[[i]]))
@@ -594,7 +642,7 @@ cbindPD <- function(..., gaps="-"){
     vec = numeric(n+1)
     wvec = numeric(n+1)
     objNames<-as.character(object)
-    if(any(duplicated(objNames))) objNames <- paste(objNames,1:n,sep="")
+    if(any(duplicated(objNames))) objNames <- paste0(objNames, 1:n)
     #    tmp <- as.character(x[[1]])
     
     for(i in 1:n){
@@ -642,7 +690,7 @@ cbind.phyDat <- function(..., gaps="-"){
     snames <- vector("list", n)  # names(x[[1]])
     vec = numeric(n+1)
     objNames<-as.character(object)
-    if(any(duplicated(objNames))) objNames <- paste(objNames,1:n,sep="")
+    if(any(duplicated(objNames))) objNames <- paste0(objNames, 1:n)
     tmp <- as.character(x[[1]])
     for(i in 1:n){
         snames[[i]] = names(x[[i]]) #match.names(snames,names(x[[i]]))
@@ -673,7 +721,7 @@ cbind.phyDat <- function(..., gaps="-"){
 
 
 write.phyDat <- function(x, file, format="phylip",...){
-    if(format=="fasta") write.dna(as.character(x), file, format="fasta", ...)
+    if(format=="fasta") write.dna(as.character(x), file, format="fasta", colsep = "", nbcol=-1, ...)
     if(format=="phylip") write.dna(as.character(x), file, format="sequential", ...)    
     if(format=="nexus"){   
          type = attr(x, "type")
@@ -684,6 +732,10 @@ write.phyDat <- function(x, file, format="phylip",...){
 
 
 read.phyDat <- function(file, format="phylip", type="DNA", ...){
+    
+    formats <- c("phylip", "nexus", "interleaved", "sequential", "fasta", "clustal")
+    format <- match.arg(tolower(format), formats)
+    
     if(format=="nexus") data=read.nexus.data(file, ...)
     else {
         if(format=="phylip")format="interleaved"  #"sequential"
@@ -697,17 +749,18 @@ read.phyDat <- function(file, format="phylip", type="DNA", ...){
 }
 
 
-baseFreq <- function(obj, freq=FALSE, drop.unused.levels = FALSE){
-    if (class(obj) != "phyDat") 
+baseFreq <- function(obj, freq=FALSE, all=FALSE, drop.unused.levels = FALSE){
+    if (!inherits(obj,"phyDat")) 
         stop("data must be of class phyDat")
     labels <- attr(obj, "allLevels")
     weight <- attr(obj,"weight")
     n <- length(obj)    
     res <- numeric(length(labels))  
     D = diag(length(labels))   
-    for(i in 1:n)res <- res + colSums(D[obj[[i]],, drop=FALSE]*weight)      
-    if(!freq)res <- res/sum(res)
+    for(i in 1:n)res <- res + colSums(D[obj[[i]],, drop=FALSE]*weight)
     names(res) <- labels
+    if(!all) res <- res[attr(obj, "levels")]
+    if(!freq)res <- res/sum(res)
     if(drop.unused.levels) return(res[res>0])    
     res    
 }
@@ -773,13 +826,86 @@ subset.phyDat <- function (x, subset, select, site.pattern = TRUE,...)
 }
 
 
-unique.phyDat <- function(x, incomparables=FALSE, ...) getCols(x, !duplicated(x))
+duplicated_phyDat <- function(x, ...){
+    dm <- as.matrix(dist.hamming(x))
+    diag(dm) <- 1
+    res <- logical(nrow(dm))
+    if(all(dm>0)) return(res)
+    tmp <- which(dm==0, arr.ind = TRUE, useNames = FALSE)
+    tmp <- tmp[tmp[,1] < tmp[,2],2]
+    res[unique(tmp)]=TRUE
+    res
+}
+
+
+duplicated_map2 <- function(x, ...){
+    dm <- dist.hamming(x)
+    if(all(dm>0)) return(NULL)
+    dm <- as.matrix(dm)
+    tmp <- which(dm==0, arr.ind = TRUE, useNames = FALSE)
+    tmp <- tmp[tmp[,1] < tmp[,2],] 
+    tmp[] = names(x)[tmp]
+    g <- graph_from_edgelist(tmp, directed = FALSE)
+    clu <- components(g)
+    gr <- groups(clu)
+    mapping <- matrix(NA, 1,2)
+    for(i in 1:length(gr)){
+        if(length(gr[[i]])==2)mapping <- rbind(mapping, gr[[i]])
+        else{
+            tmplab = gr[[i]]
+            sg <- sum(dm[tmplab, tmplab])
+            if(sg==0)mapping <- rbind(mapping, cbind(tmplab[1], tmplab[-1]))
+        }
+    }
+    mapping[-1,c(2,1)]
+}
+
+
+duplicated_map <- function(x, ...){
+# exact matches    
+   dup <-  duplicated(x)
+   mapping <- NULL
+   if(any(dup)){ # && optNNI
+       labels <- names(x)
+       ind <- match(subset(x, dup), x)
+       mapping <- cbind(labels[dup], labels[ind])
+   }
+   mapping
+}   
+
+
+unique.phyDat <- function(x, incomparables=FALSE, identical=TRUE, ...){
+    if(identical) return(getCols(x, !duplicated(x)))
+    getCols(x, !duplicated_phyDat(x))
+} 
+
+
+removeUndeterminedSites <- function(x, use.contrast=TRUE, undetermined=c("?", "n", "-"), ...){
+    nc <- attr(x, "nc")
+    nr <- attr(x, "nr")
+    contrast <- attr(x, "contrast")
+    if(use.contrast) ind <- which( (contrast %*% rep(1, nc)) == nc )
+    else ind <- sort(match(undetermined, attr(x, "allLevels")))
+    tmp <- x[[1]] %in% ind
+    for(i in 2:length(x)) tmp = tmp & (x[[i]] %in% ind)
+    if(any(tmp)) x <- getRows(x, (1:nr)[!tmp]) #getRows(x, -which(tmp))
+    x
+}
+
+
+removeParsUninfoSites <- function(data){
+    nr <- attr(data, "nr")
+    pis <- parsinfo(data)
+    if (length(pis) > 0) 
+        data <- getRows(data, c(1:nr)[-pis[, 1]], TRUE)
+}
+
 
 
 allSitePattern <- function(n,levels=c("a","c","g","t"), names=NULL){
     l=length(levels)
     X=vector("list", n)
-    if(is.null(names))names(X) = paste("t",1:n, sep="") 
+    if(is.null(names))names(X) = paste0("t", 1:n) 
     else names(X)=names
     for(i in 1:n)
         X[[i]] = rep(rep(levels, each=l^(i-1)),l^(n-i)) 
@@ -792,7 +918,7 @@ constSitePattern <- function(n,levels=c("a","c","g","t"), names=NULL){
     l=length(levels)
     X=matrix(0, l,n)
     X = matrix(rep(levels, each=n), n, l)
-    if(is.null(names))rownames(X) = paste("t",1:n, sep="")
+    if(is.null(names))rownames(X) = paste0("t", 1:n)
     else rownames(X)=names
     phyDat.default(X, levels)
 } 
@@ -925,7 +1051,7 @@ read.aa <- function (file, format = "interleaved", skip = 0, nlines = 0,
             sequ <- gsub(" ", "", sequ)
             j <- j + 1
             while (nchar(sequ) < s) {
-                sequ <- paste(sequ, gsub(" ", "", X[j]), sep = "")
+                sequ <- paste0(sequ, gsub(" ", "", X[j]))
                 j <- j + 1
             }
             obj[i, ] <- unlist(strsplit(sequ, NULL))
@@ -963,3 +1089,12 @@ genlight2phyDat <- function(x, ambiguity=NA){
     lev <- na.omit(unique(as.vector(tmp)))
     phyDat(tmp, "USER", levels=lev, ambiguity=ambiguity)
 }
+
+
+if (getRversion() >= "2.15.1") utils::globalVariables("image.AAbin")
+image.phyDat <- function(x, ...){
+    if(attr(x, "type")=="AA")image(as.AAbin(x), ...)
+    if(attr(x, "type")=="DNA")image(as.DNAbin(x), ...)
+    else return(NULL)
+}
+
diff --git a/R/phylo.R b/R/phylo.R
index 6eb75da..69cdcff 100644
--- a/R/phylo.R
+++ b/R/phylo.R
@@ -1,3 +1,21 @@
+  
+edgeLengthIndex <- function(child, parent, nTips){
+    fun = function(child, parent, nTips){
+        if(child <= nTips) return(child)
+        else{
+            if(child < parent) return(parent)
+            return(child)
+        }
+    }
+    if (length(child)==1) return(fun(child, parent, nTips))
+    else {
+        res = integer(length(child))
+        for(i in 1:length(child))res[i]=fun(child[i], parent[i], nTips)
+        return(res)
+    }
+}
+
+
 #
 # Maximum likelihood estimation
 #
@@ -9,23 +27,27 @@ discrete.gamma <- function (alpha, k)
 }
 
 
+# allow transition probs of zero (added o)
 optimQ <- function (tree, data, Q=rep(1,6), subs=rep(1,length(Q)), trace = 0, ...) 
 {
     m = length(Q)
     n = max(subs)
+    o = min(subs)
     ab = numeric(n)
 #    ab = log(Q[match(1:n, subs)])    
     for(i in 1:n) ab[i]=log(Q[which(subs==i)[1]])
-    fn = function(ab, tree, data, m, n, subs,...) {
+    fn = function(ab, tree, data, m, n, o, subs,...) {
         Q = numeric(m)
         for(i in 1:n)Q[subs==i] = ab[i]
+        if(o < 0)Q[subs<0] = -Inf
         pml.fit(tree, data, Q = exp(Q),...)# Q^2, ...)
     }
     res = optim(par = ab, fn = fn, gr = NULL, method = "L-BFGS-B", 
         lower = -Inf, upper = 10, control = list(fnscale = -1, 
-        maxit = 25, trace = trace), tree = tree, data = data, m=m, n=n, subs=subs,...)
+        maxit = 25, trace = trace), tree = tree, data = data, m=m, n=n, o=o, subs=subs,...)
     Q = rep(1, m)
     for(i in 1:n) Q[subs==i] = exp(res[[1]][i])
+    if(o < 0)Q[subs<0] = 0
     res[[1]] = Q
     res
 }    
@@ -95,140 +117,7 @@ subsChoice <- function(type=c("JC", "F81", "K80", "HKY", "TrNe", "TrN", "TPM1",
 }
 
 
-modelTest <- function (object, tree = NULL, model = c("JC", "F81", "K80", 
-    "HKY", "SYM", "GTR"), G = TRUE, I = TRUE, k = 4, control = pml.control(epsilon = 1e-08, 
-    maxit = 10, trace = 1), multicore = FALSE) 
-{    
-    if (class(object) == "phyDat") 
-        data = object
-    if (class(object) == "pml") {
-        data = object$data
-        if (is.null(tree)) 
-            tree = object$tree
-    }
-    
-    if(attr(data, "type")=="DNA") type = c("JC", "F81", "K80", "HKY", "TrNe", "TrN", "TPM1", 
-            "K81", "TPM1u", "TPM2", "TPM2u", "TPM3", "TPM3u", "TIM1e", 
-            "TIM1", "TIM2e", "TIM2", "TIM3e", "TIM3", "TVMe", "TVM", 
-            "SYM", "GTR")
-    if(attr(data, "type")=="AA") type = .aamodels   
-    model = match.arg(model, type, TRUE)
-    
-    env = new.env()
-    assign("data", data, envir=env)
-    
-    if (is.null(tree)) 
-        tree = NJ(dist.hamming(data))
-    else{
-        tree <- nnls.phylo(tree, dist.ml(data)) 
-        # may need something faster for trees > 500 taxa  
-    }
-    trace <- control$trace
-    control$trace = trace - 1
-    fit = pml(tree, data)
-    fit = optim.pml(fit, control = control)
-    l = length(model)
-    n = 1L + sum(I + G + (G & I))
-    nseq = sum(attr(data, "weight"))
-    fitPar = function(model, fit, G, I, k) {
-        m = 1
-        res = matrix(NA, n, 6)
-        res = as.data.frame(res)
-        colnames(res) = c("Model", "df", "logLik", "AIC", "AICc", "BIC")
-        data.frame(c("Model", "df", "logLik", "AIC", "AICc", "BIC"))
-        calls = vector("list", n)
-        trees = vector("list", n)
-        fittmp = optim.pml(fit, model = model, control = control)
-        res[m, 1] = model
-        res[m, 2] = fittmp$df
-        res[m, 3] = fittmp$logLik
-        res[m, 4] = AIC(fittmp)
-        res[m, 5] = AICc(fittmp)
-        res[m, 6] = AIC(fittmp, k = log(nseq))
-        calls[[m]] = fittmp$call
-        
-        trees[[m]] = fittmp$tree
-        m = m + 1
-        if (I) {
-            if(trace>0)print(paste(model, "+I", sep = ""))
-            fitI = optim.pml(fittmp, model = model, optInv = TRUE, 
-                             control = control)
-            res[m, 1] = paste(model, "+I", sep = "")
-            res[m, 2] = fitI$df
-            res[m, 3] = fitI$logLik
-            res[m, 4] = AIC(fitI)
-            res[m, 5] = AICc(fitI)
-            res[m, 6] = AIC(fitI, k = log(nseq))
-            calls[[m]] = fitI$call
-            trees[[m]] = fitI$tree
-            m = m + 1
-        }
-        if (G) {
-            if(trace>0)print(paste(model, "+G", sep = ""))
-            fitG = update(fittmp, k = k)
-            fitG = optim.pml(fitG, model = model, optGamma = TRUE, 
-                             control = control)
-            res[m, 1] = paste(model, "+G", sep = "")
-            res[m, 2] = fitG$df
-            res[m, 3] = fitG$logLik
-            res[m, 4] = AIC(fitG)
-            res[m, 5] = AICc(fitG)
-            res[m, 6] = AIC(fitG, k = log(nseq))
-            calls[[m]] = fitG$call
-            trees[[m]] = fitG$tree
-            m = m + 1
-        }
-        if (G & I) {
-            if(trace>0)print(paste(model, "+G+I", sep = ""))
-            fitGI = optim.pml(fitG, model = model, optGamma = TRUE, 
-                              optInv = TRUE, control = control)
-            res[m, 1] = paste(model, "+G+I", sep = "")
-            res[m, 2] = fitGI$df
-            res[m, 3] = fitGI$logLik
-            res[m, 4] = AIC(fitGI)
-            res[m, 5] = AICc(fitGI)
-            res[m, 6] = AIC(fitGI, k = log(nseq))
-            calls[[m]] = fitGI$call
-            trees[[m]] = fitGI$tree
-            m = m + 1
-        }
-        list(res, trees, calls)
-    }
-    eval.success <- FALSE
-    if (!eval.success & multicore) {
-        # !require(parallel) ||         
-        if (.Platform$GUI != "X11") {
-            warning("package 'parallel' not found or GUI is used, \n      analysis is performed in serial")
-        }
-        else {
-            RES <- mclapply(model, fitPar, fit, G, I, k)
-            eval.success <- TRUE
-        }
-    }
-    if (!eval.success) 
-        res <- RES <- lapply(model, fitPar, fit, G, I, k)
-    
-    RESULT = matrix(NA, n * l, 6)
-    RESULT = as.data.frame(RESULT)
-    colnames(RESULT) = c("Model", "df", "logLik", "AIC", "AICc", "BIC")
-    for (i in 1:l) RESULT[((i - 1) * n + 1):(n * i), ] = RES[[i]][[1]]
-    for(i in 1:l){
-        for(j in 1:n){
-            mo = RES[[i]][[1]][j,1]
-            tname = paste("tree_", mo, sep = "")
-            tmpmod = RES[[i]][[3]][[j]]
-            tmpmod["tree"] = call(tname)
-            if(!is.null(tmpmod[["k"]]))tmpmod["k"] = k
-            if(attr(data, "type")=="AA") tmpmod["model"] = RES[[i]][[1]][1,1]          
-            assign(tname, RES[[i]][[2]][[j]], envir=env)
-            assign(mo, tmpmod, envir=env) 
-        }
-    }
-    attr(RESULT, "env") = env 
-    RESULT
-}
 
- 
 optimGamma = function(tree, data, shape=1, k=4,...){
     fn = function(shape, tree, data, k,...)pml.fit(tree, data, shape=shape, k=k,...)
     res = optimize(f=fn, interval = c(0.1, 500), lower = 0.1, upper = 500, maximum = TRUE,
@@ -317,12 +206,18 @@ AICc <- function (object, ...)
 AICc.pml <- function(object, ...){
     n = sum(object$weight)
     k = object$df
-#    if(k>=(n-1))return(NULL)    
+    if(k >= (n-1)) return(NaN)
     res = AIC(object)
     res +   (2*k*(k+1))/(n-k-1)    
 }
 
 
+BIC.pml <- function(object, ...){
+    res = AIC(object, k=log(sum(object$weight)))
+    res     
+}
+
+
 anova.pml <- function (object, ...) 
 {
     X <- c(list(object), list(...))
@@ -468,17 +363,15 @@ pml.init <- function(data, k=1L){
     nr <- attr(data, "nr")
     nc <- attr(data, "nc")    
     .C("ll_init", as.integer(nr), as.integer(nTips), as.integer(nc), as.integer(k))
-    INV <- lli(data) #, tree
+#    INV <- lli(data) #, tree
 #    .iind <<- which((INV %*% rep(1, nc)) > 0)
 #    .INV <<-  Matrix(INV, sparse=TRUE)
-    assign(".iind", which((INV %*% rep(1, nc)) > 0), envir=parent.frame())
-    assign(".INV", Matrix(INV, sparse=TRUE), envir=parent.frame())
+#    assign(".iind", which((INV %*% rep(1, nc)) > 0), envir=parent.frame())
+#    assign(".INV", Matrix(INV, sparse=TRUE), envir=parent.frame())
 } 
 
 
-
 pml.free2 <- function(){.C("ll_free2")}
-
 pml.init2 <- function(data, k=1L){
     nTips <- length(data)
     nr <- attr(data, "nr")
@@ -583,13 +476,13 @@ optim.quartet2 <- function (old.el, eig, bf, dat1, dat2, dat3, dat4, g = 1, w =
 }
 
 
-pml.nni <- function (tree, data, w, g, eig, bf, ll.0, ll, ...) 
+pml.nni.old <- function (tree, data, w, g, eig, bf, ll.0, ll, ...) 
 {        
     k = length(w)
     INDEX <-  indexNNI(tree)
     rootEdges <- attr(INDEX,"root")
     .dat <- NULL
-    data = getCols(data, tree$tip)
+    data = getCols(data, tree$tip.label)
 
     parent = tree$edge[,1]
     child = tree$edge[,2]
@@ -643,7 +536,7 @@ pml.nni <- function (tree, data, w, g, eig, bf, ll.0, ll, ...)
  
 #    on.exit(.C("ll_free"))
 #    .C("ll_init", nr, nTips, nc, as.integer(k))
-
+#    cat("candidates", sum(candidates), "\n")
     while(any(candidates)){     
         ind = which.max(loglik)
         loglik[ind]=-Inf
@@ -671,7 +564,7 @@ rnodes <- function (tree, data, w, g, eig, bf)
     if (is.null(attr(tree, "order")) || attr(tree, "order") == 
         "cladewise") 
         tree <- reorder(tree, "postorder")
-    data = getCols(data, tree$tip) 
+    data = getCols(data, tree$tip.label) 
     q = length(tree$tip.label)
     node <- tree$edge[, 1]
     edge <- tree$edge[, 2]
@@ -688,7 +581,7 @@ rnodes <- function (tree, data, w, g, eig, bf)
     nc <- as.integer(attr(data, "nc"))
     node = as.integer(node - min(node))
     edge = as.integer(edge - 1)
-    nTips = as.integer(length(tree$tip))
+    nTips = as.integer(length(tree$tip.label))
     mNodes = as.integer(max(node) + 1)
     contrast = attr(data, "contrast")
     nco = as.integer(dim(contrast)[1])
@@ -815,472 +708,151 @@ pml.control <- function (epsilon = 1e-08, maxit = 10, trace = 1)
 }
 
 
-optim.pml <- function (object, optNni = FALSE, optBf = FALSE, optQ = FALSE, 
-    optInv = FALSE, optGamma = FALSE, optEdge = TRUE, optRate = FALSE, optRooted=FALSE, 
-    control = pml.control(epsilon = 1e-8, maxit = 10, trace = 1L), 
-    model = NULL, subs = NULL, ...) 
+# improves trees similar to 
+likelihoodRatchet <- function(obj, maxit=100, k=10, 
+        control=pml.control(epsilon = 1e-08, maxit = 10, trace = 1L)){
+    tree = obj$tree
+    nTips <- length(tree$tip.label)
+    trace = control$trace
+    control$trace = trace-1L
+    kmax=1
+    for(i in 1:maxit){
+        tree<- rNNI(obj$tree, moves=nTips/3, n=1)
+        #tree <- rSPR(tree, moves=10, k=3, n=1)
+        obj2 = update(obj, tree=tree)
+        obj2 <- optim.pml(obj2, TRUE, control = control)
+        if(logLik(obj2) > logLik(obj)){
+            obj <- obj2
+            kmax=1
+        } 
+        else kmax = kmax+1
+        if(trace > 0) print(paste("Iteration ", i,", best pscore so far:",logLik(obj)))
+        if(kmax == k) break()
+    }  
+    obj
+}
+
+
+fs <- function (old.el, eig, parent.dat, child.dat, weight, g=g, 
+    w=w, bf=bf, ll.0=ll.0, evi, getA=TRUE, getB=TRUE) 
 {
-    extras <- match.call(expand.dots = FALSE)$...
-    pmla <- c("wMix", "llMix")
-    wMix <- object$wMix
-    llMix <- object$llMix
-    if(is.null(llMix)) llMix=0
-    if (!is.null(extras)) {
-        names(extras) <- pmla[pmatch(names(extras), pmla)]
-        existing <- match(pmla, names(extras))
-        if (!is.na(existing[1])) 
-            wMix <- eval(extras[[existing[1]]], parent.frame())
-        if (!is.na(existing[2])) 
-            llMix <- eval(extras[[existing[2]]], parent.frame())
-    }
-    tree = object$tree
-    call = object$call
-    if(optNni) {
-        if(!is.binary.tree(tree)) 
-            tree = multi2di(tree)
-        optEdge = TRUE     
-    }
-    if(is.rooted(tree)) {
-        if(optRooted==FALSE && optEdge==TRUE){
-            tree = unroot(tree)
-            attr(tree, "order") <- NULL
-            tree = reorder(tree, "postorder")
-            warning("I unrooted the tree", call. = FALSE)
-        }    
-    }
-    if(is.null(attr(tree, "order")) || attr(tree, "order") == 
-        "cladewise") 
-        tree <- reorder(tree, "postorder")
-    if(any(tree$edge.length < 1e-08)) {
-        tree$edge.length[tree$edge.length < 1e-08] <- 1e-08
-# save to change to new update.pml       
-        object <- update.pml(object, tree = tree)
+    if (old.el < 1e-8) old.el <- 1e-8
+    lg = length(parent.dat)
+    P <- getP(old.el, eig, g)
+    nr = as.integer(length(weight))
+    nc = as.integer(length(bf))
+    eve = eig[[2]]
+    dad <- .Call("getDAD", parent.dat, child.dat, P, nr, nc) 
+    X <- .Call("getPrep", dad, child.dat, eig[[2]], evi, nr, nc) 
+    .Call("FS4", eig, as.integer(length(bf)), as.double(old.el), 
+            as.double(w), as.double(g), X, child.dat, dad, as.integer(length(w)), 
+            as.integer(length(weight)), as.double(bf), as.double(weight), 
+            as.double(ll.0), as.integer(getA), as.integer(getB))
+}
+
+
+fs3 <- function (old.el, eig, parent.dat, child, weight, g=g, 
+    w=w, bf=bf, ll.0=ll.0, contrast, contrast2, evi, ext=TRUE, getA=TRUE, getB=TRUE) # child.dat
+{
+    if (old.el < 1e-8) old.el <- 1e-8
+    lg = length(parent.dat)
+    P <- getP(old.el, eig, g)
+    nr = as.integer(length(weight))
+    nc = as.integer(length(bf))
+    if(ext==FALSE){ 
+       child.dat <- child
+       eve = eig[[2]]
+       dad <- .Call("getDAD", parent.dat, child.dat, P, nr, nc) 
+       X <- .Call("getPrep", dad, child.dat, eig[[2]], evi, nr, nc) 
     }
-    if(optEdge & optRate) {
-        warning("You can't optimise edges and rates at the same time, only edges are optimised!", call. = FALSE)
-        optRate = FALSE
+    else {
+        nco = as.integer(nrow(contrast))
+        dad <- .Call("getDAD2", parent.dat, child, contrast, P, nr, nc, nco)
+        child.dat <- vector("list", lg)
+        for (i in 1:lg)child.dat[[i]] <- contrast[child, , drop=FALSE]
+        X <- .Call("getPrep2", dad, child, contrast2, evi, nr, nc, nco)
     }
-    if(optRooted){
-        optEdge = FALSE
-        if(!is.rooted(tree)) stop("Tree must be rooted!")
-        if(!is.ultrametric(tree)) stop("Tree must be ultrametric!")
-	}
-    trace <- control$trace
-    
-    data = object$data
-    data = subset(data, tree$tip.label) 
+    .Call("FS4", eig, as.integer(length(bf)), as.double(old.el), 
+            as.double(w), as.double(g), X, child.dat, dad, as.integer(length(w)), 
+            as.integer(length(weight)), as.double(bf), as.double(weight), 
+            as.double(ll.0), as.integer(getA), as.integer(getB))
+}
 
-    type <- attr(data, "type")
-    if (type == "AA" & !is.null(model)){
-        object = update(object, model=model)  
-    }     
-    if (type == "CODON") {
-        dnds <- object$dnds 
-        tstv <- object$tstv
-        if(!is.null(model)){
-            if(model == "codon0") optQ = FALSE
-            else  optQ = TRUE
-        }
-    }       
-    Q = object$Q
-    if(is.null(subs)) subs = c(1:(length(Q) - 1), 0)
-    bf = object$bf
-    eig = object$eig
-    inv = object$inv
-    k = object$k
-    if(k==1 & optGamma){
-        optGamma = FALSE
-        message('only one rate class, ignored optGamma')
-    }
-    shape = object$shape
-    w = object$w
-    g = object$g
-    if (type == "DNA" & !is.null(model)) {
-        tmp = subsChoice(model)
-        optQ = tmp$optQ
-        if (!optQ) 
-            Q = rep(1, 6)
-        optBf = tmp$optBf
-        if (!optBf) 
-            bf = c(0.25, 0.25, 0.25, 0.25)
-        subs = tmp$subs
-    }   
-    ll0 <- object$logLik
-    INV <- object$INV
-    ll.0 <- object$ll.0
-    rate <- object$rate
-    ll = ll0
-    ll1 = ll0
-    opti = TRUE
 
-    nr <- as.integer(attr(data, "nr")) 
-    nc <- as.integer(attr(data, "nc"))
-    nTips <- as.integer(length(tree$tip.label))
- 
-#    on.exit(.C("ll_free"))
-#    .C("ll_init", nr, nTips, nc, as.integer(k))
-    .INV <- .iind <- NULL
-    on.exit({
-        pml.free()
-#        rm(.INV, .iind)
-        })
-    pml.init(data, k)    
+optimEdge <- function (tree, data, eig=eig, w=w, g=g, bf=bf, rate=rate, ll.0=ll.0,
+                        control = pml.control(epsilon = 1e-08, maxit = 10, trace=0), ...) 
+{
+    if (is.null(attr(tree, "order")) || attr(tree, "order") == "cladewise") 
+        tree <- reorder(tree, "postorder") 
+    nTips <- length(tree$tip.label)
+    el <- tree$edge.length
+    tree$edge.length[el < 1e-08] <- 1e-08
+    oldtree = tree
+    k = length(w)    
+    data = subset(data, tree$tip.label) 
+    loglik = pml.fit4(tree, data, bf=bf, g=g, w=w, eig=eig, ll.0=ll.0, k=k) 
+    start.ll <- old.ll <- loglik 
+    contrast <- attr(data, "contrast")
+    contrast2 <- contrast %*% eig[[2]] 
+    evi = (t(eig[[3]]) * bf)
+    weight <- attr(data, "weight")
+    eps = 1
+    iter = 0
     
-    if (optEdge) {
-         res <- optimEdge(tree, data, eig=eig, w=w, g=g, bf=bf, rate=rate, ll.0=ll.0, INV=INV,
-              control = pml.control(epsilon = 1e-07, maxit = 5, trace=trace - 1)) 
-         if(trace > 0) 
-             cat("optimize edge weights: ", ll, "-->", res[[2]], "\n")  
-        if (res[[2]] > ll){  
-           ll <- res[[2]]
-           tree <- res[[1]]
-        }
-    }
-    if(optRooted){
-	    res <- optimRooted(tree, data, eig=eig, w=w, g=g, bf=bf, rate=rate, ll.0=ll.0, INV=INV, control = pml.control(epsilon = 1e-07, maxit = 10, trace = trace-1))
-	    if(trace > 0) 
-	        cat("optimize edge weights: ", ll, "-->", res[[2]], "\n")
-	    if(res[[2]] > ll){  
-           ll <- res[[2]]
-           tree <- res[[1]]
-        }     
-	}
-    rounds = 1
-    while (opti) {
-        if (optBf) {
-            res = optimBf(tree, data, bf = bf, inv = inv, Q = Q, 
-                w = w, g = g, INV = INV, rate = rate, k = k, 
-                llMix = llMix)
-            bf = res[[1]]
-            eig = edQt(Q = Q, bf = bf)
-            if (inv > 0) 
-                ll.0 <- as.matrix(INV %*% (bf * inv))
-            if (wMix > 0) 
-                ll.0 <- ll.0 + llMix
-            if (trace > 0) 
-                cat("optimize base frequencies: ", ll, "-->", 
-                  res[[2]], "\n")
-            ll = res[[2]]
-        }
-        if (optQ) {
-            if(type=="CODON"){
-                 if(is.null(model)) model <- "codon1"
-                 model <- match.arg(model, c("codon0", "codon1", "codon2", "codon3"))
-                 ab <- c(tstv, dnds)
-                 res <- switch(model, 
-                     codon1 = optimCodon(tree,data, Q=rep(1,1830), subs=.sub, syn=.syn, 
-                         bf = bf, w = w, g = g, inv = inv, INV = INV, ll.0 = ll.0, rate = rate, k = k, ab=log(ab),
-                         optK=TRUE, optW = TRUE),  
-                     codon2 = optimCodon(tree,data, Q=rep(1,1830), subs=.sub, syn=.syn, 
-                         bf = bf, w = w, g = g, inv = inv, INV = INV, ll.0 = ll.0, rate = rate, k = k, ab=log(ab), 
-                         optK=FALSE, optW = TRUE),
-                     codon3 = optimCodon(tree,data, Q=rep(1,1830), subs=.sub, syn=.syn, 
-                         bf = bf, w = w, g = g, inv = inv, INV = INV, ll.0 = ll.0, rate = rate, k = k, ab=log(ab),
-                         optK=TRUE, optW = FALSE))
-                 tmp <- res[[5]]
-                 m = length(tmp)
-                 dnds = tmp[m]
-                   
-                 if(m>1) tstv <- tmp[1]
-            }
-            else
-            res = optimQ(tree, data, Q = Q, subs = subs, bf = bf, w = w, g = g, inv = inv, INV = INV, 
-                ll.0 = ll.0, rate = rate, k = k)
-            Q = res[[1]]
-            eig = edQt(Q = Q, bf = bf)
-            if (trace > 0) 
-                cat("optimize rate matrix: ", ll, "-->", res[[2]], 
-                  "\n")
-            ll = res[[2]]
-        }
-        if(optInv) {
-            res = optimInv(tree, data, inv = inv, INV = INV, Q = Q, 
-                bf = bf, eig = eig, k = k, shape = shape, rate = rate)
-            inv = res[[1]]
-            w = rep(1/k, k)
-            g = discrete.gamma(shape, k)
-            w = (1 - inv) * w
-            if (wMix > 0) 
-                w <- (1 - wMix) * w
-            g = g/(1 - inv)
-            g <- g * rate
-            ll.0 = as.matrix(INV %*% (bf * inv))
-            if (wMix > 0) 
-                ll.0 <- ll.0 + llMix
-            if (trace > 0) 
-                cat("optimize invariant sites: ", ll, "-->", res[[2]], "\n")
-            ll = res[[2]]
-        }
-        if(optGamma) {
-            res = optimGamma(tree, data, shape = shape, k = k, 
-                inv = inv, INV = INV, Q = Q, bf = bf, eig = eig, 
-                ll.0 = ll.0, rate = rate)
-            shape = res[[1]]
-            w = rep(1/k, k)
-            g = discrete.gamma(shape, k)
-            if (inv > 0) {
-                w = (1 - inv) * w
-                g = g/(1 - inv)
-            }
-            if (wMix > 0) 
-                w <- (1 - wMix) * w
-            g <- g * rate
-            if (trace > 0) 
-                cat("optimize shape parameter: ", ll, "-->", 
-                  res[[2]], "\n")
-            ll = res[[2]]
-        }
-        if(optRate) {
-            res = optimRate(tree, data, rate = rate, inv = inv, 
-                INV = INV, Q = Q, bf = bf, eig = eig, k = k, 
-                shape = shape, w = w, ll.0 = ll.0)
-            if (res[[2]] > ll)rate = res[[1]]
-            g = discrete.gamma(shape, k)
-            w = rep(1/k, k)
-            if (inv > 0) {
-                w = (1 - inv) * w
-                g = g/(1 - inv)
-            }
-            if (wMix > 0) 
-                w <- (1 - wMix) * w
-            g <- g * rate
-            if (trace > 0) 
-                cat("optimize rate: ", ll, "-->", res[[2]], "\n")
-            ll = res[[2]]
-        }
-        if (optEdge) {  
-           res <- optimEdge(tree, data, eig=eig, w=w, g=g, bf=bf, rate=rate, ll.0=ll.0,
-                 control = pml.control(epsilon = 1e-08, maxit = 5, trace=trace - 1)) 
-           if (trace > 0) 
-              cat("optimize edge weights: ", ll, "-->", res[[2]], "\n")
-           if (res[[2]] > ll){  
-              ll <- res[[2]]
-              tree <- res[[1]]
-           }
-        }
-        if(optRooted){
-	        res <- optimRooted(tree, data, eig=eig, w=w, g=g, bf=bf, rate=rate, ll.0=ll.0, INV=INV, control = pml.control(epsilon = 1e-07, maxit = 10, trace = trace-1))
-	        if(trace > 0) 
-	            cat("optimize edge weights: ", ll, "-->", res[[2]], "\n")
-	        if (res[[2]] > ll){  
-                ll <- res[[2]]
-                tree <- res[[1]]
-            }     
-	    }
-        if(optNni) {
-            swap = 0
-            iter = 1
-            while (iter < 4) {
-                if(optEdge){
-                    tmp <- pml.nni(tree, data, w, g, eig, bf, ll.0, ll, ...) 
-                    swap = swap + tmp$swap
-                    res <- optimEdge(tmp$tree, data, eig=eig, w=w, g=g, bf=bf, rate=rate, ll.0=ll.0, control = pml.control(epsilon = 1e-08, maxit = 3, trace=0)) 
-                    ll2 = res[[2]] 
-                    tree <- res[[1]]
-                }
-                else{ 
-                    tmp <- rooted.nni(tree, data, eig=eig, w=w, g=g, bf=bf, rate=rate, ll.0=ll.0, INV=INV, ...) 
-                    swap = swap + tmp$swap
-                    res <- optimRooted(tmp$tree, data, eig=eig, w=w, g=g, bf=bf, rate=rate, ll.0=ll.0, INV=INV, control = pml.control(epsilon = 1e-07, maxit = 5, trace = trace-1))
-                    tree <- tmp$tree
-                    ll2 = tmp$logLik
-                }
-                if (trace > 0) 
-                  cat("optimize topology: ", ll, "-->", ll2, "\n")
-                ll = ll2
-                iter = iter + 1
-                if (tmp$swap == 0) {
-                  iter = 4
-                }
-            }
-            if (trace > 0) 
-                cat(swap, "\n")
-            if (swap > 0) 
-                rounds = 1
-            if (swap == 0) 
-                optNni = FALSE
-        }
-        rounds = rounds + 1
-        if(rounds > control$maxit) opti <- FALSE
-        if (( ll1 - ll ) / ll  < control$eps) #abs(ll1 - ll)
-            opti <- FALSE
-        ll1 = ll
-    }  
-    if(type=="CODON"){
-        object$dnds = dnds
-        object$tstv = tstv
-    }
-    
-    tmp <- pml.fit(tree, data, bf, shape = shape, k = k, Q = Q, 
-        levels = attr(data, "levels"), inv = inv, rate = rate, 
-        g = g, w = w, eig = eig, INV = INV, ll.0 = ll.0, llMix = llMix, 
-        wMix = wMix, site = TRUE)
-    
-    df <- ifelse(optRooted, tree$Nnode, length(tree$edge.length))
-    # length(tree$edge.length)    
-    if (type == "CODON") {
-        df <- df + (k > 1) + (inv > 0) + 
-            length(unique(bf)) - 1 + (dnds != 1) + (tstv != 1) 
-    }
-    else df = df + (k > 1) + (inv > 0) + 
-        length(unique(bf)) - 1 + length(unique(Q)) - 1
-    
-    object = list(logLik = tmp$loglik, inv = inv, k = k, shape = shape, 
-        Q = Q, bf = bf, rate = rate, siteLik = tmp$siteLik, weight = attr(data, "weight"), 
-        g = g, w = w, eig = eig, data = data, model = model, 
-        INV = INV, ll.0 = ll.0, tree = tree, lv = tmp$resll, 
-        call = call, df = df, wMix = wMix, llMix = llMix)
-    if (type == "CODON") {
-        object$dnds <- dnds
-        object$tstv <- tstv
-    }
-    class(object) = "pml"
-
-    extras = pairlist(bf = bf, Q = Q, inv = inv, shape = shape, rate = rate)[c(optBf, optQ, optInv, optGamma, optRate)]
-    if (length(extras)) {
-        existing <- !is.na(match(names(extras), names(call)))
-        for (a in names(extras)[existing]) call[[a]] <- extras[[a]]
-        if (any(!existing)) {
-            call <- c(as.list(call), extras[!existing])
-            call <- as.call(call)
-        }
-    }
-    object$call = call   
-    object
-}
-
-
-fs <- function (old.el, eig, parent.dat, child.dat, weight, g=g, 
-    w=w, bf=bf, ll.0=ll.0, evi, getA=TRUE, getB=TRUE) 
-{
-    if (old.el < 1e-8) old.el <- 1e-8
-    lg = length(parent.dat)
-    P <- getP(old.el, eig, g)
-    nr = as.integer(length(weight))
-    nc = as.integer(length(bf))
-    eve = eig[[2]]
-    dad <- .Call("getDAD", parent.dat, child.dat, P, nr, nc) 
-    X <- .Call("getPrep", dad, child.dat, eig[[2]], evi, nr, nc) 
-    .Call("FS4", eig, as.integer(length(bf)), as.double(old.el), 
-            as.double(w), as.double(g), X, child.dat, dad, as.integer(length(w)), 
-            as.integer(length(weight)), as.double(bf), as.double(weight), 
-            as.double(ll.0), as.integer(getA), as.integer(getB))
-}
-
-
-fs3 <- function (old.el, eig, parent.dat, child, weight, g=g, 
-    w=w, bf=bf, ll.0=ll.0, contrast, contrast2, evi, ext=TRUE, getA=TRUE, getB=TRUE) # child.dat
-{
-    if (old.el < 1e-8) old.el <- 1e-8
-    lg = length(parent.dat)
-    P <- getP(old.el, eig, g)
-    nr = as.integer(length(weight))
-    nc = as.integer(length(bf))
-    if(ext==FALSE){ 
-       child.dat <- child
-       eve = eig[[2]]
-       dad <- .Call("getDAD", parent.dat, child.dat, P, nr, nc) 
-       X <- .Call("getPrep", dad, child.dat, eig[[2]], evi, nr, nc) 
-    }
-    else {
-        nco = as.integer(nrow(contrast))
-        dad <- .Call("getDAD2", parent.dat, child, contrast, P, nr, nc, nco)
-        child.dat <- vector("list", lg)
-        for (i in 1:lg)child.dat[[i]] <- contrast[child, , drop=FALSE]
-        X <- .Call("getPrep2", dad, child, contrast2, evi, nr, nc, nco)
-    }
-    .Call("FS4", eig, as.integer(length(bf)), as.double(old.el), 
-            as.double(w), as.double(g), X, child.dat, dad, as.integer(length(w)), 
-            as.integer(length(weight)), as.double(bf), as.double(weight), 
-            as.double(ll.0), as.integer(getA), as.integer(getB))
-}
-
-
-
-optimEdge <- function (tree, data, eig=eig, w=w, g=g, bf=bf, rate=rate, ll.0=ll.0,
-                        control = pml.control(epsilon = 1e-08, maxit = 10, trace=0), ...) 
-{
-    if (is.null(attr(tree, "order")) || attr(tree, "order") == "cladewise") 
-        tree <- reorder(tree, "postorder") 
-    nTips <- length(tree$tip)
-    el <- tree$edge.length
-    tree$edge.length[el < 1e-08] <- 1e-08
-    oldtree = tree
-    k = length(w)    
-    data = subset(data, tree$tip) 
-    loglik = pml.fit2(tree, data, bf=bf, g=g, w=w, eig=eig, ll.0=ll.0, k=k)
-    start.ll <- old.ll <- loglik 
-    contrast <- attr(data, "contrast")
-    contrast2 <- contrast %*% eig[[2]] 
-    evi = (t(eig[[3]]) * bf)
-    weight <- attr(data, "weight")
-    eps = 1
-    iter = 0
-    
-    treeP = tree
-    tree = reorder(tree)
-    
-    child = tree$edge[, 2]
-    parent = tree$edge[, 1]
-    m <- max(tree$edge)
-    pvec <- integer(m)
-    pvec[child] <- parent
-    
-    EL = numeric(m)
-    EL[child] = tree$edge.length
-    
-    n = length(tree$edge.length)  
-    
-    nr = as.integer(length(weight))
-    nc = as.integer(length(bf))
-    nco = as.integer(nrow(contrast))
-    eve = eig[[2]]
-    lg = k
-    rootNode = getRoot(tree)         
-    ScaleEPS = 1.0/4294967296.0
-    anc = Ancestors(tree, 1:m, "parent")  
-    anc0 = as.integer(c(0L, anc))
-    
-    while (eps > control$eps && iter < control$maxit) {
-        blub3 <- .Call("extractScale", as.integer(rootNode), w, g, as.integer(nr), as.integer(nc), as.integer(nTips))
-        rowM = apply(blub3, 1, min)       
-        blub3 = (blub3-rowM) 
-        blub3 = ScaleEPS ^ (blub3) 
-        EL <- .Call("optE", as.integer(parent), as.integer(child), 
-                    as.integer(anc0), eig, evi, EL, w, g, as.integer(nr), as.integer(nc), 
-                    as.integer(nTips), as.double(contrast), 
-                    as.double(contrast2), nco, blub3, data, as.double(weight), as.double(ll.0))       
-        iter = iter + 1
-#        tree$edge.length = EL[tree$edge[,2]]
-        treeP$edge.length = EL[treeP$edge[,2]]
-        newll <- pml.fit2(treeP, data, bf=bf, g=g, w=w, eig=eig, ll.0=ll.0, k=k)
-        
-        eps = ( old.ll - newll ) / newll
-        if( eps <0 ) return(list(oldtree, old.ll))
-        oldtree = treeP
-        if(control$trace>1) cat(old.ll, " -> ", newll, "\n") 
-        old.ll = newll
-        #        loli = parent[1] 
+    treeP = tree
+    tree = reorder(tree)
+    
+    child = tree$edge[, 2]
+    parent = tree$edge[, 1]
+    m <- max(tree$edge)
+    pvec <- integer(m)
+    pvec[child] <- parent
+    
+    EL = numeric(m)
+    EL[child] = tree$edge.length
+    
+    n = length(tree$edge.length)  
+    
+    nr = as.integer(length(weight))
+    nc = as.integer(length(bf))
+    nco = as.integer(nrow(contrast))
+    eve = eig[[2]]
+    lg = k
+    rootNode = getRoot(tree)  # raus       
+    ScaleEPS = 1.0/4294967296.0
+    anc = Ancestors(tree, 1:m, "parent")  
+    anc0 = as.integer(c(0L, anc))
+    
+    while (eps > control$eps && iter < control$maxit) {
+        EL <- .Call("optE", as.integer(parent), as.integer(child), 
+                    as.integer(anc0), eig, evi, EL, w, g, as.integer(nr), as.integer(nc), 
+                    as.integer(nTips), as.double(contrast), 
+                    as.double(contrast2), nco, data, as.double(weight), as.double(ll.0))       
+        iter = iter + 1
+        treeP$edge.length = EL[treeP$edge[,2]]
+        newll <- pml.fit4(treeP, data, bf=bf, g=g, w=w, eig=eig, ll.0=ll.0, k=k)
+        
+        eps = ( old.ll - newll ) / newll
+        if( eps <0 ) return(list(oldtree, old.ll))
+        oldtree = treeP
+        if(control$trace>1) cat(old.ll, " -> ", newll, "\n") 
+        old.ll = newll
     }
     if(control$trace>0) cat(start.ll, " -> ", newll, "\n")
     list(tree=treeP, logLik=newll, c(eps, iter))
 }
 
 
-# bf raus C naeher
-# data=data, k=k, g=g, w=w, eig=eig, bf=bf, ll.0=ll.0, INV=INV)
 pml.move <- function(EDGE, el, data, g, w, eig, k, nTips, bf){
     node <- EDGE[, 1]
     edge <- EDGE[, 2]
-    root <- as.integer(node[length(node)])     
-#    el <- as.double(tree$edge.length)
     nr = as.integer(attr(data, "nr"))
     nc = as.integer(attr(data, "nc"))    
     node = as.integer(node - nTips - 1L)  
     edge = as.integer(edge - 1L)
     contrast = attr(data, "contrast")
     nco = as.integer(dim(contrast)[1])    
-    tmp <- .Call("PML3", dlist=data, as.double(el), as.double(w), as.double(g), nr, nc, k, eig, as.double(bf), node, edge, nTips, root, nco, contrast, N=as.integer(length(edge))) 
+    tmp <- .Call("PML3", dlist=data, as.double(el), as.double(w), as.double(g), nr, nc, k, eig, as.double(bf), node, edge, nTips, nco, contrast, N=as.integer(length(edge))) 
     return(NULL)
 }
 
@@ -1390,7 +962,7 @@ optimPartGamma <- function (object, shape = 1, ...)
 dltmp <- function (fit, i=1, transform=transform) # i = weights
 {
     tree = fit$tree 
-    data = getCols(fit$data, tree$tip) 
+    data = getCols(fit$data, tree$tip.label) 
     if (is.null(attr(tree, "order")) || attr(tree, "order") == 
         "cladewise") 
         tree <- reorder(tree, "postorder")
@@ -1409,7 +981,7 @@ dltmp <- function (fit, i=1, transform=transform) # i = weights
     nc <- as.integer(attr(data, "nc"))
     node = as.integer(node - min(node))
     edge = as.integer(edge - 1)
-    nTips = as.integer(length(tree$tip))
+    nTips = as.integer(length(tree$tip.label))
     mNodes = as.integer(max(node) + 1)
     contrast = attr(data, "contrast")
     nco = as.integer(dim(contrast)[1])
@@ -1507,7 +1079,7 @@ optimPartEdge <- function (object, ...)
 
 
 makePart <- function(fit, rooted, weight=~index+genes){
-    if(class(fit)=="phyDat"){
+    if(inherits(fit,"phyDat")){
         x <- fit
         dm <- dist.ml(x)
         if(!rooted) tree <- NJ(dm)
@@ -1536,7 +1108,7 @@ multiphyDat2pmlPart <- function(x, rooted=FALSE, ...){
         else tree <- upgma(dm)
         fit <- pml(tree, x, ...)
     }
-    fits <- lapply(x at dna, fun, ...)
+    fits <- lapply(x at seq, fun, ...)
     fits
 }
 
@@ -1574,14 +1146,16 @@ pmlPart <- function (formula, object, control=pml.control(epsilon=1e-8, maxit=10
     PartEdge <- !is.na(optPart[6])
     PartRate <- !is.na(optPart[7])
  
-    if(class(object)=="multiphyDat"){
-        if(AllNNI || AllEdge) object <- do.call(cbind.phyDat, object at dna)
+    if(PartNni) PartEdge <- TRUE
+    
+    if(inherits(object,"multiphyDat")){
+        if(AllNNI || AllEdge) object <- do.call(cbind.phyDat, object at seq)
         else fits <- multiphyDat2pmlPart(object, rooted=rooted, ...)
     } 
-    if(class(object)=="pml") fits <- makePart(object, rooted=rooted, ...) 
-    if(class(object)=="phyDat") fits <- makePart(object, rooted=rooted, ...)
-    if(class(object)=="pmlPart") fits <- object$fits
-    if(class(object)=="list") fits <- object
+    if(inherits(object,"pml")) fits <- makePart(object, rooted=rooted, ...) 
+    if(inherits(object,"phyDat")) fits <- makePart(object, rooted=rooted, ...)
+    if(inherits(object,"pmlPart")) fits <- object$fits
+    if(inherits(object,"list")) fits <- object
 
 
     trace = control$trace
@@ -1681,7 +1255,7 @@ bip <- function (obj)
             "cladewise") 
         obj <- reorder(obj, "postorder")
     maxP = max(obj$edge)
-    nTips = length(obj$tip)
+    nTips = length(obj$tip.label)
     res <- .Call("C_bip", as.integer(obj$edge[, 1]), as.integer(obj$edge[, 2]), as.integer(nTips), as.integer(maxP))
     res
 }
@@ -1691,7 +1265,7 @@ bipart <- function(obj){
     if (is.null(attr(obj, "order")) || attr(obj, "order") == "cladewise") 
         obj <- reorder(obj, "postorder")
     maxP  = max(obj$edge)
-    nTips = length(obj$tip)
+    nTips = length(obj$tip.label)
     res <- .Call("C_bipart", as.integer(obj$edge[,1]) , as.integer(obj$edge[,2]), as.integer(nTips), as.integer(maxP))  #, as.integer(obj$Nnode))
 #    attr(res, "nodes") = unique(obj$edge[,1])
     res    
@@ -1703,7 +1277,7 @@ bipartition <- function (tree)
     if(is.rooted(tree))tree <- unroot(tree)
     if(is.null(attr(tree,"order")) || attr(tree, "order")=="cladewise") tree <- reorder(tree, "postorder")
     bp <- bipart(tree)
-    nTips = length(tree$tip)
+    nTips = length(tree$tip.label)
     l = length(bp)
     m = length(bp[[l]])
     k = length(tree$edge[, 1])
@@ -1742,6 +1316,7 @@ pmlCluster.fit <- function (formula, fit, weight, p = 4, part = NULL, control=pm
     PartGamma <- !is.na(optPart[5])
     PartEdge <- !is.na(optPart[6])
     PartRate <- !is.na(optPart[7])
+    if(PartNni) PartEdge <- TRUE
     nrw <- dim(weight)[1]
     ncw <- dim(weight)[2]
     if (is.null(part)){ 
@@ -2104,7 +1679,7 @@ update.pmlNew <- function (object, ..., evaluate = TRUE){
     else call
 }
 
-
+# add dnds tstv
 update.pml <- function (object, ...) 
 {
     extras <- match.call(expand.dots = FALSE)$...
@@ -2183,7 +1758,10 @@ update.pml <- function (object, ...)
     levels <- attr(data, "levels")
     weight <- attr(data, "weight")
     if(updateEig)eig <- edQt(bf = bf, Q = Q)
-    else eig <- object$eig
+    else{
+        eig <- object$eig
+        model <- object$model
+    } 
     g <- discrete.gamma(shape, k)
     g <- rate * g 
     if (inv > 0) g <- g/(1 - inv)
@@ -2208,12 +1786,17 @@ update.pml <- function (object, ...)
         wMix = wMix, site = TRUE)
     
     df <- ifelse(is.ultrametric(tree), tree$Nnode, length(tree$edge.length))
+#    ifelse()
+    df <- switch(type, 
+                 DNA = df + (k>1) + (inv > 0) + length(unique(bf)) - 1 + length(unique(Q)) - 1, 
+                 AA = df + (k>1) + (inv > 0) ,
+                 CODON = df + (k>1) + (inv > 0) + length(unique(bf)) - 1 , #+ (dnds != 1) + (tstv != 1),  
+                 USER = df + (k>1) + (inv > 0) + length(unique(bf)) - 1 + length(unique(Q)) - 1)
+#    if (type == "CODON") {
+#        df <- df + (k > 1) + (inv > 0) + length(unique(bf)) - 1
+#    }
+#    else df = df + (k > 1) + (inv > 0) + length(unique(bf)) - 1 + length(unique(Q)) - 1
     
-    if (type == "CODON") {
-        df <- df + (k > 1) + (inv > 0) + length(unique(bf)) - 1
-    }
-    else df = df + (k > 1) + (inv > 0) + 
-        length(unique(bf)) - 1 + length(unique(Q)) - 1
     result = list(logLik = tmp$loglik, inv = inv, k = k, shape = shape, Q = Q, bf = bf, 
         rate = rate, siteLik = tmp$siteLik, weight = weight, g = g, w = w, eig = eig, 
         data = data, model = model, INV = INV, ll.0 = ll.0, tree = tree, lv = tmp$resll,
@@ -2408,7 +1991,7 @@ pmlMix <- function (formula, fit, m = 2, omega = rep(1/m, m), control=pml.contro
     MixGamma <- !is.na(optPart[5])
     MixEdge <- !is.na(optPart[6])
     MixRate <- !is.na(optPart[7])
-    if (class(fit) == "list") 
+    if (inherits(fit,"list")) 
         fits <- fit
     else {
         fits <- vector("list", m) 
@@ -2660,8 +2243,8 @@ logLik.pmlPart <- function (object, ...)
 
 
 pmlPen <- function(object, lambda, ...){
-    if(class(object)=="pmlPart") return(pmlPartPen(object, lambda,...))
-    if(class(object)=="pmlMix") return(pmlMixPen(object, lambda,...))
+    if(inherits(object,"pmlPart")) return(pmlPartPen(object, lambda,...))
+    if(inherits(object,"pmlMix")) return(pmlMixPen(object, lambda,...))
     else stop("object has to be of class pmlPart or pmlMix")
     }
        
@@ -2861,12 +2444,11 @@ optNNI <- function(fit, INDEX){
        parent = tree$edge[, 1]
        child = tree$edge[, 2]
              
-       data = getCols(fit$data, tree$tip)
+       data = getCols(fit$data, tree$tip.label)
        datp <- rnodes(tree, data, w, g, eig, bf)       
 # nicht elegant, spaeter auch raus       
        tmp = length(tree$tip.label)
        for(i in 1:length(w)).dat[i,1:tmp]=new2old.phyDat(data)       
-#       datp = rnodes(fit) # raus
        
        evector <- numeric(max(parent))
        evector[child] <- tree$edge.length
@@ -2960,319 +2542,26 @@ optimPartNNI <- function (object, AllEdge=TRUE,...)
 }
 
 
-      
-SH.test <- function (..., B = 10000, data = NULL)
-{
-   fits <- list(...)
-   p = 1
-   if (inherits(fits[[1]],"pmlPart"))
-#       class(fits[[1]]) == "pmlPart") 
-   {
-       fits = fits[[1]]$fits
-       p = length(fits)
-   }
-   k = length(fits)
-   if (is.null(data))
-       data = fits[[1]]$data
-   res = NULL
-   for (h in 1:p) {
-       if (p > 1)
-           data = fits[[h]]$data
-       weight = attr(data, "weight")
-       lw = length(weight)
-       siteLik = matrix(0, lw, k)
-       for (i in 1:k) siteLik[, i] = update(fits[[i]], data = data)$site
-       ntree = k
-       Lalpha <- drop(crossprod(siteLik, weight))
-       Talpha <- max(Lalpha) - Lalpha
-       M <- matrix(NA, k, B)
-#        S <- matrix(NA, k, B)
-       wvec <- rep(1L:lw, weight)
-       size = length(wvec)
-       for (i in 1:B) {
-           boot = tabulate(sample(wvec, replace=TRUE), nbins=lw)
-           M[, i] <- crossprod(siteLik, boot)
-       }
-       M <- M - rowMeans(M)
-#        for (i in 1:B) for (j in 1:ntree) S[j, i] <- max(M[j, i] - M[, i])
-       S = matrix(apply(M,2,min), k, B, byrow=TRUE)
-       S = M - S
-       count <- numeric(ntree)
-       for (j in 1:ntree) count[j] <- sum(S[j, ] > Talpha[j])
-       count <- count/B
-       trees <- 1:k
-       if (p == 1)
-           res = cbind(trees, Lalpha, Talpha, count)
-       else res = rbind(res, cbind(h, trees[-h], Lalpha[-h],
-           Talpha[-h], count[-h]))
-   }
-   if (p == 1)
-       colnames(res) <- c("Trees", "ln L", "Diff ln L", "p-value")
-   else colnames(res) <- c("Partition", "Trees", "ln L", "Diff ln L",
-       "p-value")
-   res
-}
-
-
-#
-# Bootstrap functions 
-# multicore support
-#
-bootstrap.pml = function (x, bs = 100, trees = TRUE, multicore=FALSE,  ...) 
+### this is the version we want to optimise
+pml.fit4 <- function (tree, data, bf = rep(1/length(levels), length(levels)), 
+                          shape = 1, k = 1, Q = rep(1, length(levels) * (length(levels) - 1)/2), 
+                          levels = attr(data, "levels"), inv = 0, rate = 1, g = NULL, w = NULL, 
+                          eig = NULL, INV = NULL, ll.0 = NULL, llMix = NULL, wMix = 0, ..., site=FALSE) 
 {
-    data = x$data
-    weight = attr(data, "weight")
-    v = rep(1:length(weight), weight)
-    BS = vector("list", bs)
-    for (i in 1:bs) BS[[i]] = tabulate(sample(v, replace = TRUE), 
-        length(weight))
-    pmlPar <- function(weights, fit, trees = TRUE, ...) {
-        data = fit$data
-        ind <- which(weights > 0)
-        data <- getRows(data, ind)
-        attr(data, "weight") <- weights[ind]
-        fit = update(fit, data = data)
-        fit = optim.pml(fit, ...)
-        if (trees) {
-            tree = fit$tree
-            return(tree)
-        }
-        attr(fit, "data") = NULL
-        fit
-    }
-    eval.success <- FALSE
-    if (!eval.success & multicore) {
-#  !require(parallel) ||      
-        if (.Platform$GUI!="X11") {
-            warning("package 'parallel' not found or GUI is used, 
-            bootstrapping is performed in serial")
-        } else {       
-            res <- mclapply(BS, pmlPar, x, trees = trees, ...)
-            eval.success <- TRUE
-        } 
-    }
-    if (!eval.success) res <- lapply(BS, pmlPar, x, trees = trees, ...)
-    if (trees) {
-        class(res) = "multiPhylo"
-        res = .compressTipLabel(res) # save memory
-    }
-    res
-}
-
-
-bootstrap.phyDat <- function (x, FUN, bs = 100, mc.cores=1L, ...) 
-{
-    weight = attr(x, "weight")
-    v = rep(1:length(weight), weight)
-    BS = vector("list", bs)
-    for(i in 1:bs)BS[[i]]=tabulate(sample(v, replace=TRUE),length(weight)) 
-    fitPar <- function(weights, data, ...){     
-        ind <- which(weights > 0)
-        data <- getRows(data, ind)
-        attr(data, "weight") <- weights[ind]
-        FUN(data,...)        
-    }
-    res <- mclapply(BS, fitPar, x, ..., mc.cores = mc.cores) 
-    if(class(res[[1]]) == "phylo"){
-        class(res) <- "multiPhylo"   
-        res = .compressTipLabel(res) # save memory
-    }
-    res 
-}
-
-
-matchEdges = function(tree1, tree2){
-    bp1 = bip(tree1)
-    bp2 = bip(tree2)
-    l = length(tree1$tip)
-    fn = function(x, y){
-        if(x[1]==1)return(x)
-        else return(y[-x])
-        } 
-    bp1[] = lapply(bp1, fn, 1:l)
-    bp2[] = lapply(bp2, fn, 1:l)
-    match(bp1, bp2)
-}
-
-
-checkLabels <- function(tree, tip){
-  ind <- match(tip, tree$tip.label)
-  tree$tip.label <- tree$tip.label[ind]
-  ind2 <- match(1:length(ind), tree$edge[, 2])
-  tree$edge[ind2, 2] <- order(ind)
-  tree
-}
-
-
-plotBS <- function (tree, BStrees, type = "unrooted", bs.col = "black", 
-          bs.adj = NULL, p=80, ...) 
-{
-    # prop.clades raus??
-    prop.clades <- function(phy, ..., part = NULL, rooted = FALSE) {
-        if (is.null(part)) {
-            obj <- list(...)
-            if (length(obj) == 1 && class(obj[[1]]) != "phylo") 
-                obj <- unlist(obj, recursive = FALSE)
-            if (!identical(phy$tip, obj[[1]]$tip)) 
-                obj[[1]] = checkLabels(obj[[1]], phy$tip)
-            part <- prop.part(obj, check.labels = TRUE)
-        }
-        bp <- prop.part(phy)
-        if (!rooted) {
-            bp <- postprocess.prop.part(bp)
-            part <- postprocess.prop.part(part)
-        }
-        n <- numeric(phy$Nnode)
-        for (i in seq_along(bp)) {
-            for (j in seq_along(part)) {
-                if (identical(bp[[i]], part[[j]])) {
-                    n[i] <- attr(part, "number")[j]
-                    done <- TRUE
-                    break
-                }
-            }
-        }
-        n
-    }
-    type <- match.arg(type, c("phylogram", "cladogram", "fan", 
-                              "unrooted", "radial"))
-    if (type == "phylogram" | type == "cladogram") {
-        if (!is.rooted(tree) & !is.null(tree$edge.length)) 
-            tree2 = midpoint(tree)
-        else tree2=tree
-        plot(tree2, type = type, ...)
-    }
-    else plot(tree, type = type, ...)
-    BStrees <- .uncompressTipLabel(BStrees)
-    x = prop.clades(tree, BStrees)
-    x = round((x/length(BStrees)) * 100)
-    tree$node.label = x
-    label = c(rep(0, length(tree$tip)), x)
-    ind <- get("last_plot.phylo", envir = .PlotPhyloEnv)$edge[, 
-                                                              2]
-    if (type == "phylogram" | type == "cladogram") {
-        root = getRoot(tree)
-        label = c(rep(0, length(tree$tip)), x)
-        label[root] = 0
-        ind2 = matchEdges(tree2, tree)
-        label = label[ind2]
-        ind = which(label > p)
-#        browser()
-        if (is.null(bs.adj)) 
-            bs.adj = c(1, 1)
-        if(length(ind)>0)nodelabels(text = label[ind], node = ind, frame = "none", 
-                   col = bs.col, adj = bs.adj, ...)
-    }
-    else {
-        if (is.null(bs.adj)) 
-            bs.adj = c(0.5, 0.5)
-        ind2 = which(label[ind]>p)
-        if(length(ind2>0))edgelabels(label[ind][ind2],ind2, frame = "none", col = bs.col, 
-                   adj = bs.adj, ...)
-    }
-    invisible(tree)
-}
-
-
-pml.fit2 <- function (tree, data, bf = rep(1/length(levels), length(levels)), 
-                     shape = 1, k = 1, Q = rep(1, length(levels) * (length(levels) - 1)/2), 
-                     levels = attr(data, "levels"), inv = 0, rate = 1, g = NULL, w = NULL, 
-                     eig = NULL, INV = NULL, ll.0 = NULL, llMix = NULL, wMix = 0, ..., site=FALSE) 
-{
-    weight <- as.double(attr(data, "weight"))
-    nr <- as.integer(attr(data, "nr")) 
-    nc <- as.integer(attr(data, "nc"))
-    nTips <- as.integer(length(tree$tip.label)) 
-    k <- as.integer(k)
-    m = 1
-    if (is.null(eig)) 
-        eig = edQt(bf = bf, Q = Q)
-    if (is.null(w)) {
-        w = rep(1/k, k)
-        if (inv > 0) 
-            w <- (1 - inv) * w
-        if (wMix > 0) 
-            w <- (1 - wMix) * w           
-    }
-    if (is.null(g)) {
-        g = discrete.gamma(shape, k)
-        if (inv > 0) 
-            g <- g/(1 - inv)
-        g <- g * rate     
-    } 
-#    inv0 <- inv
-    if(any(g<.gEps)){
-        for(i in 1:length(g)){
-            if(g[i]<.gEps){
-                inv <- inv+w[i]
-            }
-        }
-        w <- w[g>.gEps]
-        g <- g[g>.gEps]
-#        kmax <- k
-        k <- length(w)
-    }
-    if (is.null(INV)) 
-        INV <- Matrix(lli(data, tree), sparse=TRUE)
-    if (is.null(ll.0)){ 
-        ll.0 <- numeric(attr(data,"nr"))    
-    }
-    if(inv>0)
-        ll.0 <- as.matrix(INV %*% (bf * inv))              
-    if (wMix > 0)
-        ll.0 <- ll.0 + llMix           
-    
-    node <- tree$edge[, 1]
-    edge <- tree$edge[, 2]
-    root <- as.integer(node[length(node)])     
-    el <- as.double(tree$edge.length)
-    node = as.integer(node - nTips - 1L) #    min(node))
-    edge = as.integer(edge - 1L)
-    
-    contrast = attr(data, "contrast")
-    nco = as.integer(dim(contrast)[1])    
-# dlist=data, nr, nc, weight, k ausserhalb definieren  
-# pmlPart einbeziehen 
-    resll <- .Call("PML3", dlist=data, el, as.double(w), as.double(g), nr, nc, k, eig, as.double(bf), node, edge, nTips, root, nco, contrast, N=as.integer(length(edge))) 
-
-    # sort(INV at i)+1L  
-    ind = which(ll.0>0) # automatic in INV gespeichert
-
-    sca = .Call("rowMax", resll, length(weight), as.integer(k)) + 1   # nr statt length(weight)
-    lll = resll - sca 
-    lll <- exp(lll) 
-    lll <- (lll%*%w)
-    lll[ind] = lll[ind] + exp(log(ll.0[ind])-sca[ind])    
-    siteLik <- lll 
-    siteLik <- log(siteLik) + sca
-    # needs to change
-    if(wMix >0) siteLik <- log(exp(siteLik) * (1-wMix) + llMix )
-    loglik <- sum(weight * siteLik)
-    if(!site) return(loglik)
-    resll = exp(resll) 
-    return(list(loglik=loglik, siteLik=siteLik, resll=resll))         
-}
-
-
-pml.fit4 <- function (tree, data, bf = rep(1/length(levels), length(levels)), 
-                          shape = 1, k = 1, Q = rep(1, length(levels) * (length(levels) - 1)/2), 
-                          levels = attr(data, "levels"), inv = 0, rate = 1, g = NULL, w = NULL, 
-                          eig = NULL, INV = NULL, ll.0 = NULL, llMix = NULL, wMix = 0, ..., site=FALSE) 
-{
-    weight <- as.double(attr(data, "weight"))
-    nr <- as.integer(attr(data, "nr")) 
-    nc <- as.integer(attr(data, "nc"))
-    nTips <- as.integer(length(tree$tip.label)) 
-    k <- as.integer(k)
-    m = 1
-    if (is.null(eig)) 
-        eig = edQt(bf = bf, Q = Q)
-    if (is.null(w)) {
-        w = rep(1/k, k)
-        if (inv > 0) 
-            w <- (1 - inv) * w
-        if (wMix > 0) 
-            w <- (1 - wMix) * w           
+    weight <- as.double(attr(data, "weight"))
+    nr <- as.integer(attr(data, "nr")) 
+    nc <- as.integer(attr(data, "nc"))
+    nTips <- as.integer(length(tree$tip.label)) 
+    k <- as.integer(k)
+    m = 1
+    if (is.null(eig)) 
+        eig = edQt(bf = bf, Q = Q)
+    if (is.null(w)) {
+        w = rep(1/k, k)
+        if (inv > 0) 
+            w <- (1 - inv) * w
+        if (wMix > 0) 
+            w <- (1 - wMix) * w           
     }
     if (is.null(g)) {
         g = discrete.gamma(shape, k)
@@ -3306,7 +2595,7 @@ pml.fit4 <- function (tree, data, bf = rep(1/length(levels), length(levels)),
     
     node <- tree$edge[, 1]
     edge <- tree$edge[, 2]
-    root <- as.integer(node[length(node)])     
+#    root <- as.integer(node[length(node)])     
     el <- as.double(tree$edge.length)
     node = as.integer(node - nTips - 1L) #    min(node))
     edge = as.integer(edge - 1L)
@@ -3315,11 +2604,12 @@ pml.fit4 <- function (tree, data, bf = rep(1/length(levels), length(levels)),
     nco = as.integer(dim(contrast)[1])    
 
     siteLik <- .Call("PML4", dlist=data, el, as.double(w), as.double(g), nr, nc, k, eig, as.double(bf), 
-                     node, edge, nTips, root, nco, contrast, N=as.integer(length(edge))) 
+                     node, edge, nTips, nco, contrast, N=as.integer(length(edge))) 
 # if(inv>0) siteLik[.iind] = log(exp(siteLik[.iind]) + ll.0[.iind]) 
     ind = which(ll.0>0)
 #    if(!is.null(ll.0)) siteLik[.iind] = log(exp(siteLik[.iind]) + ll.0[.iind]) 
     if(!is.null(ll.0)) siteLik[ind] = log(exp(siteLik[ind]) + ll.0[ind]) 
+#   diese 2 zeilen darueber in C, weight, nr, nc, nco, contrast in C struct definieren      
     if(wMix >0) siteLik <- log(exp(siteLik) * (1-wMix) + llMix )
     loglik <- sum(weight * siteLik)
     if(!site) return(loglik)
@@ -3333,6 +2623,7 @@ pml.fit <- function (tree, data, bf = rep(1/length(levels), length(levels)),
                      levels = attr(data, "levels"), inv = 0, rate = 1, g = NULL, w = NULL, 
                      eig = NULL, INV = NULL, ll.0 = NULL, llMix = NULL, wMix = 0, ..., site=FALSE) 
 {
+    Mkv=FALSE
     weight <- as.double(attr(data, "weight"))
     nr <- as.integer(attr(data, "nr")) 
     nc <- as.integer(attr(data, "nc"))
@@ -3372,13 +2663,15 @@ pml.fit <- function (tree, data, bf = rep(1/length(levels), length(levels)),
         ll.0 <- numeric(attr(data,"nr"))    
     }
     if(inv>0)
-        ll.0 <- as.matrix(INV %*% (bf * inv))              
+        ll.0 <- as.matrix(INV %*% (bf * inv))
+    if(Mkv)
+        ll.0 <- as.matrix(INV %*% bf)
     if (wMix > 0)
         ll.0 <- ll.0 + llMix           
     
     node <- tree$edge[, 1]
     edge <- tree$edge[, 2]
-    root <- as.integer(node[length(node)])     
+#    root <- as.integer(node[length(node)])     
     el <- as.double(tree$edge.length)
     node = as.integer(node - nTips - 1L) #    min(node))
     edge = as.integer(edge - 1L)
@@ -3387,7 +2680,7 @@ pml.fit <- function (tree, data, bf = rep(1/length(levels), length(levels)),
     nco = as.integer(dim(contrast)[1])    
     # dlist=data, nr, nc, weight, k ausserhalb definieren  
     # pmlPart einbeziehen 
-    resll <- .Call("PML0", dlist=data, el, as.double(w), as.double(g), nr, nc, k, eig, as.double(bf), node, edge, nTips, root, nco, contrast, N=as.integer(length(edge))) 
+    resll <- .Call("PML0", dlist=data, el, as.double(w), as.double(g), nr, nc, k, eig, as.double(bf), node, edge, nTips, nco, contrast, N=as.integer(length(edge))) 
     
     # sort(INV at i)+1L  
     ind = which(ll.0>0) # automatic in INV gespeichert
@@ -3396,11 +2689,13 @@ pml.fit <- function (tree, data, bf = rep(1/length(levels), length(levels)),
     lll = resll - sca 
     lll <- exp(lll) 
     lll <- (lll%*%w)
+    if(Mkv) p0 <- sum(exp(log(lll[ind]) + sca[ind]))
     lll[ind] = lll[ind] + exp(log(ll.0[ind])-sca[ind])    
     siteLik <- lll 
     siteLik <- log(siteLik) + sca
     # needs to change
     if(wMix >0) siteLik <- log(exp(siteLik) * (1-wMix) + llMix )
+    if(Mkv)siteLik <- siteLik + log(1-p0)
     loglik <- sum(weight * siteLik)
     if(!site) return(loglik)
     resll = exp(resll) 
@@ -3411,6 +2706,7 @@ pml.fit <- function (tree, data, bf = rep(1/length(levels), length(levels)),
 pml <- function (tree, data, bf = NULL, Q = NULL, inv = 0, k = 1, shape = 1, 
     rate = 1, model=NULL, ...) 
 {
+    Mkv = FALSE
     call <- match.call()
     extras <- match.call(expand.dots = FALSE)$...
     pmla <- c("wMix", "llMix") 
@@ -3418,7 +2714,11 @@ pml <- function (tree, data, bf = NULL, Q = NULL, inv = 0, k = 1, shape = 1,
     wMix <- ifelse(is.na(existing[1]), 0, eval(extras[[existing[1]]], parent.frame()) )  
     llMix <- ifelse(is.na(existing[2]), 0, eval(extras[[existing[2]]], parent.frame()) )
   
-    if(class(tree)!="phylo") stop("tree must be of class phylo") 
+    if(!inherits(tree,"phylo")) stop("tree must be of class phylo") 
+#    if(is.null(tree$edge.length)){
+#        warning("tree has no edge length, used nnls.phylo to assign them")
+#        tree <- nnls.phylo(tree, dist.ml(data))
+#    }    
     if (is.null(attr(tree, "order")) || attr(tree, "order") == 
         "cladewise") 
         tree <- reorder(tree, "postorder")
@@ -3428,9 +2728,13 @@ pml <- function (tree, data, bf = NULL, Q = NULL, inv = 0, k = 1, shape = 1,
     }
     if (class(data)[1] != "phyDat") stop("data must be of class phyDat")
     if(is.null(tree$edge.length)) stop("tree must have edge weights") 
-    if(any(is.na(match(tree$tip, attr(data, "names"))))) stop("tip labels are not in data")  
+    if(any(is.na(match(tree$tip.label, attr(data, "names"))))) stop("tip labels are not in data")  
     data <- subset(data, tree$tip.label) # needed
     levels <- attr(data, "levels")
+    if(Mkv){
+        data <- cbind(constSitePattern(length(tree$tip.label),levels, tree$tip.label), data)
+        attr(data, "weight")[1:attr(data, "nc")] <- 0.0
+    }    
     weight <- attr(data, "weight")
     nr <- attr(data, "nr")
     type <- attr(data,"type")
@@ -3438,7 +2742,9 @@ pml <- function (tree, data, bf = NULL, Q = NULL, inv = 0, k = 1, shape = 1,
         model <- match.arg(model, .aamodels)
         getModelAA(model, bf=is.null(bf), Q=is.null(Q)) 
     }  
-    if(type=="CODON") Q <- as.numeric(.syn > 0)
+    if(type=="CODON"){ 
+        Q <- as.numeric(.syn > 0)
+    }
     if (is.null(bf)) 
         bf <- rep(1/length(levels), length(levels))
     if (is.null(Q)) 
@@ -3470,6 +2776,8 @@ pml <- function (tree, data, bf = NULL, Q = NULL, inv = 0, k = 1, shape = 1,
     
     INV <- Matrix(lli(data, tree), sparse=TRUE)
     ll.0 <- as.matrix(INV %*% (bf * inv))
+#    if(Mkv) ll.0 <- as.matrix(INV %*% rep(1, length(bf))) 
+    
     if(wMix>0) ll.0 <- ll.0 + llMix
 
     nr <- as.integer(attr(data, "nr")) 
@@ -3480,17 +2788,27 @@ pml <- function (tree, data, bf = NULL, Q = NULL, inv = 0, k = 1, shape = 1,
     .C("ll_init", nr, nTips, nc, as.integer(k))
     tmp <- pml.fit(tree, data, bf, shape = shape, k = k, Q = Q, 
         levels = attr(data, "levels"), inv = inv, rate = rate, g = g, w = w, 
-        eig = eig, INV = INV, ll.0 = ll.0, llMix = llMix, wMix = wMix, site=TRUE) 
+        eig = eig, INV = INV, ll.0 = ll.0, llMix = llMix, wMix = wMix, site=TRUE)  #, Mkv=Mkv
     
     df <- ifelse(is.ultrametric(tree), tree$Nnode, length(tree$edge.length))
-    if(type=="CODON"){ 
-        df <- df + (kmax>1) + (inv0 > 0) + length(unique(bf)) - 1 
-        }
-    else df = df + (kmax>1) + (inv0 > 0) + length(unique(bf)) - 1 + length(unique(Q)) - 1
+    
+    df <- switch(type, 
+                  DNA =  df + (kmax>1) + (inv0 > 0) + length(unique(bf)) - 1 + length(unique(Q)) - 1, 
+                  AA = df + (kmax>1) + (inv0 > 0) ,
+                  CODON = df + (kmax>1) + (inv0 > 0) + length(unique(bf)) - 1, 
+                  USER = df + (kmax>1) + (inv0 > 0) + length(unique(bf)) - 1 + length(unique(Q)) - 1)
+    
+#    if(type=="AA" & !is.null(model)){ 
+#        df <- df + (kmax>1) + (inv0 > 0) #+ length(unique(bf)) - 1 
+#    }
+#    if(type=="CODON"){ 
+#        df <- df + (kmax>1) + (inv0 > 0) + length(unique(bf)) - 1 
+#        }
+#    else df = df + (kmax>1) + (inv0 > 0) + length(unique(bf)) - 1 + length(unique(Q)) - 1
     result = list(logLik = tmp$loglik, inv = inv, k = kmax, shape = shape,
         Q = Q, bf = bf, rate = rate, siteLik = tmp$siteLik, weight = weight, 
         g = g, w = w, eig = eig, data = data, model=model, INV = INV, 
-        ll.0 = ll.0, tree = tree, lv = tmp$resll, call = call, df=df, wMix=wMix, llMix=llMix)
+        ll.0 = ll.0, tree = tree, lv = tmp$resll, call = call, df=df, wMix=wMix, llMix=llMix) #, Mkv=Mkv
     if(type=="CODON"){
         result$dnds <- 1
         result$tstv <- 1
@@ -3650,24 +2968,6 @@ optimRooted <- function(tree, data, eig=eig, w=w, g=g, bf=bf, rate=rate, ll.0=ll
 }
 
 
-
-# copy node likelihoods from C to R
-getNodeLogLik = function(data, i, j=1L){
-    nr = attr(data, "nr")
-    nc = attr(data, "nc")
-    ntips = length(data)
-    .Call("getLL", as.integer(i), as.integer(j-1L), as.integer(nr), as.integer(nc), as.integer(ntips))
-}
-
-
-# copy scaling parameters from C to R
-getSC = function(data, k=1L){
-    nr = attr(data, "nr")
-    ntips = length(data)
-    .Call("getSCM", as.integer(k),  as.integer(nr), as.integer(ntips))
-}
-
-
 index.nni <- function (ch, cvector, pvector, root) 
 {
     p1 = pvector[ch]
@@ -3984,6 +3284,878 @@ rooted.nni <- function(tree, data, eig, w, g, bf, rate, ll.0, INV,
 }
 
 
+# maybe into treeManipulation
+addAllTips <- function(tree, mapping){
+    tree2 <- tree
+    uni <- unique(mapping[,2])
+    for(i in uni)
+        tree2 = addTips2Tree(tree2, mapping[mapping[,2]==i,1],i)
+    tree2
+}
+
+
+
+addTips2Tree <- function (tree, tips, where){
+    nTips <- length(tree$tip.label)
+    edge = tree$edge
+    
+    where <- match(where, tree$tip.label)
+    
+    ind = match(where, edge[,2])
+    nt <- as.integer(length(tips))
+    edge[edge>nTips] = edge[edge>nTips]+nt
+    m = max(edge)
+    edge[ind,2] <- m+1L    
+    
+    newEdge <- cbind(m+1L,c(where,(nTips+1L):(nTips+nt)))
+    edge <- rbind(newEdge, edge)
+    storage.mode(edge) <- "integer"
+    if(!is.null(tree$edge.length)) tree$edge.length = c(rep(0, nrow(newEdge)), tree$edge.length)
+    tree$edge = edge
+    tree$Nnode = tree$Nnode + 1L
+    tree$tip.label = c(tree$tip.label, tips)
+    attr(tree, "order") <- NULL
+    tree <- reorder(tree, "postorder")
+    tree
+}    
+
+
+optim.pml <- function (object, optNni = FALSE, optBf = FALSE, optQ = FALSE, 
+                        optInv = FALSE, optGamma = FALSE, optEdge = TRUE, optRate = FALSE, optRooted=FALSE,
+                        control = pml.control(epsilon = 1e-8, maxit = 10, trace = 1L), 
+                        model = NULL, rearrangement = ifelse(optNni, "NNI","none"), subs = NULL, ratchet.par = list(iter = 20L, maxit = 100L, prop = 1/3), ...) 
+{
+    optRatchet = FALSE
+    optRatchet2 = FALSE
+    if(rearrangement ==  "none"){
+        optNni = FALSE
+        optRatchet = FALSE
+        optRatchet2 = FALSE
+    }
+    if(rearrangement ==  "NNI")optNni = TRUE
+    if(rearrangement ==  "stochastic") optRatchet = TRUE
+    if(rearrangement ==  "ratchet") optRatchet2 = TRUE
+    extras <- match.call(expand.dots = FALSE)$...
+    pmla <- c("wMix", "llMix")
+    wMix <- object$wMix
+    llMix <- object$llMix
+#    Mkv <- object$Mkv
+    Mkv <- FALSE
+    if(is.null(llMix)) llMix=0
+    if (!is.null(extras)) {
+        names(extras) <- pmla[pmatch(names(extras), pmla)]
+        existing <- match(pmla, names(extras))
+        if (!is.na(existing[1])) 
+            wMix <- eval(extras[[existing[1]]], parent.frame())
+        if (!is.na(existing[2])) 
+            llMix <- eval(extras[[existing[2]]], parent.frame())
+    }
+    tree = object$tree
+    call = object$call
+    ratchet=FALSE
+    ratchet2=FALSE
+    if(optRatchet == TRUE){
+        if(optRooted==FALSE){
+            optNni=TRUE
+            optEdge=TRUE
+            ratchet=TRUE
+        }
+    }
+    if(optRatchet2 == TRUE){
+        optNni=TRUE
+        optEdge=TRUE
+        ratchet2=TRUE
+    }
+    
+    data <- object$data
+    addTaxa <- FALSE
+    
+    if(optNni) {
+        # test this more 
+        dup <-  duplicated(data) # duplicated_phyDat(data)
+        if(any(dup)){ # && optNNI
+            orig.data <- data
+            addTaxa <- TRUE
+            labels <- names(data)
+            ldup <- labels[dup]
+            ind2 <- match(subset(data, dup), data)
+            tree2 <- drop.tip(tree, ldup)
+            tree <- reorder(tree2, "postorder")
+            mapping <- cbind(labels[dup], labels[ind2])
+        }
+        if(!is.binary.tree(tree)) 
+            tree = multi2di(tree)
+        optEdge = TRUE     
+    }
+    if(is.rooted(tree)) {
+        if(optRooted==FALSE && optEdge==TRUE){
+            tree = unroot(tree)
+            attr(tree, "order") <- NULL
+            tree = reorder(tree, "postorder")
+            warning("I unrooted the tree", call. = FALSE)
+        }    
+    }
+    if(is.null(attr(tree, "order")) || attr(tree, "order") == 
+       "cladewise") 
+        tree <- reorder(tree, "postorder")
+    if(any(tree$edge.length < 1e-08)) {
+        tree$edge.length[tree$edge.length < 1e-08] <- 1e-08
+        # save to change to new update.pml       
+        object <- update.pml(object, tree = tree)
+    }
+    if(optEdge & optRate) {
+        warning("You can't optimise edges and rates at the same time, only edges are optimised!", call. = FALSE)
+        optRate = FALSE
+    }
+    if(optRooted){
+        optEdge = FALSE
+        if(!is.rooted(tree)) stop("Tree must be rooted!")
+        if(!is.ultrametric(tree)) stop("Tree must be ultrametric!")
+    }
+    trace <- control$trace
+    
+    data = subset(data, tree$tip.label) 
+    
+    type <- attr(data, "type")
+    if (type == "AA" & !is.null(model)){
+        object = update(object, model=model)  
+    }     
+    if (type == "CODON") {
+        if(is.null(model)) model <- "codon1"
+        model <- match.arg(model, c("codon0", "codon1", "codon2", "codon3", "YN98"))
+        dnds <- object$dnds 
+        tstv <- object$tstv
+        if(!is.null(model)){
+            if(model == "codon0") optQ = FALSE
+            else  optQ = TRUE
+            if(model == "YN98") optBf = TRUE
+        }
+    }       
+    Q = object$Q
+    if(is.null(subs)) subs = c(1:(length(Q) - 1), 0)
+    bf = object$bf
+    eig = object$eig
+    inv = object$inv
+    k = object$k
+    if(k==1 & optGamma){
+        optGamma = FALSE
+        message('only one rate class, ignored optGamma')
+    }
+#    if(Mkv==TRUE & optInv==TRUE){ 
+#        optInv = FALSE
+#        message('cannot estimate invariant sites and Mkv model, ignored optInv')
+#    } 
+    shape = object$shape
+    w = object$w
+    g = object$g
+    if (type == "DNA" & !is.null(model)) {
+        tmp = subsChoice(model)
+        optQ = tmp$optQ
+        if (!optQ) 
+            Q = rep(1, 6)
+        optBf = tmp$optBf
+        if (!optBf) 
+            bf = c(0.25, 0.25, 0.25, 0.25)
+        subs = tmp$subs
+    }   
+    ll0 <- object$logLik
+    INV <- object$INV
+    ll.0 <- object$ll.0
+    rate <- object$rate
+    ll = ll0
+    ll1 = ll0
+    opti = TRUE
+    
+    nr <- as.integer(attr(data, "nr")) 
+    nc <- as.integer(attr(data, "nc"))
+    nTips <- as.integer(length(tree$tip.label))
+    
+    #    on.exit(.C("ll_free"))
+    #    .C("ll_init", nr, nTips, nc, as.integer(k))
+    #    .INV <- .iind <- NULL
+    on.exit({
+
+
+        
+        tmp <- pml.fit(tree, data, bf, shape = shape, k = k, Q = Q, 
+                       levels = attr(data, "levels"), inv = inv, rate = rate, 
+                       g = g, w = w, eig = eig, INV = INV, ll.0 = ll.0, llMix = llMix, 
+                       wMix = wMix, site = TRUE)
+        
+#   df <- ifelse(optRooted, tree$Nnode, length(tree$edge.length))
+#   length(tree$edge.length)    
+#   nTips             
+#   nNodes
+#   uniqueTips
+#   uniqueNodes        
+#   kmax>1        
+#   bf
+#   Q     
+        if(addTaxa){
+            tree <- addAllTips(tree, mapping)
+            data <- orig.data
+        }
+        df <- ifelse(optRooted, tree$Nnode, length(tree$edge.length))
+        df <- switch(type, 
+                      DNA = df + (k>1) + (inv > 0) + length(unique(bf)) - 1 + length(unique(Q)) - 1, 
+                      AA = df + (k>1) + (inv > 0) +  optBf * (length(unique(bf)) - 1),
+                      CODON = df + (k>1) + (inv > 0) + length(unique(bf)) - 1 + (dnds != 1) + (tstv != 1),  
+                      USER = df + (k>1) + (inv > 0) + length(unique(bf)) - 1 + length(unique(Q)) - 1)
+        
+        object = list(logLik = tmp$loglik, inv = inv, k = k, shape = shape, 
+                      Q = Q, bf = bf, rate = rate, siteLik = tmp$siteLik, weight = attr(data, "weight"), 
+                      g = g, w = w, eig = eig, data = data, model = model, 
+                      INV = INV, ll.0 = ll.0, tree = tree, lv = tmp$resll, 
+                      call = call, df = df, wMix = wMix, llMix = llMix)
+        if (type == "CODON") {
+            object$dnds <- dnds
+            object$tstv <- tstv
+        }
+        class(object) = "pml"
+        
+        extras = pairlist(bf = bf, Q = Q, inv = inv, shape = shape, rate = rate)[c(optBf, optQ, optInv, optGamma, optRate)]
+        if (length(extras)) {
+            existing <- !is.na(match(names(extras), names(call)))
+            for (a in names(extras)[existing]) call[[a]] <- extras[[a]]
+            if (any(!existing)) {
+                call <- c(as.list(call), extras[!existing])
+                call <- as.call(call)
+            }
+        }
+        object$call = call   
+        
+        pml.free()
+        return(object)
+    })
+    pml.init(data, k)    
+    
+    if (optEdge) {
+        
+        # check if non-negative least-squares is better for start of optimisation
+        treetmp <- nnls.phylo(tree, dist.ml(data))
+        treetmp$edge.length[treetmp$edge.length < 1e-8] <- 1e-8
+        tmplogLik <- pml.fit(treetmp, data, bf, k = k, inv = inv, g = g, w = w, 
+            eig = eig, INV = INV, ll.0 = ll.0, llMix = llMix, wMix = wMix)
+        if(tmplogLik>ll) tree <- treetmp
+        
+        res <- optimEdge(tree, data, eig=eig, w=w, g=g, bf=bf, rate=rate, ll.0=ll.0, INV=INV,
+                         control = pml.control(epsilon = 1e-07, maxit = 5, trace=trace - 1)) 
+        if(trace > 0) 
+            cat("optimize edge weights: ", ll, "-->", res[[2]], "\n")  
+        if (res[[2]] > ll){  
+            ll <- res[[2]]
+            tree <- res[[1]]
+        }
+    }
+    if(optRooted){
+        res <- optimRooted(tree, data, eig=eig, w=w, g=g, bf=bf, rate=rate, ll.0=ll.0, INV=INV, control = pml.control(epsilon = 1e-07, maxit = 10, trace = trace-1))
+        if(trace > 0) 
+            cat("optimize edge weights: ", ll, "-->", res[[2]], "\n")
+        if(res[[2]] > ll){  
+            ll <- res[[2]]
+            tree <- res[[1]]
+        }     
+    }
+    rounds = 1
+    while (opti) {
+        if (optBf) {
+            res = optimBf(tree, data, bf = bf, inv = inv, Q = Q, 
+                          w = w, g = g, INV = INV, rate = rate, k = k, 
+                          llMix = llMix)
+            bf = res[[1]]
+            eig = edQt(Q = Q, bf = bf)
+            if (inv > 0) 
+                ll.0 <- as.matrix(INV %*% (bf * inv))
+            if (wMix > 0) 
+                ll.0 <- ll.0 + llMix
+            if (trace > 0) 
+                cat("optimize base frequencies: ", ll, "-->", 
+                    res[[2]], "\n")
+            ll = res[[2]]
+        }
+        if (optQ) {
+            if(type=="CODON"){
+#                if(is.null(model)) model <- "codon1"
+#                model <- match.arg(model, c("codon0", "codon1", "codon2", "codon3", "YN98"))
+                ab <- c(tstv, dnds)
+                res <- switch(model, 
+                              YN98 = optimCodon(tree,data, Q=rep(1,1830), subs=.sub, syn=.syn, 
+                                                  bf = bf, w = w, g = g, inv = inv, INV = INV, ll.0 = ll.0, rate = rate, k = k, ab=log(ab),
+                                                  optK=TRUE, optW = TRUE),                              
+                              codon1 = optimCodon(tree,data, Q=rep(1,1830), subs=.sub, syn=.syn, 
+                                                  bf = bf, w = w, g = g, inv = inv, INV = INV, ll.0 = ll.0, rate = rate, k = k, ab=log(ab),
+                                                  optK=TRUE, optW = TRUE),  
+                              codon2 = optimCodon(tree,data, Q=rep(1,1830), subs=.sub, syn=.syn, 
+                                                  bf = bf, w = w, g = g, inv = inv, INV = INV, ll.0 = ll.0, rate = rate, k = k, ab=log(ab), 
+                                                  optK=FALSE, optW = TRUE),
+                              codon3 = optimCodon(tree,data, Q=rep(1,1830), subs=.sub, syn=.syn, 
+                                                  bf = bf, w = w, g = g, inv = inv, INV = INV, ll.0 = ll.0, rate = rate, k = k, ab=log(ab),
+                                                  optK=TRUE, optW = FALSE))
+                tmp <- res[[5]]
+                m = length(tmp)
+                dnds = tmp[m]
+                
+                if(m>1) tstv <- tmp[1]
+            }
+            else
+                res = optimQ(tree, data, Q = Q, subs = subs, bf = bf, w = w, g = g, inv = inv, INV = INV, 
+                             ll.0 = ll.0, rate = rate, k = k)
+            Q = res[[1]]
+            eig = edQt(Q = Q, bf = bf)
+            if (trace > 0) 
+                cat("optimize rate matrix: ", ll, "-->", res[[2]], 
+                    "\n")
+            ll = res[[2]]
+        }
+        if(optInv) {
+            res = optimInv(tree, data, inv = inv, INV = INV, Q = Q, 
+                           bf = bf, eig = eig, k = k, shape = shape, rate = rate)
+            inv = res[[1]]
+            w = rep(1/k, k)
+            g = discrete.gamma(shape, k)
+            w = (1 - inv) * w
+            if (wMix > 0) 
+                w <- (1 - wMix) * w
+            g = g/(1 - inv)
+            g <- g * rate
+            ll.0 = as.matrix(INV %*% (bf * inv))
+            if (wMix > 0) 
+                ll.0 <- ll.0 + llMix
+            if (trace > 0) 
+                cat("optimize invariant sites: ", ll, "-->", res[[2]], "\n")
+            ll = res[[2]]
+        }
+        if(optGamma) {
+            res = optimGamma(tree, data, shape = shape, k = k, 
+                             inv = inv, INV = INV, Q = Q, bf = bf, eig = eig, 
+                             ll.0 = ll.0, rate = rate)
+            shape = res[[1]]
+            w = rep(1/k, k)
+            g = discrete.gamma(shape, k)
+            if (inv > 0) {
+                w = (1 - inv) * w
+                g = g/(1 - inv)
+            }
+            if (wMix > 0) 
+                w <- (1 - wMix) * w
+            g <- g * rate
+            if (trace > 0) 
+                cat("optimize shape parameter: ", ll, "-->", 
+                    res[[2]], "\n")
+            ll = res[[2]]
+        }
+        if(optRate) {
+            res = optimRate(tree, data, rate = rate, inv = inv, 
+                            INV = INV, Q = Q, bf = bf, eig = eig, k = k, 
+                            shape = shape, w = w, ll.0 = ll.0)
+            if (res[[2]] > ll)rate = res[[1]]
+            g = discrete.gamma(shape, k)
+            w = rep(1/k, k)
+            if (inv > 0) {
+                w = (1 - inv) * w
+                g = g/(1 - inv)
+            }
+            if (wMix > 0) 
+                w <- (1 - wMix) * w
+            g <- g * rate
+            if (trace > 0) 
+                cat("optimize rate: ", ll, "-->", res[[2]], "\n")
+            ll = res[[2]]
+        }
+        if (optEdge) {  
+            res <- optimEdge(tree, data, eig=eig, w=w, g=g, bf=bf, rate=rate, ll.0=ll.0,
+                             control = pml.control(epsilon = 1e-08, maxit = 5, trace=trace - 1)) 
+            if (trace > 0) 
+                cat("optimize edge weights: ", ll, "-->", res[[2]], "\n")
+            if (res[[2]] > ll){  
+                ll <- res[[2]]
+                tree <- res[[1]]
+            }
+        }
+        if(optRooted){
+            res <- optimRooted(tree, data, eig=eig, w=w, g=g, bf=bf, rate=rate, ll.0=ll.0, INV=INV, control = pml.control(epsilon = 1e-07, maxit = 10, trace = trace-1))
+            if(trace > 0) 
+                cat("optimize edge weights: ", ll, "-->", res[[2]], "\n")
+            if (res[[2]] > ll){  
+                ll <- res[[2]]
+                tree <- res[[1]]
+            }     
+        }
+        if(optNni) {
+            swap = 0
+            iter = 1
+            while (iter < 4) {
+                if(optEdge){
+#                    tmp <- pml.nni.old(tree, data, w, g, eig, bf, ll.0, ll, ...) 
+                    tmp <- pml.nni(tree, data, w=w, g=g, eig=eig, bf=bf, ll.0=ll.0, ll=ll, INV=INV, ...)
+                    swap = swap + tmp$swap
+                    res <- optimEdge(tmp$tree, data, eig=eig, w=w, g=g, bf=bf, rate=rate, ll.0=ll.0, control = pml.control(epsilon = 1e-08, maxit = 3, trace=0)) 
+                    ll2 = res[[2]] 
+                    tree <- res[[1]]
+                }
+                else{ 
+                    tmp <- rooted.nni(tree, data, eig=eig, w=w, g=g, bf=bf, rate=rate, ll.0=ll.0, INV=INV, ...) 
+                    swap = swap + tmp$swap
+                    res <- optimRooted(tmp$tree, data, eig=eig, w=w, g=g, bf=bf, rate=rate, ll.0=ll.0, INV=INV, control = pml.control(epsilon = 1e-08, maxit = 5, trace = trace-1))
+                    tree <- tmp$tree
+                    ll2 = tmp$logLik
+                }
+                if (trace > 0) 
+                    cat("optimize topology: ", ll, "-->", ll2, "\n")
+                ll = ll2
+                iter = iter + 1
+                if (tmp$swap == 0) {
+                    iter = 4
+                }
+            }
+            if (trace > 0) 
+                cat(swap, "\n")
+            if (swap > 0) 
+                rounds = 1
+            if (swap == 0) 
+                optNni = FALSE
+        }
+        epsR <- 1e-8
+        if( (ratchet==TRUE) && (optNni == FALSE) ){
+            maxR = ratchet.par$iter
+            maxit = ratchet.par$maxit
+            kmax=1
+            i=1
+            while(i < maxit){
+                
+                tree2<- rNNI(tree, moves=round(nTips * ratchet.par$prop), n=1)
+                #tree <- rSPR(tree, moves=10, k=3, n=1)
+                swap = 1
+                ll2 <- pml.fit(tree2, data, bf, shape = shape, k = k, Q = Q, 
+                               levels = attr(data, "levels"), inv = inv, rate = rate, 
+                               g = g, w = w, eig = eig, INV = INV, ll.0 = ll.0, llMix = llMix, 
+                               wMix = wMix, site = FALSE)
+                
+                while(swap>0){
+#                    tmp <- pml.nni(tree2, data, w, g, eig, bf, ll.0, ll=ll2, ...) 
+                    tmp <- pml.nni(tree2, data, w=w, g=g, eig=eig, bf=bf, ll.0=ll.0, ll=ll2, INV=INV, ...)
+                    swap = tmp$swap
+                    res <- optimEdge(tmp$tree, data, eig=eig, w=w, g=g, bf=bf, rate=rate, ll.0=ll.0, control = pml.control(epsilon = 1e-08, maxit = 3, trace=0))
+                    if (trace > 1) 
+                        cat("optimize topology: ", ll2, "-->", res[[2]], "\n", "swaps:", tmp$swap, "\n")
+                    ll2 = res[[2]] 
+                    tree2 <- res[[1]]
+                }
+                
+                if(ll2 > (ll + epsR)){
+                    tree <- tree2
+                    ll <- ll2
+                    kmax=1
+                } 
+                else kmax = kmax+1
+                if(trace > 0) print(paste("Ratchet iteration ", i,", best pscore so far:",ll))
+                i=i+1
+                if(kmax > maxR) i <- maxit
+            }  
+            optNni = TRUE
+            ratchet=FALSE
+            rounds = 1
+        }
+        
+        if( (ratchet2==TRUE) && (optNni == FALSE) ){
+            if(optRooted){
+                FUN <- function(x, bf, Q, k, shape){
+                dm <- dist.ml(x, bf=bf, Q=Q, k=k, shape=shape)
+                tr <- wpgma(dm)
+                #                nnls.phylo(tr, dm, TRUE)
+                tr
+                }
+            }
+            else{
+                FUN <- function(x, bf, Q, k, shape){
+                dm <- dist.ml(x, bf=bf, Q=Q)
+                tr <- fastme.bal(dm, TRUE, FALSE, FALSE)
+                tr$edge.length[tr$edge.length < 1e-8] = 1e-8
+                tr #nnls.phylo(tr, dm)
+                }
+            }
+            maxR = ratchet.par$iter
+            maxit = ratchet.par$maxit
+            kmax=1
+            i=1
+            while(i < maxit){
+                tree2 <- bootstrap.phyDat(data, FUN, bs = 1, bf=bf, Q=Q, k=k, shape=shape)[[1]]
+                tree2 <- checkLabels(tree2, tree$tip.label)
+                tree2 <- reorder(tree2, "postorder")
+                swap = 1
+#                ll2 <- pml.fit(tree, data, bf, shape = shape, k = k, Q = Q, 
+#                               levels = attr(data, "levels"), inv = inv, rate = rate, 
+#                               g = g, w = w, eig = eig, INV = INV, ll.0 = ll.0, llMix = llMix, 
+#                               wMix = wMix, site = FALSE)
+#print(ll2)                
+                ll2 <- pml.fit(tree2, data, bf, shape = shape, k = k, Q = Q, 
+                               levels = attr(data, "levels"), inv = inv, rate = rate, 
+                               g = g, w = w, eig = eig, INV = INV, ll.0 = ll.0, llMix = llMix, 
+                               wMix = wMix, site = FALSE)
+#print(ll2)                 
+                while(swap>0){
+#                    tmp <- pml.nni(tree2, data, w, g, eig, bf, ll.0, ll=ll2, ...) 
+                    tmp <- pml.nni(tree2, data, w=w, g=g, eig=eig, bf=bf, ll.0=ll.0, ll=ll2, INV=INV, ...)
+                    swap = tmp$swap
+                    res <- optimEdge(tmp$tree, data, eig=eig, w=w, g=g, bf=bf, rate=rate, ll.0=ll.0, control = pml.control(epsilon = 1e-08, maxit = 3, trace=0)) 
+                    if (trace > 1) 
+                        cat("optimize topology: ", ll2, "-->", res[[2]], "\n", "swaps:", tmp$swap, "\n")
+                    ll2 = res[[2]] 
+                    tree2 <- res[[1]]
+                }
+                if(ll2 > (ll + epsR)){
+                    tree <- tree2
+                    ll <- ll2
+                    kmax=1
+                } 
+                else kmax = kmax+1
+                if(trace > 0) print(paste("Ratchet iteration ", i,", best pscore so far:",ll))
+                i=i+1
+                if(kmax > maxR) i <- maxit
+            }  
+            optNni = TRUE
+            ratchet2=FALSE
+            rounds = 1
+        }
+        
+        if(rounds > control$maxit) opti <- FALSE
+        if ((( ll1 - ll ) / ll  < control$eps ) && rounds > 2 ) #abs(ll1 - ll)
+            opti <- FALSE
+        rounds = rounds + 1
+        ll1 = ll
+    }  
+}
+
+
+#########################################################################################
+#
+# experimental pml.nni 
+#
+#########################################################################################
+indexNNI3 <- function(tree){
+    parent = tree$edge[, 1]
+    child = tree$edge[, 2]
+    ind = reorder(tree)$edge[,2]
+    nTips <- length(tree$tip.label)
+    ind = ind[ind>nTips]
+    #    ind = which(child %in% parent)
+    Nnode = tree$Nnode
+    #     a         d
+    #      \       /
+    #       e-----f       c is closest to root, f is root from subtree
+    #      /       \  
+    #     b         c     c(a,b,c,d,e,f)     
+    edgeMatrix = matrix(0,(Nnode-1), 6)
+    
+    pvector <- numeric(max(parent))
+    pvector[child] <- parent
+    tips  <- !logical(max(parent))
+    tips[parent] <-  FALSE
+    #    cvector <- allCildren(tree)  
+    cvector <- vector("list",max(parent))   
+    for(i in 1:length(parent))  cvector[[parent[i]]] <- c(cvector[[parent[i]]], child[i]) 
+    k=1L
+    for(i in ind){   
+        f = pvector[i] #f
+        ab = cvector[[i]] #a,b
+        ind1 = cvector[[f]] #c,d
+        cd = ind1[ind1 != i]
+        if(pvector[f])cd=c(pvector[f], cd) # cd  
+        edgeMatrix[k, 1:6] = c(ab,cd,i,f)
+        k=k+1L
+    } 
+    edgeMatrix
+}
+
+# EL ausserhalb
+index2tree <- function(x, tree, root=length(tree$tip.label)+1L){
+    EL = numeric(max(tree$edge))
+    EL[tree$edge[,2]] = tree$edge.length  #edgeLengthIndex()
+    pa = c(5L,5L,6L,6L,6L)
+    ch = c(1L,2L,5L,4L,3L)
+    elind = c(1L,2L,5L,4L,6L)                # raus 
+    if(x[6L]==root) el = EL[x[ch]]        #1 Zeile raus
+    else   el = EL[x[elind]]              #edgeLengthIndex()
+#    structure(list(edge = structure(c(x[pa], x[ch]), .Dim = c(5L, 2L)), 
+#        tip.label = tree$tip.label, edge.length = el, Nnode = 2L), 
+#       .Names = c("edge", "tip.label", "edge.length", "Nnode"), class = "phylo", order = "postorder")
+    structure(list(edge = structure(c(x[pa], x[ch]), .Dim = c(5L, 2L)), 
+        edge.length = el, Nnode = 2L), 
+        .Names = c("edge", "edge.length", "Nnode"), class = "phylo", order = "postorder")
+}
+
+
+index2tree2 <- function(x, tree, root=length(tree$tip.label)+1L){
+    EL = numeric(max(tree$edge))
+    EL[tree$edge[,2]] = tree$edge.length
+    pa = c(6L,6L,5L,5L,5L)
+    ch = c(3L,4L,6L,1L,2L)
+    elr = c(3L,4L,5L,1L,2L)
+    eln = c(6L,4L,5L,1L,2L)
+    if(x[6L]==root) el = EL[x[elr]]
+    else   el = EL[x[eln]]  
+    structure(list(edge = structure(c(x[pa], x[ch]), .Dim = c(5L, 2L)), 
+            edge.length = el, Nnode = 2L), 
+            .Names = c("edge", "edge.length", "Nnode"), class = "phylo", order = "postorder")
+}
+
+
+# weight, nr, nc, contrast, nco (Reihenfolge beibehalten)      
+# INV raus
+optimQuartet <- function (tree, data, eig, w, g, bf, rate, ll.0=ll.0, nTips,
+        weight, nr, nc, contrast, nco, llcomp =-Inf,                  
+        control = pml.control(epsilon = 1e-08, maxit = 5, trace=0), ...) 
+{
+#    if (is.null(attr(tree, "order")) || attr(tree, "order") == "cladewise") {
+#        tree <- reorder(tree, "postorder") 
+#     print("reorder")   
+#    }    
+#    nTips <- length(tree$tip.label)
+    el <- tree$edge.length
+    tree$edge.length[el < 1e-08] <- 1e-08
+    oldtree = tree
+    k = length(w)    
+    loglik = pml.quartet(tree, data, bf=bf, g=g, w=w, eig=eig, ll.0=ll.0, k=k, nTips=nTips,
+        weight=weight, nr=nr, nc=nc, contrast=contrast, nco=nco)
+    start.ll <- old.ll <- new.ll <- loglik 
+#    contrast <- attr(data, "contrast")
+    contrast2 <- contrast %*% eig[[2]] 
+    evi = (t(eig[[3]]) * bf)
+#    weight <- attr(data, "weight")
+    eps = 1
+    iter = 0
+    
+    treeP = tree
+    
+    child = tree$edge[, 2]
+    parent = tree$edge[, 1]
+    m <- max(tree$edge)
+
+    EL = tree$edge.length  
+    n = length(tree$edge.length)  
+    
+    ind.inv <- which(ll.0>0)
+
+#    nr = as.integer(length(weight))
+#    nc = as.integer(length(bf))
+#    nco = as.integer(nrow(contrast))
+    eve = eig[[2]]
+    lg = k
+    rootNode = getRoot(tree)  # raus       
+    ScaleEPS = 1.0/4294967296.0
+    #    anc = Ancestors(tree, 1:m, "parent")  
+    #    anc0 = as.integer(c(0L, anc))
+    
+    while (eps > control$eps && iter < control$maxit) {
+        EL <- .Call("optQrtt", as.integer(parent), as.integer(child), 
+                    eig, evi, EL, w, g, as.integer(nr), as.integer(nc), 
+                    as.integer(nTips), as.double(contrast), 
+                    as.double(contrast2), nco, data, as.double(weight), as.double(ll.0))       
+        iter = iter + 1
+        #        tree$edge.length = EL[tree$edge[,2]]
+        treeP$edge.length = EL  # [treeP$edge[,2]]
+        newll <- pml.quartet(treeP, data, bf=bf, g=g, w=w, eig=eig, ll.0=ll.0, k=k, nTips=nTips,
+            weight=weight, nr=nr, nc=nc, contrast=contrast, nco=nco)
+        eps = ( old.ll - newll ) / newll
+        if( (eps<0) || (newll < llcomp) ) return(list(tree=oldtree, logLik=old.ll, c(eps, iter)))
+        
+        oldtree = treeP
+        if(control$trace>1) cat(old.ll, " -> ", newll, "\n") 
+        old.ll = newll
+        #        loli = parent[1] 
+    }
+    if(control$trace>0) cat(start.ll, " -> ", newll, "\n")
+    list(tree=treeP, logLik=newll, c(eps, iter))
+}
+
+
+# weight, nr, nc, contrast, nco rein
+# inv, INV raus
+pml.quartet <- function (tree, data, bf = rep(.25, 4), k = 1, rate = 1, g, w, 
+    eig, ll.0 = NULL, ind.ll0=NULL, llMix = NULL, wMix = 0, nTips, 
+    weight, nr, nc, contrast, nco, ..., site=FALSE) 
+{
+#    k <- as.integer(k)
+#    m = 1
+
+#    if(any(g<.gEps)){
+#        for(i in 1:length(g)){
+#            if(g[i]<.gEps){
+#                inv <- inv+w[i]
+#            }
+#        }
+#        w <- w[g>.gEps]
+#        g <- g[g>.gEps]
+#        k <- length(w)
+#    }
+#    if (is.null(INV)) 
+#        INV <- Matrix(lli(data, tree), sparse=TRUE)
+    
+# in C    
+    if (is.null(ll.0)){ 
+        ll.0 <- numeric(nr)    
+    }
+    if(is.null(ind.ll0)){
+        ind = which(ll.0>0)  
+    }
+    else ind = ind.ll0
+#    if(inv>0)
+#        ll.0 <- as.matrix(INV %*% (bf * inv))              
+#    if (wMix > 0)
+#        ll.0 <- ll.0 + llMix           
+    
+#    node <- tree$edge[, 1]
+#    edge <- tree$edge[, 2]
+#    root <- as.integer(node[length(node)])     
+#    el <- as.double(tree$edge.length)
+    node = as.integer(tree$edge[, 1] - nTips - 1L) #    min(node))
+    edge = as.integer(tree$edge[, 2] - 1L)
+    
+#    contrast = attr(data, "contrast")
+#    nco = as.integer(dim(contrast)[1])    
+#    dlist=data, nr, nc, weight, k ausserhalb definieren  
+#    pmlPart einbeziehen 
+    siteLik <- .Call("PML4", dlist=data, as.double(tree$edge.length), as.double(w), 
+                     as.double(g), nr, nc, as.integer(k), eig, as.double(bf), 
+                     node, edge, nTips, nco, contrast, N=as.integer(length(edge))) 
+    
+# in C    
+    if(!is.null(ll.0)){
+#        ind = which(ll.0>0)                                    
+        siteLik[ind] = log(exp(siteLik[ind]) + ll.0[ind])       
+    }    
+    if(wMix >0) siteLik <- log(exp(siteLik) * (1-wMix) + llMix ) 
+    loglik <- sum(weight * siteLik)                              
+    return(loglik)
+}
+
+
+index2edge <- function(x, root){
+    ch = c(1L,2L,5L,4L,3L)
+    elind = c(1L,2L,5L,4L,6L)                
+    if(x[6L]==root) el = x[ch]        
+    else   el = x[elind]              
+    el
+}
+
+
+pml.nni <- function (tree, data, w, g, eig, bf, ll.0, ll, INV=INV, ...) 
+{        
+    k = length(w)
+    INDEX <-  indexNNI3(tree)
+
+    tmpl <- pml.fit4(tree, data, bf=bf, g=g, w=w, eig=eig, INV=INV, ll.0=ll.0, k=k, ...)
+
+#    parent = tree$edge[,1]
+#    child = tree$edge[,2]
+    
+    nr <- as.integer(attr(data, "nr"))
+    nc <- as.integer(attr(data, "nc"))
+    weight = as.numeric(attr(data, "weight"))
+    contrast <- attr(data, "contrast")
+    nco = as.integer(dim(contrast)[1])
+    contrast2 <- contrast %*% eig[[2]] 
+    evi = (t(eig[[3]]) * bf)
+    nTips = as.integer(length(tree$tip.label))
+    
+    
+    #    EL <- numeric(max(parent)) 
+    #    EL[child] <- tree$edge.length
+    m <- dim(INDEX)[1]
+    loglik = numeric(2*m)
+    edgeMatrix <- matrix(0, 2*m, 5)
+    
+    anc <- Ancestors(tree, 1:max(tree$edge), "parent")  
+    loli <- getRoot(tree)
+    
+    ind1 <- c(1,4,3,2,5) # 
+    ind2 <- c(4,2,3,1,5) #  
+ 
+    for(i in 1:m){
+        ei = INDEX[i,]
+        #        el0 = evector[INDEX[i,]]
+        tree0 = index2tree(INDEX[i, ], tree, nTips+1L)
+        ch = ei[5]
+        pa = ei[6]
+        
+        # move up
+        while(pa != loli){
+            tmpr = match(loli, INDEX[,5])
+            treetmp = index2tree(INDEX[tmpr, ], tree, nTips+1L)
+            tmpl <- pml.quartet(treetmp, data, bf=bf, g=g, w=w, eig=eig, ll.0=ll.0, k=k, nTips=nTips, 
+                weight=weight, nr=nr, nc=nc, contrast=contrast, nco=nco)
+            loli = anc[loli]
+        }
+        llt0 <- pml.quartet(tree0, data, bf=bf, g=g, w=w, eig=eig, ll.0=ll.0, k=k, nTips=nTips, 
+                            weight=weight, nr=nr, nc=nc, contrast=contrast, nco=nco)
+#        new0 <- optimQuartet(tree0, data, eig=eig, w=w, g=g, bf=bf, rate=rate, ll.0=ll.0, nTips=nTips, 
+#                weight=weight, nr=nr, nc=nc, contrast=contrast, nco=nco, 
+#                control = list(epsilon = 1e-08, maxit = 3, trace=0))
+        tree2 <- tree1 <- tree0
+        tree1$edge[,2] <- tree1$edge[ind1,2]
+        tree1$edge.length <- tree1$edge.length[ind1]
+        tree2$edge[,2] <- tree2$edge[ind2,2]
+        tree2$edge.length <- tree2$edge.length[ind2]
+        
+        new1 <- optimQuartet(tree1, data, eig=eig, w=w, g=g, bf=bf, ll.0=ll.0, nTips=nTips, 
+            weight=weight, nr=nr, nc=nc, contrast=contrast, nco=nco, llcomp = ll+1e-8, ...) # new0$logLik+1e-8)
+        new2 <- optimQuartet(tree2, data, eig=eig, w=w, g=g, bf=bf, ll.0=ll.0, nTips=nTips, 
+            weight=weight, nr=nr, nc=nc, contrast=contrast, nco=nco, llcomp = ll+1e-8, ...) #new0$logLik+1e-8)
+        loglik[(2*i)-1]=new1$logLik
+        loglik[(2*i)]=new2$logLik 
+        edgeMatrix[(2*i)-1,]=new1$tree$edge.length
+        edgeMatrix[(2*i),]=new2$tree$edge.length      
+        
+        # godown or recompute           
+        if(any (INDEX[i, c(1,2)]>nTips )) {
+            tree00 <- index2tree2(INDEX[i, ], tree, nTips+1L)     
+            tmp3 <- pml.quartet(tree00, data, bf=bf, g=g, w=w, eig=eig, ll.0=ll.0, k=k, nTips=nTips,
+                weight=weight, nr=nr, nc=nc, contrast=contrast, nco=nco)
+            loli <- getRoot(tree00)
+        }   
+        else tmp3 <- pml.quartet(tree0, data, bf=bf, g=g, w=w, eig=eig, ll.0=ll.0, k=k, nTips=nTips,
+            weight=weight, nr=nr, nc=nc, contrast=contrast, nco=nco)             
+        
+    }
+    swap <- 0
+    eps0 <- 1e-6
+    candidates <- loglik > ll + eps0
+#    cat("candidates", sum(candidates), "\n")
+    INDEX2 <- t(apply(INDEX, 1, index2edge, root=getRoot(tree)))
+    while(any(candidates)){     
+        ind = which.max(loglik)
+        loglik[ind]=-Inf
+        if( ind %% 2 ) swap.edge = c(2,4)
+        else swap.edge = c(1,4)
+        
+        IND <- index2edge(INDEX[(ind+1) %/% 2,],nTips+1L)
+        treeT <- changeEdge(tree, IND[swap.edge], IND, edgeMatrix[ind,]) 
+        test <- pml.fit4(treeT, data, bf = bf, k=k, g=g, w=w, eig=eig, ll.0=ll.0, INV=INV, ...) 
+
+        if(test <= ll + eps0) candidates[ind] = FALSE
+        if(test > ll + eps0) {
+            ll = test 
+            swap=swap+1
+            tree <- treeT
+            indi <- which(rep(colSums(apply(INDEX,1,match,INDEX[(ind+1)%/%2,],nomatch=0))>0,each=2))
+            candidates[indi] <- FALSE
+            loglik[indi] <- -Inf
+        }
+    }    
+        #    trees <- vector("list", 2*m)
+        #    for(i in 1:length(loglik)){     
+        #        ind = i
+        #        if( ind %% 2 ) swap.edge = c(2,4)
+        #        else swap.edge = c(1,4)
+        #        IND = index2edge(INDEX[(ind+1)%/%2,])
+        #        tree2 <- try( changeEdge(tree, IND[swap.edge], IND, edgeMatrix[ind,]) )
+        #        trees[[i]] <- tree2
+        #    }
+        #    class(trees) <- "multiPhylo"
+        #    trees <- .compressTipLabel(trees) 
+        # , all=loglik
+    list(tree=tree, loglik=ll, swap=swap, candidates = candidates)
+}
 
 
 
diff --git a/R/sankoff.R b/R/sankoff.R
index 2a8c991..53baec7 100644
--- a/R/sankoff.R
+++ b/R/sankoff.R
@@ -9,7 +9,7 @@ prepareDataSankoffNew <- function(data){
 
 sankoffNew <- function (tree, data, cost = NULL, site = 'pscore') 
 {
-    if (class(data) != "phyDat") 
+    if (!inherits(data,"phyDat")) 
         stop("data must be of class phyDat")
     data <- prepareDataSankoffNew(data)
     weight <- attr(data, "weight")
@@ -31,8 +31,8 @@ sankoffNew <- function (tree, data, cost = NULL, site = 'pscore')
 
 #    for (i in 1:length(data)) storage.mode(data[[i]]) = "double"
 
-    if(class(tree)=="phylo") return(fit.sankoffNew(tree, data, cost, returnData =site))
-    if(class(tree)=="multiPhylo"){
+    if(inherits(tree,"phylo")) return(fit.sankoffNew(tree, data, cost, returnData =site))
+    if(inherits(tree,"multiPhylo")){
 	    if(is.null(tree$TipLabel))tree = unclass(tree)
 	    return(sapply(tree, fit.sankoffNew, data, cost, site))
     }    
@@ -59,9 +59,9 @@ fit.sankoffNew <- function (tree, data, cost, returnData = c("pscore", "site", "
     dat[1:q] = data[tree$tip.label]
     node = as.integer(node - 1)
     edge = as.integer(edge - 1)
-    nTips = as.integer(length(tree$tip))
+    nTips = as.integer(length(tree$tip.label))
     mNodes = as.integer(max(node) + 1)
-#    tips = as.integer((1:length(tree$tip))-1)
+#    tips = as.integer((1:length(tree$tip.label))-1)
     res <- .Call("sankoff3B", dat, as.numeric(cost), as.integer(nr),as.integer(nc), 
          node, edge, mNodes, nTips, as.double(contr), as.integer(nrow(contr)), PACKAGE="phangorn")  
     root <- getRoot(tree) 
diff --git a/R/simSeq.R b/R/simSeq.R
index 8305556..3eff2e1 100644
--- a/R/simSeq.R
+++ b/R/simSeq.R
@@ -52,13 +52,13 @@ simSeq.phylo = function(x, l=1000, Q=NULL, bf=NULL, rootseq=NULL, type = "DNA",
             res[ind,to] = sample(levels, sum(ind), replace=TRUE, prob=P[,j])
         }
     }
-    k = length(x$tip)
-    label = c(x$tip, as.character((k+1):nNodes))
+    k = length(x$tip.label)
+    label = c(x$tip.label, as.character((k+1):nNodes))
     colnames(res)=label 
-    if(!ancestral)res = res[, x$tip, drop=FALSE]
-    if(pt=="DNA") return(phyDat.DNA(as.data.frame(res), return.index=TRUE))
-    if(pt=="AA") return(phyDat.AA(as.data.frame(res), return.index=TRUE))
-    if(pt=="USER") return(phyDat.default(as.data.frame(res), levels = levels, return.index=TRUE))
+    if(!ancestral)res = res[, x$tip.label, drop=FALSE]
+    if(pt=="DNA") return(phyDat.DNA(as.data.frame(res, stringsAsFactors = FALSE), return.index=TRUE))
+    if(pt=="AA") return(phyDat.AA(as.data.frame(res, stringsAsFactors = FALSE), return.index=TRUE))
+    if(pt=="USER") return(phyDat.default(as.data.frame(res, stringsAsFactors = FALSE), levels = levels, return.index=TRUE))
 }        
 
 
diff --git a/R/treeManipulation.R b/R/treeManipulation.R
index d9d21ef..8f4e9f2 100644
--- a/R/treeManipulation.R
+++ b/R/treeManipulation.R
@@ -2,17 +2,6 @@
 # tree manipulation
 # 
 
-# from coalescenMCMC
-getIndexEdge <- function(tip, edge)
-    ## 'integer(1)' mustn't be substituted by '0L' except if 'DUP = TRUE':
-    .C("get_single_index_integer", as.integer(edge[, 2L]),
-       as.integer(tip), integer(1L), PACKAGE = "phangorn",
-       NAOK = TRUE)[[3L]]
-
-getIndexEdge2 <- function(node, edge)
-    .C("get_two_index_integer", as.integer(edge[, 1L]),
-       as.integer(node), integer(2L), PACKAGE = "phangorn",
-       NAOK = TRUE)[[3L]]
 
 # no checks for postorder
 getRoot <- function (tree) 
@@ -81,7 +70,7 @@ changeEdgeLength = function (tree, edge, edge.length)
 
 
 # O(n) statt O(n^2) Speicher und Geschwindigkeit
-midpoint <- function(tree){
+midpoint <- function(tree, node.labels = "support"){
 # distance from node to root
 node2root <- function(x){
     x = reorder(x, "postorder")
@@ -98,11 +87,13 @@ node2root <- function(x){
 }
     oldtree <- tree
     tree = unroot(tree)   
-    nTips = length(tree$tip)
+    nTips = length(tree$tip.label)
     maxD1 = node2root(tree)[1:nTips] 
     ind = which.max(maxD1)
     tmproot = Ancestors(tree, ind, "parent")
-    tree = reroot(tree, tmproot)
+    nTips  = length(tree$tip.label)
+    if(tmproot>nTips) tree = root(tree, node=tmproot)
+    else  tree = root(tree, tmproot)   
     el = numeric(max(tree$edge))
     el[tree$edge[,2]]=tree$edge.length  
     maxdm = el[ind]
@@ -138,8 +129,24 @@ node2root <- function(x){
     tree$edge=edge
     tree$Nnode  = tree$Nnode+1
     attr(tree, "order") <- NULL
-    tree <- reorder(reroot(tree, rn), "postorder")
-    if(!is.null(oldtree$node.label))tree <- addConfidences.phylo(tree, oldtree)
+    tree <- reroot(tree, rn) 
+    if(!is.null(tree$node.label)){
+        node.label = tree$node.label
+        tmp = node.label[1]
+        node.label[1] = node.label[rn-nTips]
+        node.label[rn-nTips] = tmp
+        node.label[is.na(node.label)] = ""
+        tree$node.label = node.label
+    }
+    attr(tree, "order") <- NULL
+    tree <- reorder(tree, "postorder")
+#    tree <- reorder(reroot(tree, rn), "postorder")
+#    if(!is.null(oldtree$node.label))tree <- addConfidences.phylo(tree, oldtree)
+    if(!is.null(oldtree$node.label)){
+        type <- match.arg(node.labels, c("support", "label", "delete"))
+        if(type=="support") tree <- addConfidences.phylo(tree, oldtree)
+        if(type=="delete") tree$node.label <- NULL
+    }
     tree 
 }
 
@@ -148,7 +155,7 @@ pruneTree = function(tree, ..., FUN = ">="){
      if(is.null(tree$node)) stop("no node labels")
      if(is.rooted(tree)) tree = unroot(tree)
      m = max(tree$edge)
-     nTips = length(tree$tip)
+     nTips = length(tree$tip.label)
      bs = rep(TRUE, m)
      bs[ (nTips+1) : m] = sapply(as.numeric(as.character(tree$node)), FUN,...)    
      tree$edge.length[!bs[tree$edge[,2]]] = 0
@@ -163,8 +170,6 @@ pruneTree = function(tree, ..., FUN = ">="){
 # pos statt i      
 dropTip <- function(x, i, check.binary=FALSE, check.root=TRUE){
     edge <- x$edge
-#    edge1 <- edge[,1]
-#    edge2 <- edge[,2]
     root <- getRoot(x)
     ch <- which(edge[,2] == i)
     pa <- edge[ch,1] 
@@ -203,46 +208,6 @@ dropTip <- function(x, i, check.binary=FALSE, check.root=TRUE){
     x
 }
 
-# kind of works well too
-dropTip2 <- function(x, i, check.binary=FALSE, check.root=TRUE){
-  edge <- x$edge
-  root <- getRoot(x)
-  ch <- which(edge[,2] == i)
-  pa <- edge[ch,1] 
-  edge = edge[-ch,]
-  ind <- which(edge[,1] == pa) 
-  if(root == pa){
-    if(length(ind)==1){
-      edge = edge[-ind,]
-      x$Nnode=x$Nnode-1L
-    }
-    if(length(ind)==2){
-      n = dim(edge)[1]
-      newroot = edge[n-2L,1]
-      newedge = edge[ind,2] 
-      if(newedge[1]==newroot)edge[n-1,] <- newedge
-      else edge[n-1,] <- newedge[2:1]
-      edge = edge[-n,]   
-      x$Nnode=x$Nnode-1L
-      edge[edge==newroot] = root
-      pa <- newroot
-    }
-    # todo handle unrooted trees  
-  }
-  else{
-    nind <- which(edge[,2] == pa)         
-    # normal binary case
-    if(length(ind)==1){
-      edge[nind,2] = edge[ind,2]
-      edge <- edge[-ind,]
-      x$Nnode <- x$Nnode-1L           
-    }  
-  }
-  #
-#  edge[edge>pa]  = edge[edge>pa] -1L 
-  x$edge <- edge
-  x
-}
 
 
 # like drop tip and returns two trees, 
@@ -324,114 +289,6 @@ dropNode <- function(x, i, check.binary=FALSE, check.root=TRUE, all.ch=NULL){
 }
 
 
-
-dropNodeNew <- function(edge, i, nTips, check.binary=FALSE, check.root=TRUE){
-    root <- edge[nrow(edge),2]
-    ch <- which(edge[,2] == i)
-    pa <- edge[ch,1]
-    edge2=NULL
-    
-    # einfachere allChildren Variante 2*schneller
-    allKids = function (edge, nTips) 
-    {
-        parent = edge[, 1]
-        children = edge[, 2]
-        .Call("AllChildren", as.integer(children), as.integer(parent), as.integer(max(edge)), PACKAGE = "phangorn")
-    }
-    
-    descAll = function (edge, node, nTips) 
-    {
-        ch = allKids(edge, nTips)
-        isInternal = logical(max(edge))
-        isInternal[unique(edge[, 1])] = TRUE
-        desc = function(node, isInternal) {
-            if (!isInternal[node]) return(node)
-            res = NULL
-            while (length(node) > 0) {
-                tmp = unlist(ch[node])
-                res = c(res, tmp)
-                node = tmp[isInternal[tmp]]
-            }
-            res
-        }
-        desc(node, isInternal)
-    }    
-    
-    if(i>nTips){
-        kids <- descAll(edge, i, nTips)
-        ind <- match(kids,edge[,2])
-        edge2 <- edge[sort(ind),]            
-        edge <- edge[-c(ch, ind),]
-    }    
-    else edge = edge[-ch,]
-    if(nrow(edge)<3)return(NULL)  
-    ind <- which(edge[,1] == pa) 
-    if(root == pa){
-        if(length(ind)==1){
-            edge = edge[-ind,]
-        }
-        if(length(ind)==2){
-            n = dim(edge)[1]
-            newroot = edge[n-2L,1]
-            newedge = edge[ind,2] 
-            if(newedge[1]==newroot)edge[n-1,] <- newedge
-            else edge[n-1,] <- newedge[2:1]
-            edge = edge[-n,]   
-            edge[edge==newroot] = root
-            pa <- newroot
-        }
-        # todo handle unrooted trees  
-    }
-    else{
-        nind <- which(edge[,2] == pa)         
-        # normal binary case
-        if(length(ind)==1){
-            edge[nind,2] = edge[ind,2]
-            edge <- edge[-ind,]          
-        }  
-    }
-    #
-    #  edge[edge>pa]  = edge[edge>pa] -1L 
-    list(edge, edge2, pa)
-}
-
-
-dropTipNew <- function(edge, i, nTips, check.binary=FALSE, check.root=TRUE){
-    root <- edge[nrow(edge),2]
-    ch <- which(edge[,2] == i)
-    pa <- edge[ch,1] 
-    edge = edge[-ch,]
-    ind <- which(edge[,1] == pa) 
-    if(root == pa){
-        if(length(ind)==1){
-            edge = edge[-ind,]
-        }
-        if(length(ind)==2){
-            n = dim(edge)[1]
-            newroot = edge[n-2L,1]
-            newedge = edge[ind,2] 
-            if(newedge[1]==newroot)edge[n-1,] <- newedge
-            else edge[n-1,] <- newedge[2:1]
-            edge = edge[-n,]   
-            edge[edge==newroot] = root
-            pa <- newroot
-        }
-        # todo handle unrooted trees  
-    }
-    else{
-        nind <- which(edge[,2] == pa)         
-        # normal binary case
-        if(length(ind)==1){
-            edge[nind,2] = edge[ind,2]
-            edge <- edge[-ind,]       
-        }  
-    }
-    #
-    edge[edge>pa]  = edge[edge>pa] -1L 
-    edge
-}
-
-
 # postorder remained tip in 1:nTips
 addOne <- function (tree, tip, i){
     edge = tree$edge
@@ -466,7 +323,7 @@ addOneTree <- function (tree, subtree, i, node){
   tree$edge = edge 
   tree$Nnode = tree$Nnode + subtree$Nnode + 1L
   attr(tree, "order") = NULL
-  tips1 = as.integer(length(tree$tip) + 1L)
+  tips1 = as.integer(length(tree$tip.label) + 1L)
   tmproot = getRoot(tree)
   if(tmproot!=tips1){
       tree$edge[tree$edge==tmproot] = 0L
@@ -654,44 +511,6 @@ allTrees <- function (n, rooted = FALSE, tip.label = NULL)
 }
 
 
-
-dn <- function (x){
-    if (!is.binary.tree(x) ) 
-        x <- multi2di(x, random = FALSE)  
-    x = reroot2(x, 1)       
-    n <- length(x$tip.label)
-    n.node <- x$Nnode
-    N <- n + n.node
-    x <- reorderPruning(x)
-    res <- matrix(NA, N, N)
-    res[cbind(1:N, 1:N)] <- 0
-    res[x$edge] <- res[x$edge[, 2:1]] <- 1
-    for (i in seq(from = 1, by = 2, length.out = n.node)) {
-        j <- i + 1
-        anc <- x$edge[i, 1]
-        des1 <- x$edge[i, 2]
-        des2 <- x$edge[j, 2]
-        if (des1 > n) 
-            des1 <- which(!is.na(res[des1, ]))
-        if (des2 > n) 
-            des2 <- which(!is.na(res[des2, ]))
-        for (y in des1) res[y, des2] <- res[des2, y] <- res[anc, 
-            y] + res[anc, des2]
-        if (anc != 1) {
-            ind <- which(x$edge[, 2] == anc)
-            nod <- x$edge[ind, 1]
-            l <- length(ind)
-            res[des2, nod] <- res[nod, des2] <- res[anc, des2] + 
-                l
-            res[des1, nod] <- res[nod, des1] <- res[anc, des1] + 
-                l
-        }
-    }
-    dimnames(res)[1:2] <- list(1:N)
-    res
-}
-
-
 # replace with dist.nodes
 dn <- function(x){
 #  if (!is.binary.tree(x) ) x <- multi2di(x, random = FALSE)
@@ -820,7 +639,7 @@ sprMove <- function(tree, m){
 
     edge = tree$edge    
     k = max(edge)
-    nTips = length(tree$tip)
+    nTips = length(tree$tip.label)
     nEdges = 2*nTips-3 
     if(m > nEdges) stop("m to big")
 
@@ -976,7 +795,7 @@ Ancestors <- function (x, node, type = c("all", "parent"))
 
 
 allChildren <- function(x){
-   l = length(x$tip) 
+   l = length(x$tip.label) 
    if(l<20){
        parent = x$edge[,1]
        children = x$edge[,2]
@@ -1055,35 +874,44 @@ Siblings = function (x, node, include.self = FALSE)
 
 
 
-mrca.phylo <- function(x, node){
+mrca.phylo <- function(x, node=NULL){
+    if(is.null(node)) return(mrca2(x))
     anc <- Ancestors(x, node, type = "all")
     res <- Reduce(intersect, anc)[1]
     res
 }
 
-# mrca.phylo <- getMRCA
-
 
-# 1090
-rNNI_Old <- function(tree, moves=1, n=1){   
-    k = length(na.omit(match(tree$edge[,2], tree$edge[,1])))   
-    if(n==1){
-        trees = tree
-        for(i in 1:moves) trees = nnin(trees,sample(k,1))[[sample(2,1)]] 
-        trees$tip.label <- tree$tip.label
-    }  
+# should be in ape
+mrca2 <- function(phy, full=FALSE){
+    Nnode <- phy$Nnode
+    Ntips <- length(phy$tip.label)      
+    phy <- reorder(phy)
+    nodes <- unique(phy$edge[,1])
+    if(!full){
+        res <- Descendants(phy, nodes, "tips")
+        M <- matrix(nodes[1], Ntips, Ntips)
+        for(i in 2:Nnode)M[res[[i]], res[[i]]]<-nodes[i]
+        diag(M) <- 1:Ntips
+        dimnames(M) <-  list(phy$tip.label, phy$tip.label)
+    }
     else{
-        trees = vector("list", n)
-        for(j in 1:n){
-            tmp = tree 
-            for(i in 1:moves) tmp = nnin(tmp, sample(k,1))[[sample(2,1)]]
-            tmp$tip.label=NULL
-            trees[[j]] = tmp
-        }
-        attr(trees, "TipLabel") <- tree$tip.label
-        class(trees) <- "multiPhylo"   
+        res <- Descendants(phy, nodes, "all")
+        M <- matrix(nodes[1], Ntips+Nnode, Ntips+Nnode)
+        for(i in 2:Nnode){
+            tmp  = c(res[[i]], nodes[i])
+            M[tmp, tmp]<-nodes[i]
+        }    
+        diag(M) <- 1:(Ntips+Nnode)
+        dimnames(M) <-  list(1:(Ntips+Nnode),1:(Ntips+Nnode))
     }
-    trees
+    M
 }
 
 
+# mrca.phylo <- getMRCA
+
+
+
+
+
diff --git a/R/treedist.R b/R/treedist.R
index d4f2040..20bd0dd 100644
--- a/R/treedist.R
+++ b/R/treedist.R
@@ -3,7 +3,7 @@
 #
 
 allKids <- function(phy){
-    nTips = as.integer(length(phy$tip))
+    nTips = as.integer(length(phy$tip.label))
     lp=nrow(phy$edge)
     nNode = phy$Nnode
     .C("AllKids", as.integer(phy$edge[,2]), as.integer(phy$edge[,1]), as.integer(nTips), 
@@ -11,7 +11,7 @@ allKids <- function(phy){
 } 
 
 
-coph <- function(x){ 
+coph <- function(x, path=FALSE){ 
     if (is.null(attr(x, "order")) || attr(x, "order") == "cladewise") 
         x <- reorder(x, "postorder")
     nTips = as.integer(length(x$tip.label))   
@@ -21,7 +21,8 @@ coph <- function(x){
     nNode = as.integer(x$Nnode)
     m = as.integer(max(x$edge))
     el = double(m)
-    el[kids] = x$edge.length
+    if(path) el <- rep(1.0, m)
+    else el[kids] = x$edge.length
     dm <- .C("C_cophenetic", kids, parents, as.double(el), lp, m, nTips, nNode, double(nTips*(nTips-1L)/2L))[[8]]
     attr(dm, "Size") <- nTips
     attr(dm, "Labels") <- x$tip.label
@@ -46,7 +47,8 @@ cophenetic.splits <- function(x){
 
 
 cophenetic.networx <- function(x){
-    spl <- attr(x, "splits")
+#    spl <- attr(x, "splits")
+    spl <- x$splits
     cophenetic.splits(spl)
 }
 
@@ -109,12 +111,12 @@ treedist <- function (tree1, tree2, check.labels=TRUE)
     branch.score.difference = NULL
     path.difference = NULL
     quadratic.path.difference = NULL
-    if(!is.binary.tree(tree1) | !is.binary.tree(tree2))warning("Trees are not binary!")
+    if(!is.binary.tree(tree1) | !is.binary.tree(tree2))message("Trees are not binary!")
     
     bp1 = bip(tree1)
     bp2 = bip(tree2)
-    bp1 <- SHORTwise(bp1, length(tree1$tip))
-    bp2 <- SHORTwise(bp2, length(tree2$tip))
+    bp1 <- SHORTwise(bp1, length(tree1$tip.label))
+    bp2 <- SHORTwise(bp2, length(tree2$tip.label))
     bp1 <- sapply(bp1, paste, collapse = "_")
     bp2 <- sapply(bp2, paste, collapse = "_")
     
@@ -165,10 +167,177 @@ treedist <- function (tree1, tree2, check.labels=TRUE)
 }
 
 
-mRF2 <- function(tree, trees, check.labels = TRUE){
-    if (class(trees) != "multiPhylo") 
+wRF0 <- function(tree1, tree2, normalize=FALSE, check.labels=TRUE, rooted = FALSE){    
+    r1 = is.rooted(tree1)
+    r2 = is.rooted(tree2)
+    if (r1 != r2) {
+        message("one tree is unrooted, unrooted both")
+    }
+    if (!rooted) {
+        if (r1) 
+            tree1 <- unroot(tree1)
+        if (r2) 
+            tree2 <- unroot(tree2)
+    }
+    if (!r1 | !r2) {
+        if (r1) 
+            tree1 = unroot(tree1)
+        if (r2) 
+            tree2 = unroot(tree2)
+    }
+    if (!is.binary.tree(tree1) | !is.binary.tree(tree2)) 
+        message("Trees are not binary!")
+    if (check.labels) {
+        ind <- match(tree1$tip.label, tree2$tip.label)
+        if (any(is.na(ind)) | length(tree1$tip.label) != length(tree2$tip.label)) 
+            stop("trees have different labels")
+        tree2$tip.label <- tree2$tip.label[ind]
+        ind2 <- match(1:length(ind), tree2$edge[, 2])
+        tree2$edge[ind2, 2] <- order(ind)
+    }
+    bp1 = bip(tree1)
+    bp2 = bip(tree2)
+    if (!rooted) {
+        bp1 <- SHORTwise(bp1, length(tree1$tip.label))
+        bp2 <- SHORTwise(bp2, length(tree2$tip.label))
+    }
+    bp1 <- sapply(bp1, paste, collapse = "_")
+    bp2 <- sapply(bp2, paste, collapse = "_")
+    
+    w1 <- numeric(max(tree1$edge))
+    w2 <- numeric(max(tree2$edge))
+    w1[tree1$edge[,2]] <- tree1$edge.length
+    w2[tree2$edge[,2]] <- tree2$edge.length
+    
+    ind3 <- match(bp1, bp2, nomatch=0L)
+    ind4 <- ind3[ind3>0]
+    ind3 <- which(ind3>0)
+    
+    s1 <- sum(abs(w1[ind3] - w2[ind4]))
+    s2 <- sum(w1[-ind3])
+    s3 <- sum(w2[-ind4])
+    
+    wRF <- s1 + s2 + s3
+    if(normalize) wRF <- wRF / (sum(tree1$edge.length) + sum(tree2$edge.length))
+    return(wRF)
+}
+
+
+wRF2 <- function(tree, trees, normalize=FALSE, check.labels = TRUE){    
+    if(check.labels){
+        trees <- .compressTipLabel(trees)
+        tree <- checkLabels(tree, attr(trees, "TipLabel"))
+    }    
+    trees <- .uncompressTipLabel(trees)
+    unclass(trees) 
+    
+    if (any(sapply(trees, is.rooted))) {
+        trees <- lapply(trees, unroot)
+    }
+    
+    nTips <- length(tree$tip.label)
+    
+    fun1 <- function(x){
+        w <- numeric(max(x$edge))
+        w[x$edge[,2]] <- x$edge.length
+        w
+    }
+    W <- lapply(trees, fun1)
+    
+    fun2 <- function(x, nTips){
+        bp <- bip(x)
+        bp <- SHORTwise(bp, nTips)
+        bp <- sapply(bp, paste, collapse = "_")
+        bp
+    }
+    BP <- lapply(trees, fun2, nTips)
+    
+    if(is.rooted(tree)) tree <- unroot(tree)
+    bp = bip(tree)
+    
+    bp <- SHORTwise(bp, nTips)
+    bp <- sapply(bp, paste, collapse = "_")
+    
+    w <- numeric(max(tree$edge))
+    w[tree$edge[,2]] <- tree$edge.length
+    
+    l <- length(trees)
+    wRF <- numeric(l)
+    
+    for(i in 1:l){
+        ind3 = fmatch(BP[[i]], bp, nomatch=0L)
+        ind4 = ind3[ind3>0]
+        ind3 = which(ind3>0)
+        
+        s1 = sum(abs(W[[i]][ind3] - w[ind4]))
+        s2 = sum(W[[i]][-ind3])
+        s3 = sum(w[-ind4])
+        wRF[i] = (s1 + s2 + s3)
+    }
+    if(normalize){
+        sc <- sapply(trees, function(x)sum(x$edge.length)) + sum(tree$edge.length)
+        wRF <- wRF / sc
+    }
+    wRF
+}
+
+
+wRF1 <- function(trees, normalize=FALSE, check.labels = TRUE){
+    if(check.labels) trees <- .compressTipLabel(trees)
+    trees <- .uncompressTipLabel(trees)
+    unclass(trees)     
+    
+    nTips <- length(trees[[1]]$tip.label)
+    if (any(sapply(trees, is.rooted))) {
+        trees <- lapply(trees, unroot)
+    }
+    fun1 <- function(x){
+        w <- numeric(max(x$edge))
+        w[x$edge[,2]] <- x$edge.length
+        w
+    }
+    W <- lapply(trees, fun1)
+    fun2 <- function(x, nTips){
+        bp <- bip(x)
+        bp <- SHORTwise(bp, nTips)
+        bp <- sapply(bp, paste, collapse = "_")
+        bp
+    }
+    if(normalize) sc <- sapply(trees, function(x)sum(x$edge.length)) 
+    BP <- lapply(trees, fun2, nTips)
+    k <- 1
+    l <- length(trees)
+    wRF <- numeric((l * (l - 1))/2)
+    for (i in 1:(l - 1)){
+        bp <- BP[[i]]
+        w <- W[[i]]
+        for (j in (i + 1):l){
+            ind3 = fmatch(BP[[j]], bp, nomatch=0L)
+            ind4 = ind3[ind3>0]
+            ind3 = which(ind3>0)
+            s1 = sum(abs(W[[j]][ind3] - w[ind4]))
+            s2 = sum(W[[j]][-ind3])
+            s3 = sum(w[-ind4])
+            wRF[k] <- (s1 + s2 + s3)
+            if(normalize) wRF[k] <- wRF[k] / (sc[i] + sc[j])
+            k=k+1
+        }
+    }
+    attr(wRF, "Size") <- l
+    if(!is.null(names(trees)))attr(KF, "Labels") <- names(trees)
+    attr(wRF, "Diag") <- FALSE
+    attr(wRF, "Upper") <- FALSE
+    class(wRF) <- "dist"
+    return(wRF)
+}
+
+
+
+
+mRF2 <- function(tree, trees, normalize=FALSE, check.labels = TRUE){
+    if (!inherits(trees,"multiPhylo")) 
         stop("trees should be an object of class \"multiPhylo\"")
-    if (class(tree) != "phylo") 
+    if (!inherits(tree,"phylo")) 
         stop("trees should be an object of class \"phylo\"")
     trees <- .compressTipLabel(trees)
     tipLabel <- attr(trees, "TipLabel")
@@ -187,11 +356,11 @@ mRF2 <- function(tree, trees, check.labels = TRUE){
     #    n <- length(attr(trees, "TipLabel"))
     trees <- unclass(trees)
     if (any(sapply(trees, is.rooted))) {
-        warning("Some trees are rooted. Unrooting all trees.\n")
+        message("Some trees are rooted. Unrooting all trees.\n")
         trees <- lapply(trees, unroot)
     }
     if (any(sapply(trees, function(x) !is.binary.tree(x)))) {
-        warning("Some trees are not binary. Result may not what you expect!")
+        message("Some trees are not binary. Result may not what you expect!")
     }
     tree <- reorder(tree, "postorder")
     trees <- lapply(trees, reorder, "postorder")
@@ -201,17 +370,25 @@ mRF2 <- function(tree, trees, check.labels = TRUE){
     yy <- bipart(tree)  
     yy <- SHORTwise(yy, nTips)
     yy <- sapply(yy, paste, collapse="_")
+    
+    NnodeT <- Nnode(tree)
+    Nnodes <- sapply(trees, Nnode)
+    
     for (i in 1:l){   
-#        RF[i] <- 2 * sum(fmatch(xx[[i]], yy, nomatch=0L)==0L)   
-        RF[i] <- sum(match(xx[[i]], yy, nomatch=0L)==0L) + sum(match(yy, xx[[i]], nomatch=0L)==0L)
+        RF[i] <- Nnodes[i] + NnodeT - 2 * sum(fmatch(xx[[i]], yy, nomatch=0L)>0L)
+#        RF[i] <- sum(match(xx[[i]], yy, nomatch=0L)==0L) + sum(match(yy, xx[[i]], nomatch=0L)==0L)
     }
     if(!is.null(names(trees)))names(RF) <- names(trees)
-    return(RF)
+    if(!normalize)return(RF)
+    else{
+        sc <- sapply(trees, Nnode) + Nnode(tree) - 2
+        return(RF/sc)
+    }
 }
 
 
-mRF<-function(trees){
-    if (class(trees) != "multiPhylo") 
+mRF<-function(trees, normalize=FALSE){
+    if (!inherits(trees,"multiPhylo")) 
         stop("trees should be an object of class \"multiPhylo\"")
     trees <- .compressTipLabel(trees)
     tipLabel <- attr(trees, "TipLabel")
@@ -222,23 +399,25 @@ mRF<-function(trees){
     #    n <- length(attr(trees, "TipLabel"))
     trees <- unclass(trees)
     if (any(sapply(trees, is.rooted))) {
-        warning("Some trees are rooted. Unrooting all trees.\n")
+        message("Some trees are rooted. Unrooting all trees.\n")
         trees <- lapply(trees, unroot)
     }
     if (any(sapply(trees, function(x) !is.binary.tree(x)))) {
-        warning("Some trees are not binary. Result may not what you expect!")
+        message("Some trees are not binary. Result may not what you expect!")
     }
     trees <- lapply(trees, reorder, "postorder")
     xx <- lapply(trees, bipart)  
     xx <- lapply(xx, SHORTwise, nTips)
     xx <- lapply(xx,function(x)sapply(x, paste, collapse="_")) 
     # returns list of character vectors
+    Nnodes <- sapply(trees, Nnode)
     k=1
     for (i in 1:(l - 1)){
         tmp = xx[[i]]        
         for (j in (i + 1):l){
-#            RF[k] <- 2 * sum(fmatch(xx[[j]], tmp, nomatch=0L)==0L)
-            RF[k] <- sum(match(xx[[j]], tmp, nomatch=0L)==0L) + sum(match(tmp, xx[[j]], nomatch=0L)==0L)
+            RF[k] <- Nnodes[i] + Nnodes[j] - 2 * sum(fmatch(xx[[j]], tmp, nomatch=0L)>0L)
+#            RF[k] <- sum(match(xx[[j]], tmp, nomatch=0L)==0L) + sum(match(tmp, xx[[j]], nomatch=0L)==0L)
+            if(normalize) RF[k] <- RF[k] / ( Nnodes[i] + Nnodes[j] - 2)
             k=k+1
         }   
     }
@@ -251,15 +430,11 @@ mRF<-function(trees){
 }
 
 
-RF.dist <- function (tree1, tree2=NULL, check.labels = TRUE, rooted=FALSE)
-{
-    if(class(tree1)=="multiPhylo" && is.null(tree2))return(mRF(tree1)) 
-    if(class(tree1)=="phylo" && class(tree2)=="multiPhylo")return(mRF2(tree1, tree2, check.labels))
-    if(class(tree2)=="phylo" && class(tree1)=="multiPhylo")return(mRF2(tree2, tree1, check.labels))
+RF0 <- function(tree1, tree2=NULL, normalize=FALSE, check.labels = TRUE, rooted=FALSE){   
     r1 = is.rooted(tree1)
     r2 = is.rooted(tree2)
     if(r1 != r2){
-        warning("one tree is unrooted, unrooted both")
+        message("one tree is unrooted, unrooted both")
     }  
     if(!rooted){
         if(r1) tree1<-unroot(tree1)
@@ -281,14 +456,263 @@ RF.dist <- function (tree1, tree2=NULL, check.labels = TRUE, rooted=FALSE)
         if(r1) tree1 = unroot(tree1)
         if(r2) tree2 = unroot(tree2)
     }
-    if(!is.binary.tree(tree1) | !is.binary.tree(tree2))warning("Trees are not binary!")
+    if(!is.binary.tree(tree1) | !is.binary.tree(tree2))message("Trees are not binary!")
     bp1 = bipart(tree1)
     bp2 = bipart(tree2)
     if(!rooted){
-        bp1 <- SHORTwise(bp1, length(tree1$tip))
-        bp2 <- SHORTwise(bp2, length(tree2$tip))    
+        bp1 <- SHORTwise(bp1, length(tree1$tip.label))
+        bp2 <- SHORTwise(bp2, length(tree2$tip.label))    
     }
     RF = sum(match(bp1, bp2, nomatch=0L)==0L) + sum(match(bp2, bp1, nomatch=0L)==0L)
+    if(normalize) RF <- RF / (Nnode(tree1) + Nnode(tree2) - 2)
     RF
 }
 
+
+RF.dist <- function(tree1, tree2=NULL, normalize=FALSE, check.labels = TRUE, rooted=FALSE)
+{
+    if(class(tree1)=="phylo" && class(tree2)=="phylo")return(RF0(tree1, tree2, normalize, check.labels, rooted))
+    if(class(tree1)=="multiPhylo" && is.null(tree2))return(mRF(tree1, normalize)) 
+    if(class(tree1)=="phylo" && class(tree2)=="multiPhylo")return(mRF2(tree1, tree2, normalize, check.labels))
+    if(class(tree2)=="phylo" && class(tree1)=="multiPhylo")return(mRF2(tree2, tree1, normalize, check.labels))
+    else return(NULL)
+}
+
+
+wRF.dist <- function(tree1, tree2=NULL, normalize=FALSE, check.labels = TRUE, rooted=FALSE){
+    if(class(tree1)=="phylo" && class(tree2)=="phylo")return(wRF0(tree1, tree2, normalize, check.labels, rooted))
+    if(class(tree1)=="multiPhylo" && is.null(tree2))return(wRF1(tree1, normalize, check.labels))
+    
+    if(class(tree1)=="phylo" && class(tree2)=="multiPhylo")return(wRF2(tree1, tree2, normalize, check.labels))
+    if(class(tree2)=="phylo" && class(tree1)=="multiPhylo")return(wRF2(tree2, tree1, normalize, check.labels))
+    else return(NULL)        
+}
+
+
+kf0 <- function(tree1, tree2, check.labels = TRUE){    
+    if(check.labels)tree2 <- checkLabels(tree2, tree1$tip.label)
+    if(is.rooted(tree1)) tree1 <- unroot(tree1)
+    if(is.rooted(tree2)) tree2 <- unroot(tree2)
+    bp1 = bip(tree1)
+    bp2 = bip(tree2)
+    
+    bp1 <- SHORTwise(bp1, length(tree1$tip.label))
+    bp2 <- SHORTwise(bp2, length(tree2$tip.label))
+    bp1 <- sapply(bp1, paste, collapse = "_")
+    bp2 <- sapply(bp2, paste, collapse = "_")
+    
+    w1 <- numeric(max(tree1$edge))
+    w2 <- numeric(max(tree2$edge))
+    w1[tree1$edge[,2]] <- tree1$edge.length
+    w2[tree2$edge[,2]] <- tree2$edge.length
+        
+    ind3 = match(bp1, bp2, nomatch=0L)
+    ind4 = ind3[ind3>0]
+    ind3 = which(ind3>0)
+        
+    s1 = sum((w1[ind3] - w2[ind4])^2)
+    s2 = sum(w1[-ind3]^2)
+    s3 = sum(w2[-ind4]^2)
+    branch.score.difference = sqrt(s1 + s2 + s3)
+    branch.score.difference
+}
+
+
+kf1 <- function(tree, trees, check.labels = TRUE){    
+    if(check.labels){
+        trees <- .compressTipLabel(trees)
+        tree <- checkLabels(tree, attr(trees, "TipLabel"))
+    }    
+    trees <- .uncompressTipLabel(trees)
+    unclass(trees) 
+    
+    if (any(sapply(trees, is.rooted))) {
+        trees <- lapply(trees, unroot)
+    }
+    
+    nTips <- length(tree$tip.label)
+    
+    fun1 <- function(x){
+        w <- numeric(max(x$edge))
+        w[x$edge[,2]] <- x$edge.length
+        w
+    }
+    W <- lapply(trees, fun1)
+    
+    fun2 <- function(x, nTips){
+        bp <- bip(x)
+        bp <- SHORTwise(bp, nTips)
+        bp <- sapply(bp, paste, collapse = "_")
+        bp
+    }
+    BP <- lapply(trees, fun2, nTips)
+    
+    
+    if(is.rooted(tree)) tree <- unroot(tree)
+    bp = bip(tree)
+    
+    bp <- SHORTwise(bp, nTips)
+    bp <- sapply(bp, paste, collapse = "_")
+
+    w <- numeric(max(tree$edge))
+    w[tree$edge[,2]] <- tree$edge.length
+
+    l <- length(trees)
+    branch.score.difference <- numeric(l)
+    
+    for(i in 1:l){
+        ind3 = fmatch(BP[[i]], bp, nomatch=0L)
+        ind4 = ind3[ind3>0]
+        ind3 = which(ind3>0)
+    
+        s1 = sum((W[[i]][ind3] - w[ind4])^2)
+        s2 = sum(W[[i]][-ind3]^2)
+        s3 = sum(w[-ind4]^2)
+        branch.score.difference[i] = sqrt(s1 + s2 + s3)
+    }
+    branch.score.difference
+}
+
+
+kf2 <- function(trees, check.labels = TRUE){
+    if(check.labels) trees <- .compressTipLabel(trees)
+    trees <- .uncompressTipLabel(trees)
+    unclass(trees)     
+    
+    nTips <- length(trees[[1]]$tip.label)
+    if (any(sapply(trees, is.rooted))) {
+        trees <- lapply(trees, unroot)
+    }
+    fun1 <- function(x){
+        w <- numeric(max(x$edge))
+        w[x$edge[,2]] <- x$edge.length
+        w
+    }
+    W <- lapply(trees, fun1)
+    fun2 <- function(x, nTips){
+        bp <- bip(x)
+        bp <- SHORTwise(bp, nTips)
+        bp <- sapply(bp, paste, collapse = "_")
+        bp
+    }
+    BP <- lapply(trees, fun2, nTips)
+    k <- 1
+    l <- length(trees)
+    KF <- numeric((l * (l - 1))/2)
+    for (i in 1:(l - 1)){
+        bp <- BP[[i]]
+        w <- W[[i]]
+        for (j in (i + 1):l){
+            ind3 = fmatch(BP[[j]], bp, nomatch=0L)
+            ind4 = ind3[ind3>0]
+            ind3 = which(ind3>0)
+            s1 = sum((W[[j]][ind3] - w[ind4])^2)
+            s2 = sum(W[[j]][-ind3]^2)
+            s3 = sum(w[-ind4]^2)
+            KF[k] <- sqrt(s1 + s2 + s3)
+            k=k+1
+        }
+    }
+    attr(KF, "Size") <- l
+    if(!is.null(names(trees)))attr(KF, "Labels") <- names(trees)
+    attr(KF, "Diag") <- FALSE
+    attr(KF, "Upper") <- FALSE
+    class(KF) <- "dist"
+    return(KF)
+}
+
+
+# TODO distance matrices
+KF.dist <- function(tree1, tree2=NULL, check.labels = TRUE, rooted=FALSE){
+    if(inherits(tree1, "multiPhylo") && is.null(tree2))return(kf2(tree1)) 
+    if(inherits(tree1, "phylo") && inherits(tree2, "phylo"))return(kf0(tree1, tree2, check.labels))
+    if(inherits(tree1, "phylo") && inherits(tree2, "multiPhylo"))return(kf1(tree1, tree2, check.labels))
+    if(inherits(tree2, "phylo") && inherits(tree1, "multiPhylo"))return(kf1(tree2, tree1,check.labels))
+    return(NULL)
+}
+
+
+path.dist <- function(tree1, tree2=NULL, check.labels = TRUE, use.weight=FALSE){
+    if(inherits(tree1, "phylo") && inherits(tree2, "phylo"))
+         return(pd0(tree1, tree2, check.labels, !use.weight))
+    if(inherits(tree1, "phylo") && inherits(tree2, "multiPhylo"))
+         return(pd1(tree1, tree2, check.labels, !use.weight))
+    if(inherits(tree2, "phylo") && inherits(tree1, "multiPhylo"))
+        return(pd1(tree2, tree1, check.labels, !use.weight))
+    if(inherits(tree1, "multiPhylo") && is.null(tree2))
+        return(pd2(tree1, check.labels, !use.weight))
+    else return(NULL)
+}
+
+
+#wPath.dist <- function(tree1, tree2=NULL, check.labels = TRUE){
+#    if(inherits(tree1, "phylo") && inherits(tree2, "phylo"))
+#        return(pd0(tree1, tree2, check.labels, FALSE))
+#    if(inherits(tree1, "phylo") && inherits(tree2, "multiPhylo"))
+#        return(pd1(tree1, tree2, check.labels, FALSE))
+#    if(inherits(tree2, "phylo") && inherits(tree1, "multiPhylo"))
+#        return(pd1(tree2, tree1, check.labels, FALSE))
+#    if(inherits(tree1, "multiPhylo") && is.null(tree2))
+#        return(pd2(tree1, check.labels, FALSE))
+#    else return(NULL)
+#}
+
+
+pd0 <- function(tree1, tree2, check.labels=TRUE, path=TRUE){
+    if(check.labels)tree2 <- checkLabels(tree2, tree1$tip.label)
+    if(path){
+        tree1 <- unroot(tree1)
+        tree2 <- unroot(tree2)
+    }    
+#    n <- nrow(tree1$edge)
+#    tree1$edge.length <- tree2$edge.length <- rep(1, n)
+    dt1 = coph(tree1, path)
+    dt2 = coph(tree2, path)  
+    sqrt(sum((dt1 - dt2)^2))
+}
+
+
+pd1 <- function(tree, trees, check.labels=TRUE, path=TRUE){
+    if(check.labels){
+        trees <- .compressTipLabel(trees)
+        tree <- checkLabels(tree, attr(trees, "TipLabel"))
+    }    
+    trees <- .uncompressTipLabel(trees)
+    unclass(trees)
+    if(path)trees <- lapply(trees, unroot)
+    trees <- lapply(trees, reorder, "postorder")
+    l <- length(trees)
+    dt <- coph(tree, path)
+    res <- numeric(l)
+    for(i in 1:l){
+        dt2 <- coph(trees[[i]], path)  
+        res[i] <- sqrt(sum((dt - dt2)^2))        
+    }
+    res
+} 
+
+pd2 <- function(trees, check.labels=TRUE, path=TRUE){
+    if(check.labels) trees <- .compressTipLabel(trees)
+    trees <- .uncompressTipLabel(trees)
+    unclass(trees) 
+    if(path)trees <- lapply(trees, unroot)
+    trees <- lapply(trees, reorder, "postorder")
+    l <- length(trees)
+    CM <- lapply(trees, coph, path)
+    res <- numeric(l)
+    k <- 1 
+    PD <- numeric((l * (l - 1))/2)
+    for (i in 1:(l - 1)){
+        for (j in (i + 1):l){
+            PD[k] <- sqrt(sum((CM[[i]] - CM[[j]])^2))    
+            k=k+1
+        }
+    }
+    attr(PD, "Size") <- l
+    if(!is.null(names(trees)))attr(PD, "Labels") <- names(trees)
+    attr(PD, "Diag") <- FALSE
+    attr(PD, "Upper") <- FALSE
+    class(PD) <- "dist"
+    return(PD)
+}
+
diff --git a/README.md b/README.md
index e427f93..9cf418f 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,8 @@
 [![CRAN Status Badge](http://www.r-pkg.org/badges/version/phangorn)](http://cran.r-project.org/package=phangorn)
 [![License](http://img.shields.io/badge/license-GPL%20%28%3E=%202%29-brightgreen.svg?style=flat)](http://www.gnu.org/licenses/gpl-2.0.html)
 [![CRAN Downloads](http://cranlogs.r-pkg.org/badges/phangorn)](http://cran.r-project.org/package=phangorn)
+[![Research software impact](http://depsy.org/api/package/cran/phangorn/badge.svg)](http://depsy.org/package/r/phangorn)
+[![codecov.io](https://codecov.io/github/KlausVigo/phangorn/coverage.svg?branch=master)](https://codecov.io/github/KlausVigo/phangorn?branch=master)
 
 
 phangorn
@@ -11,7 +13,13 @@ phangorn is a package for phylogenetic reconstruction and analysis in the R lang
 
 You can install
 - the latest released version `install.packages("phangorn")`
-- the latest development version `devtools::install_github("KlausVigo/phangorn")` 
+- the latest development version `devtools::install_github("KlausVigo/phangorn")`
+
+You may need to install first the Biostrings package from bioconductor 
+```
+source("http://bioconductor.org/biocLite.R")
+biocLite("Biostrings")
+```
 
 If you use phangorn please cite:
 
diff --git a/TODO b/TODO
deleted file mode 100644
index 190248f..0000000
--- a/TODO
+++ /dev/null
@@ -1,15 +0,0 @@
-1.99-4
-
-modelTest  * check optimisation
-           * AIC, AICc, BIC 
-
-optim.pml * start tree optimisation
-          * unique tree (multifurcations)
-          
-2.0.0
-Rcpp, RcppArmadillo
-imprevements pmlPart, pmlCluster    
-  
-          
-
-
diff --git a/build/vignette.rds b/build/vignette.rds
index b5a2678..7f43017 100644
Binary files a/build/vignette.rds and b/build/vignette.rds differ
diff --git a/inst/doc/Ancestral.R b/inst/doc/Ancestral.R
index efb8b47..4eaa3a6 100644
--- a/inst/doc/Ancestral.R
+++ b/inst/doc/Ancestral.R
@@ -1,14 +1,15 @@
 ### R code from vignette source 'Ancestral.Rnw'
 
 ###################################################
-### code chunk number 1: Ancestral.Rnw:44-46
+### code chunk number 1: Ancestral.Rnw:44-47
 ###################################################
 options(width=70)
+options("show.signif.stars" = FALSE)
 foo <- packageDescription("phangorn")
 
 
 ###################################################
-### code chunk number 2: Ancestral.Rnw:61-66
+### code chunk number 2: Ancestral.Rnw:62-67
 ###################################################
 library(phangorn)
 primates = read.phyDat("primates.dna", format = "phylip", type = "DNA")
@@ -18,7 +19,7 @@ parsimony(tree, primates)
 
 
 ###################################################
-### code chunk number 3: Ancestral.Rnw:72-74
+### code chunk number 3: Ancestral.Rnw:73-75
 ###################################################
 anc.acctran = ancestral.pars(tree, primates, "ACCTRAN")
 anc.mpr = ancestral.pars(tree, primates, "MPR")
@@ -40,7 +41,7 @@ if(tmp) seqLogo( t(subset(anc.mpr, getRoot(tree), 1:20)[[1]]), ic.scale=FALSE)
 
 
 ###################################################
-### code chunk number 6: Ancestral.Rnw:93-95
+### code chunk number 6: Ancestral.Rnw:94-96
 ###################################################
 options(SweaveHooks=list(fig=function()
 par(mar=c(2.1, 4.1, 2.1, 2.1))))
@@ -68,14 +69,14 @@ title("ACCTRAN")
 
 
 ###################################################
-### code chunk number 9: Ancestral.Rnw:122-124
+### code chunk number 9: Ancestral.Rnw:123-125
 ###################################################
 fit = pml(tree, primates)
 fit = optim.pml(fit, model="F81", control = pml.control(trace=0))
 
 
 ###################################################
-### code chunk number 10: Ancestral.Rnw:136-138
+### code chunk number 10: Ancestral.Rnw:137-139
 ###################################################
 anc.ml = ancestral.pml(fit, "ml")
 anc.bayes = ancestral.pml(fit, "bayes")
@@ -103,7 +104,7 @@ title("Bayes")
 
 
 ###################################################
-### code chunk number 13: Ancestral.Rnw:162-163
+### code chunk number 13: Ancestral.Rnw:163-164
 ###################################################
 toLatex(sessionInfo())
 
diff --git a/inst/doc/Ancestral.Rnw b/inst/doc/Ancestral.Rnw
index 09473be..8b29ab7 100644
--- a/inst/doc/Ancestral.Rnw
+++ b/inst/doc/Ancestral.Rnw
@@ -43,6 +43,7 @@
 
 <<echo=FALSE>>=
 options(width=70)
+options("show.signif.stars" = FALSE)
 foo <- packageDescription("phangorn")
 @
 
diff --git a/inst/doc/Ancestral.pdf b/inst/doc/Ancestral.pdf
index 35de42c..f6050c7 100644
Binary files a/inst/doc/Ancestral.pdf and b/inst/doc/Ancestral.pdf differ
diff --git a/inst/doc/IntertwiningTreesAndNetworks.R b/inst/doc/IntertwiningTreesAndNetworks.R
new file mode 100644
index 0000000..6314db4
--- /dev/null
+++ b/inst/doc/IntertwiningTreesAndNetworks.R
@@ -0,0 +1,123 @@
+## ----setup, echo=FALSE---------------------------------------------------
+# set global chunk options: images will be bigger
+knitr::opts_chunk$set(fig.width=7, fig.height=7) 
+options(digits = 4)
+
+## ---- eval=FALSE---------------------------------------------------------
+#  install.packages("phangorn", dependencies=TRUE)
+#  # install latest development version needs devtools
+#  install.packages("devtools", dependencies=TRUE)
+#  library(devtools)
+#  install_github("KlausVigo/phangorn")
+
+## ------------------------------------------------------------------------
+library(phangorn)    # load the phangorn library
+
+## ------------------------------------------------------------------------
+## automatically set the correct working directory for the examples below
+# setwd(system.file("extdata/trees", package = "phangorn"))
+# for this vignette we create a path to the files we want to load 
+fdir <- system.file("extdata/trees", package = "phangorn")
+## in your case it may look something like this...
+# setwd("C:/TreesNetworks/Example Files")
+
+##DNA Matrix, maybe not needed 
+woodmouse <- read.phyDat(file.path(fdir, "woodmouse.fasta"),format="fasta") 
+## RAxML best-known tree with bipartition support (from previous analysis)
+raxml.tree <- read.tree(file.path(fdir,"RAxML_bipartitions.woodmouse"))
+## RAxML bootstrap trees (from previous analysis)
+raxml.bootstrap <- read.tree(file.path(fdir,"RAxML_bootstrap.woodmouse"))
+## MrBayes consensus tree (50% majority rule) (from previous analysis)
+mrbayes.tree <- read.nexus(file.path(fdir,"woodmouse.mrbayes.nex.con"))
+## MrBayes sample runs 1 and 2 (from previous analysis)
+run1 <- read.nexus(file.path(fdir,"woodmouse.mrbayes.nex.run1.t"))
+run2 <- read.nexus(file.path(fdir,"woodmouse.mrbayes.nex.run2.t"))
+## How many trees are in the MrBayes tree sample?
+run1
+run2
+## Combining the two runs and removing 25% burn-in
+mrbayes.trees <- c(run1[251:1001],run2[251:1001])
+## NeigbourNet Nexus file generated by SplitsTree (from previous analysis)
+Nnet <- read.nexus.networx(file.path(fdir,"woodmouse.nxs"))
+
+## ------------------------------------------------------------------------
+par(mfrow=c(1,2), mar=c(2,2,2,2)) # Setting plot parameters
+### Plotting trees with support values:
+##  RAxML
+plot(raxml.tree)
+nodelabels(raxml.tree$node.label, adj = c(1, 0), frame = "none")
+##  MrBayes
+plot(mrbayes.tree)
+nodelabels(mrbayes.tree$node.label, adj = c(1, 0), frame = "none")
+
+par(mfrow=c(1,1)) # Setting plot parameters
+# NeighbourNet
+plot.networx(Nnet,"2D")
+## alternatively,
+# plot(Nnet,"2D")
+
+
+## ------------------------------------------------------------------------
+# create a vector of labels for the network corresponding to edges in the tree
+edge.lab <- createLabel(Nnet, raxml.tree, raxml.tree$edge[,2], "edge")
+# could be also 1:27 instead of raxml.tree$edge[,2]
+
+# Show the correspondingly labelled tree and network in R
+par(mfrow=c(1,2), mar=c(1,1,1,1))
+#plotBS(raxml.tree, rotate.tree = 180) 
+plot(raxml.tree, "u", rotate.tree = 180) 
+edgelabels(raxml.tree$edge[,2],col="blue", frame="none")
+
+# find edges that are in the network but not in the tree
+edge.col <- rep("black", nrow(Nnet$edge))
+edge.col[ is.na(edge.lab) ] <- "red"
+# or a simpler alternative...
+edge.col <- createLabel(Nnet, raxml.tree, "black", nomatch="red")
+
+x <- plot.networx(Nnet, edge.label = edge.lab, show.edge.label = T, "2D", edge.color = edge.col,
+                  col.edge.label = "blue")
+# the above plot function returns an invisible networx object and this object also  
+# contains the colors for the edges.
+
+
+## ------------------------------------------------------------------------
+x <- addConfidences(Nnet,raxml.tree)
+# find splits that are in the network but not in the tree
+split.col <- rep("black", length(x$splits))
+split.col[ !matchSplits(as.splits(x), as.splits(raxml.tree)) ] <- "red"
+
+# simpler alternative...
+split.col2 <- createLabel(x, raxml.tree, label="black", "split", nomatch="red")
+
+# Plotting in R
+par(mfrow=c(1,1))
+out.x <- plot.networx(x,"2D",show.edge.label=TRUE, split.color=split.col, col.edge.label = "blue")
+
+## ------------------------------------------------------------------------
+# write.nexus.networx(out.x,"woodmouse.tree.support.nxs")
+## or we can also export the splits alone (for usage in software other than SplitsTree)
+# write.nexus.splits(as.splits(out.x),"woodmouse.splits.support.nxs")
+
+## ------------------------------------------------------------------------
+y <- addConfidences(Nnet, as.splits(raxml.bootstrap))
+edge.col <- createLabel(y, raxml.tree, label="black", "edge", nomatch="grey")
+
+y <- plot(y,"2D",show.edge.label=TRUE, edge.color=edge.col)
+
+## Write to SplitsTree for viewing
+# write.nexus.networx(y,"NN.with.bs.support.nxs")
+
+## ------------------------------------------------------------------------
+cnet <- consensusNet(raxml.bootstrap,prob=0.10)
+edge.col <- createLabel(cnet, Nnet, label="black", "edge", nomatch="grey")
+cnet <- plot.networx(cnet, "2D", show.edge.label = TRUE, edge.color=edge.col)
+
+edge.col <- createLabel(Nnet, cnet, label="black", "edge", nomatch="grey")
+z <- plot.networx(Nnet, "2D", show.edge.label = TRUE, edge.color=edge.col)
+
+obj <- addConfidences(Nnet,cnet)
+plot.networx(obj,"2D",show.edge.label=T, edge.color=edge.col, col.edge.label = "blue")
+
+## Write to SplitsTree for viewing
+# write.nexus.networx(obj,"Nnet.with.ML.Cnet.Bootstrap.nxs")
+
diff --git a/inst/doc/IntertwiningTreesAndNetworks.Rmd b/inst/doc/IntertwiningTreesAndNetworks.Rmd
new file mode 100644
index 0000000..53a147a
--- /dev/null
+++ b/inst/doc/IntertwiningTreesAndNetworks.Rmd
@@ -0,0 +1,190 @@
+---
+title: 'Intertwining phylogenetic trees and networks: R Example Script'
+author: "Klaus Schliep, Alastair Potts, David Morrison and Guido Grimm"
+date: "`r format(Sys.time(), '%B %d, %Y')`"
+output: rmarkdown::html_vignette
+vignette: >
+   %\VignetteIndexEntry{IntertwiningTreesAndNetworks}
+   %\VignetteEngine{knitr::rmarkdown}
+   %\usepackage[utf8]{inputenc}
+---
+
+
+```{r setup, echo=FALSE}
+# set global chunk options: images will be bigger
+knitr::opts_chunk$set(fig.width=7, fig.height=7) 
+options(digits = 4)
+```
+
+
+*Description:* This script provides examples of the new functions available in the phangorn library to 'intertwine' trees and networks, i.e. compare trees and networks and data transferrance. It also provides a step-by-step guide for users new to R. 
+
+*Methodological advancement:* The major advancement in this phangorn update is the introduction of a generic network object with a wide range of related transfer and analysis functions. These new functions provide the first means to directly transfer information amongst a wide range of phylogenetic trees and networks, as well as means to visualise and further analyse this information. This should provide a platform for individuals to easily conduct tree-network comparisons and stimulate  [...]
+
+*What next?:* By implementing full network handling compatibility in R, and providing exemplar scripts (such as this) and [support](https://github.com/KlausVigo/phangorn), the scientific community now has an easy means to analyse and compare the results of phylogenetic trees vs. network approaches. We hope this will open a largely unexplored world to the general phylogenetic audience. 
+
+
+### Installing R                                                 
+1. Download R                                                     
+ Select the nearest mirror to your location at https://cran.r-project.org/mirrors.html                          
+2. Select your operating system and download the relevant installation file.                                             
+3. Install R following the instructions.                          
+
+### Installing the phangorn library                                 
+Open R and run the two lines of code below in the command line.   
+(You will need to select a region from which to download the library)                       
+```{r, eval=FALSE}
+install.packages("phangorn", dependencies=TRUE)
+# install latest development version needs devtools
+install.packages("devtools", dependencies=TRUE)
+library(devtools)
+install_github("KlausVigo/phangorn")
+```
+
+
+### Getting started                                                  
+```{r}
+library(phangorn)    # load the phangorn library
+```
+
+### Set the working directory
+This is often a major stumbling block for new R users. You need to specify where in your folder structure you wish to work. i.e, where are the files stored that you wish to input?
+
+This is done using the setwd() function, e.g. setwd("C:/TreesNetworks/Example Files").
+
+We now set it to the folder of the phangorn package, which contains the files we want to load for this example.
+
+### Read in the example file datasets:
+This example files are based on the woodmouse dataset available in the ape library. Ultimately, this dataset is from this study: Michaux, J. R., Magnanou, E., Paradis, E., Nieberding, C. and Libois, R. (2003) 
+Mitochondrial phylogeography of the Woodmouse (*Apodemus sylvaticus*) in the Western 
+Palearctic region. Molecular Ecology, 12, 685-697.)
+ 
+```{r} 
+## automatically set the correct working directory for the examples below
+# setwd(system.file("extdata/trees", package = "phangorn"))
+# for this vignette we create a path to the files we want to load 
+fdir <- system.file("extdata/trees", package = "phangorn")
+## in your case it may look something like this...
+# setwd("C:/TreesNetworks/Example Files")
+
+##DNA Matrix, maybe not needed 
+woodmouse <- read.phyDat(file.path(fdir, "woodmouse.fasta"),format="fasta") 
+## RAxML best-known tree with bipartition support (from previous analysis)
+raxml.tree <- read.tree(file.path(fdir,"RAxML_bipartitions.woodmouse"))
+## RAxML bootstrap trees (from previous analysis)
+raxml.bootstrap <- read.tree(file.path(fdir,"RAxML_bootstrap.woodmouse"))
+## MrBayes consensus tree (50% majority rule) (from previous analysis)
+mrbayes.tree <- read.nexus(file.path(fdir,"woodmouse.mrbayes.nex.con"))
+## MrBayes sample runs 1 and 2 (from previous analysis)
+run1 <- read.nexus(file.path(fdir,"woodmouse.mrbayes.nex.run1.t"))
+run2 <- read.nexus(file.path(fdir,"woodmouse.mrbayes.nex.run2.t"))
+## How many trees are in the MrBayes tree sample?
+run1
+run2
+## Combining the two runs and removing 25% burn-in
+mrbayes.trees <- c(run1[251:1001],run2[251:1001])
+## NeigbourNet Nexus file generated by SplitsTree (from previous analysis)
+Nnet <- read.nexus.networx(file.path(fdir,"woodmouse.nxs"))
+```
+All example files read into R.
+
+### Viewing the data   
+```{r}
+par(mfrow=c(1,2), mar=c(2,2,2,2)) # Setting plot parameters
+### Plotting trees with support values:
+##  RAxML
+plot(raxml.tree)
+nodelabels(raxml.tree$node.label, adj = c(1, 0), frame = "none")
+##  MrBayes
+plot(mrbayes.tree)
+nodelabels(mrbayes.tree$node.label, adj = c(1, 0), frame = "none")
+
+par(mfrow=c(1,1)) # Setting plot parameters
+# NeighbourNet
+plot.networx(Nnet,"2D")
+## alternatively,
+# plot(Nnet,"2D")
+
+```
+
+### Interwining trees and network functions                         
+### 1A: 
+Identification of edge bundles (in black) in a neighbour-net (NN) network that correspond to branches (labelled 1-12) in a tree (a maximum likelihood tree, in this case). 
+
+```{r} 
+# create a vector of labels for the network corresponding to edges in the tree
+edge.lab <- createLabel(Nnet, raxml.tree, raxml.tree$edge[,2], "edge")
+# could be also 1:27 instead of raxml.tree$edge[,2]
+
+# Show the correspondingly labelled tree and network in R
+par(mfrow=c(1,2), mar=c(1,1,1,1))
+#plotBS(raxml.tree, rotate.tree = 180) 
+plot(raxml.tree, "u", rotate.tree = 180) 
+edgelabels(raxml.tree$edge[,2],col="blue", frame="none")
+
+# find edges that are in the network but not in the tree
+edge.col <- rep("black", nrow(Nnet$edge))
+edge.col[ is.na(edge.lab) ] <- "red"
+# or a simpler alternative...
+edge.col <- createLabel(Nnet, raxml.tree, "black", nomatch="red")
+
+x <- plot.networx(Nnet, edge.label = edge.lab, show.edge.label = T, "2D", edge.color = edge.col,
+                  col.edge.label = "blue")
+# the above plot function returns an invisible networx object and this object also  
+# contains the colors for the edges.
+
+```
+
+
+### 1B: 
+Bootstrap support for all branches (branch labels) in the ML tree mapped on the corresponding edge bundles of the NN network. The edges in the network which are not found as ML tree branches are highlighted in red.
+```{r}   
+x <- addConfidences(Nnet,raxml.tree)
+# find splits that are in the network but not in the tree
+split.col <- rep("black", length(x$splits))
+split.col[ !matchSplits(as.splits(x), as.splits(raxml.tree)) ] <- "red"
+
+# simpler alternative...
+split.col2 <- createLabel(x, raxml.tree, label="black", "split", nomatch="red")
+
+# Plotting in R
+par(mfrow=c(1,1))
+out.x <- plot.networx(x,"2D",show.edge.label=TRUE, split.color=split.col, col.edge.label = "blue")
+```
+Again we can write to SplitsTree for viewing...
+```{r}
+# write.nexus.networx(out.x,"woodmouse.tree.support.nxs")
+## or we can also export the splits alone (for usage in software other than SplitsTree)
+# write.nexus.splits(as.splits(out.x),"woodmouse.splits.support.nxs")
+```
+
+### 1C: 
+Frequencies of bipartitions found in the bootstrap pseudoreplicates mapped on the corresponding edge bundles of the NN network using a threshold of 10% (i.e. any edge is labelled that occurs in at least 
+100 of the 1000 ML-BS pseudoreplicates). Edge bundles not found in the ML tree are labelled using grey edges.
+
+```{r}
+y <- addConfidences(Nnet, as.splits(raxml.bootstrap))
+edge.col <- createLabel(y, raxml.tree, label="black", "edge", nomatch="grey")
+
+y <- plot(y,"2D",show.edge.label=TRUE, edge.color=edge.col)
+
+## Write to SplitsTree for viewing
+# write.nexus.networx(y,"NN.with.bs.support.nxs")
+```
+
+### Extras...
+We can also compare the neighborNet with a consensusNet (Holland BR, Huber KT, Moulton V, Lockhart PJ,2004, Using consensus networks to visualize contradictory evidence for species phylogeny. Molecular Biology and Evolution, 21, 1459-1461). Furthermore, we can extract the support values from the consensus network, and place these on to the NeighbourNet (this is similar to the process explained in 1C above).
+```{r}
+cnet <- consensusNet(raxml.bootstrap,prob=0.10)
+edge.col <- createLabel(cnet, Nnet, label="black", "edge", nomatch="grey")
+cnet <- plot.networx(cnet, "2D", show.edge.label = TRUE, edge.color=edge.col)
+
+edge.col <- createLabel(Nnet, cnet, label="black", "edge", nomatch="grey")
+z <- plot.networx(Nnet, "2D", show.edge.label = TRUE, edge.color=edge.col)
+
+obj <- addConfidences(Nnet,cnet)
+plot.networx(obj,"2D",show.edge.label=T, edge.color=edge.col, col.edge.label = "blue")
+
+## Write to SplitsTree for viewing
+# write.nexus.networx(obj,"Nnet.with.ML.Cnet.Bootstrap.nxs")
+```
diff --git a/inst/doc/IntertwiningTreesAndNetworks.html b/inst/doc/IntertwiningTreesAndNetworks.html
new file mode 100644
index 0000000..4ab62d8
--- /dev/null
+++ b/inst/doc/IntertwiningTreesAndNetworks.html
@@ -0,0 +1,249 @@
+<!DOCTYPE html>
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+<head>
+
+<meta charset="utf-8">
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta name="generator" content="pandoc" />
+
+<meta name="viewport" content="width=device-width, initial-scale=1">
+
+<meta name="author" content="Klaus Schliep, Alastair Potts, David Morrison and Guido Grimm" />
+
+<meta name="date" content="2016-06-20" />
+
+<title>Intertwining phylogenetic trees and networks: R Example Script</title>
+
+
+
+<style type="text/css">code{white-space: pre;}</style>
+<style type="text/css">
+div.sourceCode { overflow-x: auto; }
+table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
+  margin: 0; padding: 0; vertical-align: baseline; border: none; }
+table.sourceCode { width: 100%; line-height: 100%; }
+td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
+td.sourceCode { padding-left: 5px; }
+code > span.kw { color: #007020; font-weight: bold; } /* Keyword */
+code > span.dt { color: #902000; } /* DataType */
+code > span.dv { color: #40a070; } /* DecVal */
+code > span.bn { color: #40a070; } /* BaseN */
+code > span.fl { color: #40a070; } /* Float */
+code > span.ch { color: #4070a0; } /* Char */
+code > span.st { color: #4070a0; } /* String */
+code > span.co { color: #60a0b0; font-style: italic; } /* Comment */
+code > span.ot { color: #007020; } /* Other */
+code > span.al { color: #ff0000; font-weight: bold; } /* Alert */
+code > span.fu { color: #06287e; } /* Function */
+code > span.er { color: #ff0000; font-weight: bold; } /* Error */
+code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
+code > span.cn { color: #880000; } /* Constant */
+code > span.sc { color: #4070a0; } /* SpecialChar */
+code > span.vs { color: #4070a0; } /* VerbatimString */
+code > span.ss { color: #bb6688; } /* SpecialString */
+code > span.im { } /* Import */
+code > span.va { color: #19177c; } /* Variable */
+code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
+code > span.op { color: #666666; } /* Operator */
+code > span.bu { } /* BuiltIn */
+code > span.ex { } /* Extension */
+code > span.pp { color: #bc7a00; } /* Preprocessor */
+code > span.at { color: #7d9029; } /* Attribute */
+code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
+code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
+code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
+code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
+</style>
+
+
+
+<link href="data:text/css;charset=utf-8,body%20%7B%0Abackground%2Dcolor%3A%20%23fff%3B%0Amargin%3A%201em%20auto%3B%0Amax%2Dwidth%3A%20700px%3B%0Aoverflow%3A%20visible%3B%0Apadding%2Dleft%3A%202em%3B%0Apadding%2Dright%3A%202em%3B%0Afont%2Dfamily%3A%20%22Open%20Sans%22%2C%20%22Helvetica%20Neue%22%2C%20Helvetica%2C%20Arial%2C%20sans%2Dserif%3B%0Afont%2Dsize%3A%2014px%3B%0Aline%2Dheight%3A%201%2E35%3B%0A%7D%0A%23header%20%7B%0Atext%2Dalign%3A%20center%3B%0A%7D%0A%23TOC%20%7B%0Aclear%3A%20bot [...]
+
+</head>
+
+<body>
+
+
+
+
+<h1 class="title toc-ignore">Intertwining phylogenetic trees and networks: R Example Script</h1>
+<h4 class="author"><em>Klaus Schliep, Alastair Potts, David Morrison and Guido Grimm</em></h4>
+<h4 class="date"><em>June 20, 2016</em></h4>
+
+
+
+<p><em>Description:</em> This script provides examples of the new functions available in the phangorn library to ‘intertwine’ trees and networks, i.e. compare trees and networks and data transferrance. It also provides a step-by-step guide for users new to R.</p>
+<p><em>Methodological advancement:</em> The major advancement in this phangorn update is the introduction of a generic network object with a wide range of related transfer and analysis functions. These new functions provide the first means to directly transfer information amongst a wide range of phylogenetic trees and networks, as well as means to visualise and further analyse this information. This should provide a platform for individuals to easily conduct tree-network comparisons and  [...]
+<p><em>What next?:</em> By implementing full network handling compatibility in R, and providing exemplar scripts (such as this) and <a href="https://github.com/KlausVigo/phangorn">support</a>, the scientific community now has an easy means to analyse and compare the results of phylogenetic trees vs. network approaches. We hope this will open a largely unexplored world to the general phylogenetic audience.</p>
+<div id="installing-r" class="section level3">
+<h3>Installing R</h3>
+<ol style="list-style-type: decimal">
+<li>Download R<br />
+Select the nearest mirror to your location at <a href="https://cran.r-project.org/mirrors.html" class="uri">https://cran.r-project.org/mirrors.html</a><br />
+</li>
+<li>Select your operating system and download the relevant installation file.<br />
+</li>
+<li>Install R following the instructions.</li>
+</ol>
+</div>
+<div id="installing-the-phangorn-library" class="section level3">
+<h3>Installing the phangorn library</h3>
+<p>Open R and run the two lines of code below in the command line.<br />
+(You will need to select a region from which to download the library)</p>
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">install.packages</span>(<span class="st">"phangorn"</span>, <span class="dt">dependencies=</span><span class="ot">TRUE</span>)
+<span class="co"># install latest development version needs devtools</span>
+<span class="kw">install.packages</span>(<span class="st">"devtools"</span>, <span class="dt">dependencies=</span><span class="ot">TRUE</span>)
+<span class="kw">library</span>(devtools)
+<span class="kw">install_github</span>(<span class="st">"KlausVigo/phangorn"</span>)</code></pre></div>
+</div>
+<div id="getting-started" class="section level3">
+<h3>Getting started</h3>
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">library</span>(phangorn)    <span class="co"># load the phangorn library</span></code></pre></div>
+</div>
+<div id="set-the-working-directory" class="section level3">
+<h3>Set the working directory</h3>
+<p>This is often a major stumbling block for new R users. You need to specify where in your folder structure you wish to work. i.e, where are the files stored that you wish to input?</p>
+<p>This is done using the setwd() function, e.g. setwd(“C:/TreesNetworks/Example Files”).</p>
+<p>We now set it to the folder of the phangorn package, which contains the files we want to load for this example.</p>
+</div>
+<div id="read-in-the-example-file-datasets" class="section level3">
+<h3>Read in the example file datasets:</h3>
+<p>This example files are based on the woodmouse dataset available in the ape library. Ultimately, this dataset is from this study: Michaux, J. R., Magnanou, E., Paradis, E., Nieberding, C. and Libois, R. (2003) Mitochondrial phylogeography of the Woodmouse (<em>Apodemus sylvaticus</em>) in the Western Palearctic region. Molecular Ecology, 12, 685-697.)</p>
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">## automatically set the correct working directory for the examples below
+<span class="co"># setwd(system.file("extdata/trees", package = "phangorn"))</span>
+<span class="co"># for this vignette we create a path to the files we want to load </span>
+fdir <-<span class="st"> </span><span class="kw">system.file</span>(<span class="st">"extdata/trees"</span>, <span class="dt">package =</span> <span class="st">"phangorn"</span>)
+## in your case it may look something like this...
+<span class="co"># setwd("C:/TreesNetworks/Example Files")</span>
+
+##DNA Matrix, maybe not needed 
+woodmouse <-<span class="st"> </span><span class="kw">read.phyDat</span>(<span class="kw">file.path</span>(fdir, <span class="st">"woodmouse.fasta"</span>),<span class="dt">format=</span><span class="st">"fasta"</span>) 
+## RAxML best-known tree with bipartition support (from previous analysis)
+raxml.tree <-<span class="st"> </span><span class="kw">read.tree</span>(<span class="kw">file.path</span>(fdir,<span class="st">"RAxML_bipartitions.woodmouse"</span>))
+## RAxML bootstrap trees (from previous analysis)
+raxml.bootstrap <-<span class="st"> </span><span class="kw">read.tree</span>(<span class="kw">file.path</span>(fdir,<span class="st">"RAxML_bootstrap.woodmouse"</span>))
+## MrBayes consensus tree (50% majority rule) (from previous analysis)
+mrbayes.tree <-<span class="st"> </span><span class="kw">read.nexus</span>(<span class="kw">file.path</span>(fdir,<span class="st">"woodmouse.mrbayes.nex.con"</span>))
+## MrBayes sample runs 1 and 2 (from previous analysis)
+run1 <-<span class="st"> </span><span class="kw">read.nexus</span>(<span class="kw">file.path</span>(fdir,<span class="st">"woodmouse.mrbayes.nex.run1.t"</span>))
+run2 <-<span class="st"> </span><span class="kw">read.nexus</span>(<span class="kw">file.path</span>(fdir,<span class="st">"woodmouse.mrbayes.nex.run2.t"</span>))
+## How many trees are in the MrBayes tree sample?
+run1</code></pre></div>
+<pre><code>## 1001 phylogenetic trees</code></pre>
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">run2</code></pre></div>
+<pre><code>## 1001 phylogenetic trees</code></pre>
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">## Combining the two runs and removing 25% burn-in
+mrbayes.trees <-<span class="st"> </span><span class="kw">c</span>(run1[<span class="dv">251</span>:<span class="dv">1001</span>],run2[<span class="dv">251</span>:<span class="dv">1001</span>])
+## NeigbourNet Nexus file generated by SplitsTree (from previous analysis)
+Nnet <-<span class="st"> </span><span class="kw">read.nexus.networx</span>(<span class="kw">file.path</span>(fdir,<span class="st">"woodmouse.nxs"</span>))</code></pre></div>
+<p>All example files read into R.</p>
+</div>
+<div id="viewing-the-data" class="section level3">
+<h3>Viewing the data</h3>
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">par</span>(<span class="dt">mfrow=</span><span class="kw">c</span>(<span class="dv">1</span>,<span class="dv">2</span>), <span class="dt">mar=</span><span class="kw">c</span>(<span class="dv">2</span>,<span class="dv">2</span>,<span class="dv">2</span>,<span class="dv">2</span>)) <span class="co"># Setting plot parameters</span>
+### Plotting trees with support values:
+##  RAxML
+<span class="kw">plot</span>(raxml.tree)
+<span class="kw">nodelabels</span>(raxml.tree$node.label, <span class="dt">adj =</span> <span class="kw">c</span>(<span class="dv">1</span>, <span class="dv">0</span>), <span class="dt">frame =</span> <span class="st">"none"</span>)
+##  MrBayes
+<span class="kw">plot</span>(mrbayes.tree)
+<span class="kw">nodelabels</span>(mrbayes.tree$node.label, <span class="dt">adj =</span> <span class="kw">c</span>(<span class="dv">1</span>, <span class="dv">0</span>), <span class="dt">frame =</span> <span class="st">"none"</span>)</code></pre></div>
+<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAKgCAMAAABz4j/3AAAC/VBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZ [...]
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">par</span>(<span class="dt">mfrow=</span><span class="kw">c</span>(<span class="dv">1</span>,<span class="dv">1</span>)) <span class="co"># Setting plot parameters</span>
+<span class="co"># NeighbourNet</span>
+<span class="kw">plot.networx</span>(Nnet,<span class="st">"2D"</span>)</code></pre></div>
+<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAKgCAMAAABz4j/3AAADAFBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZ [...]
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">## alternatively,
+<span class="co"># plot(Nnet,"2D")</span></code></pre></div>
+</div>
+<div id="interwining-trees-and-network-functions" class="section level3">
+<h3>Interwining trees and network functions</h3>
+</div>
+<div id="a" class="section level3">
+<h3>1A:</h3>
+<p>Identification of edge bundles (in black) in a neighbour-net (NN) network that correspond to branches (labelled 1-12) in a tree (a maximum likelihood tree, in this case).</p>
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># create a vector of labels for the network corresponding to edges in the tree</span>
+edge.lab <-<span class="st"> </span><span class="kw">createLabel</span>(Nnet, raxml.tree, raxml.tree$edge[,<span class="dv">2</span>], <span class="st">"edge"</span>)
+<span class="co"># could be also 1:27 instead of raxml.tree$edge[,2]</span>
+
+<span class="co"># Show the correspondingly labelled tree and network in R</span>
+<span class="kw">par</span>(<span class="dt">mfrow=</span><span class="kw">c</span>(<span class="dv">1</span>,<span class="dv">2</span>), <span class="dt">mar=</span><span class="kw">c</span>(<span class="dv">1</span>,<span class="dv">1</span>,<span class="dv">1</span>,<span class="dv">1</span>))
+<span class="co">#plotBS(raxml.tree, rotate.tree = 180) </span>
+<span class="kw">plot</span>(raxml.tree, <span class="st">"u"</span>, <span class="dt">rotate.tree =</span> <span class="dv">180</span>) 
+<span class="kw">edgelabels</span>(raxml.tree$edge[,<span class="dv">2</span>],<span class="dt">col=</span><span class="st">"blue"</span>, <span class="dt">frame=</span><span class="st">"none"</span>)
+
+<span class="co"># find edges that are in the network but not in the tree</span>
+edge.col <-<span class="st"> </span><span class="kw">rep</span>(<span class="st">"black"</span>, <span class="kw">nrow</span>(Nnet$edge))
+edge.col[ <span class="kw">is.na</span>(edge.lab) ] <-<span class="st"> "red"</span>
+<span class="co"># or a simpler alternative...</span>
+edge.col <-<span class="st"> </span><span class="kw">createLabel</span>(Nnet, raxml.tree, <span class="st">"black"</span>, <span class="dt">nomatch=</span><span class="st">"red"</span>)
+
+x <-<span class="st"> </span><span class="kw">plot.networx</span>(Nnet, <span class="dt">edge.label =</span> edge.lab, <span class="dt">show.edge.label =</span> T, <span class="st">"2D"</span>, <span class="dt">edge.color =</span> edge.col,
+                  <span class="dt">col.edge.label =</span> <span class="st">"blue"</span>)</code></pre></div>
+<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAKgCAIAAADLXliSAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAgAElEQVR4nOzdZ1wU194H8P/Qy9KLotSgiIiKImIApYgNkgcEjfeKV6MmMUZNLKhR8QomsYG9BBITE0CU2EvwKpYYNYpA1IgSxYIFQRRBqQK753kxcTKCEqLEleH3/fhi55w9s7Or7m/nzJlzOMYYAQAAgLSoKPsAAAAAoOkh4AEAACQIAQ8AACBBCHgAAAAJQsADAABIEAIeAABAghDwAAAAEoSABwAAkCAEPAAAgAQh4AEAACQIAQ8AACBBCHgAAAAJQsADAABIEAIeAABAghDwAAAAEoSABwAAkCAEPAAAgAQh4AEAACQIAQ8AACBBCHgAAAAJQsADAABIEAIeAABAghDwAAAAEoSABwAAkCAEPAAAgAQh4AEAACQIA [...]
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># the above plot function returns an invisible networx object and this object also  </span>
+<span class="co"># contains the colors for the edges.</span></code></pre></div>
+</div>
+<div id="b" class="section level3">
+<h3>1B:</h3>
+<p>Bootstrap support for all branches (branch labels) in the ML tree mapped on the corresponding edge bundles of the NN network. The edges in the network which are not found as ML tree branches are highlighted in red.</p>
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">x <-<span class="st"> </span><span class="kw">addConfidences</span>(Nnet,raxml.tree)
+<span class="co"># find splits that are in the network but not in the tree</span>
+split.col <-<span class="st"> </span><span class="kw">rep</span>(<span class="st">"black"</span>, <span class="kw">length</span>(x$splits))
+split.col[ !<span class="kw">matchSplits</span>(<span class="kw">as.splits</span>(x), <span class="kw">as.splits</span>(raxml.tree)) ] <-<span class="st"> "red"</span>
+
+<span class="co"># simpler alternative...</span>
+split.col2 <-<span class="st"> </span><span class="kw">createLabel</span>(x, raxml.tree, <span class="dt">label=</span><span class="st">"black"</span>, <span class="st">"split"</span>, <span class="dt">nomatch=</span><span class="st">"red"</span>)
+
+<span class="co"># Plotting in R</span>
+<span class="kw">par</span>(<span class="dt">mfrow=</span><span class="kw">c</span>(<span class="dv">1</span>,<span class="dv">1</span>))
+out.x <-<span class="st"> </span><span class="kw">plot.networx</span>(x,<span class="st">"2D"</span>,<span class="dt">show.edge.label=</span><span class="ot">TRUE</span>, <span class="dt">split.color=</span>split.col, <span class="dt">col.edge.label =</span> <span class="st">"blue"</span>)</code></pre></div>
+<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAKgCAIAAADLXliSAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAgAElEQVR4nOzde1wU9f4/8NcACivLTUABBUUUUDRRREpQQfRY0lFQ03PC9GjnpGQWpubR9CfYQ830KGoX6HL65gWl8JphgpmVZgikJkqKclMugiByF2Hm98fkuIHHLIFdttfz0R877898Zj87j/C1MzvzGUGSJBAREZF+MdD2AIiIiKjlMeCJiIj0EAOeiIhIDzHgiYiI9BADnoiISA8x4ImIiPQQA56IiEgPMeCJiIj0EAOeiIhIDzHgiYiI9BADnoiISA8x4ImIiPQQA56IiEgPMeCJiIj0EAOeiIhIDzHgiYiI9BADnoiISA8x4ImIiPQQA56IiEgPMeCJiIj0EAOeiIhIDzHgiYiI9BADnoiISA8x4ImIiPQQA56Ii [...]
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># write.nexus.networx(out.x,"woodmouse.tree.support.nxs")</span>
+## or we can also export the splits alone (for usage in software other than SplitsTree)
+<span class="co"># write.nexus.splits(as.splits(out.x),"woodmouse.splits.support.nxs")</span></code></pre></div>
+</div>
+<div id="c" class="section level3">
+<h3>1C:</h3>
+<p>Frequencies of bipartitions found in the bootstrap pseudoreplicates mapped on the corresponding edge bundles of the NN network using a threshold of 10% (i.e. any edge is labelled that occurs in at least 100 of the 1000 ML-BS pseudoreplicates). Edge bundles not found in the ML tree are labelled using grey edges.</p>
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">y <-<span class="st"> </span><span class="kw">addConfidences</span>(Nnet, <span class="kw">as.splits</span>(raxml.bootstrap))
+edge.col <-<span class="st"> </span><span class="kw">createLabel</span>(y, raxml.tree, <span class="dt">label=</span><span class="st">"black"</span>, <span class="st">"edge"</span>, <span class="dt">nomatch=</span><span class="st">"grey"</span>)
+
+y <-<span class="st"> </span><span class="kw">plot</span>(y,<span class="st">"2D"</span>,<span class="dt">show.edge.label=</span><span class="ot">TRUE</span>, <span class="dt">edge.color=</span>edge.col)</code></pre></div>
+<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAKgCAMAAABz4j/3AAADAFBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZ [...]
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">## Write to SplitsTree for viewing
+<span class="co"># write.nexus.networx(y,"NN.with.bs.support.nxs")</span></code></pre></div>
+</div>
+<div id="extras" class="section level3">
+<h3>Extras…</h3>
+<p>We can also compare the neighborNet with a consensusNet (Holland BR, Huber KT, Moulton V, Lockhart PJ,2004, Using consensus networks to visualize contradictory evidence for species phylogeny. Molecular Biology and Evolution, 21, 1459-1461). Furthermore, we can extract the support values from the consensus network, and place these on to the NeighbourNet (this is similar to the process explained in 1C above).</p>
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">cnet <-<span class="st"> </span><span class="kw">consensusNet</span>(raxml.bootstrap,<span class="dt">prob=</span><span class="fl">0.10</span>)
+edge.col <-<span class="st"> </span><span class="kw">createLabel</span>(cnet, Nnet, <span class="dt">label=</span><span class="st">"black"</span>, <span class="st">"edge"</span>, <span class="dt">nomatch=</span><span class="st">"grey"</span>)
+cnet <-<span class="st"> </span><span class="kw">plot.networx</span>(cnet, <span class="st">"2D"</span>, <span class="dt">show.edge.label =</span> <span class="ot">TRUE</span>, <span class="dt">edge.color=</span>edge.col)</code></pre></div>
+<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAKgCAMAAABz4j/3AAADAFBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZ [...]
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">edge.col <-<span class="st"> </span><span class="kw">createLabel</span>(Nnet, cnet, <span class="dt">label=</span><span class="st">"black"</span>, <span class="st">"edge"</span>, <span class="dt">nomatch=</span><span class="st">"grey"</span>)
+z <-<span class="st"> </span><span class="kw">plot.networx</span>(Nnet, <span class="st">"2D"</span>, <span class="dt">show.edge.label =</span> <span class="ot">TRUE</span>, <span class="dt">edge.color=</span>edge.col)</code></pre></div>
+<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAKgCAMAAABz4j/3AAADAFBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZ [...]
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">obj <-<span class="st"> </span><span class="kw">addConfidences</span>(Nnet,cnet)
+<span class="kw">plot.networx</span>(obj,<span class="st">"2D"</span>,<span class="dt">show.edge.label=</span>T, <span class="dt">edge.color=</span>edge.col, <span class="dt">col.edge.label =</span> <span class="st">"blue"</span>)</code></pre></div>
+<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAKgCAIAAADLXliSAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAgAElEQVR4nOzdeVQUV8I28KcBhZZmE1BQaUUUUDAiiKiggppXI5mISzQZTRzNosaYYNzi9gqZ4+4oamLETN58cUGIuI6SCMYYE+NANxpHjAsugLKIgsjSINBd3x+lZQvGOBHppn1+x3PSfW/d27frRJ+uqlu3ZIIggIiIiEyLmaEHQERERA2PAU9ERGSCGPBEREQmiAFPRERkghjwREREJogBT0REZIIY8ERERCaIAU9ERGSCGPBEREQmiAFPRERkghjwREREJogBT0REZIIY8ERERCaIAU9ERGSCGPBEREQmiAFPRERkghjwREREJogBT0REZIIY8ERERCaIAU9ERGSCGPBEREQmiAFPRERkghjwREREJogBT0REZIIY8 [...]
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">## Write to SplitsTree for viewing
+<span class="co"># write.nexus.networx(obj,"Nnet.with.ML.Cnet.Bootstrap.nxs")</span></code></pre></div>
+</div>
+
+
+
+<!-- dynamically load mathjax for compatibility with self-contained -->
+<script>
+  (function () {
+    var script = document.createElement("script");
+    script.type = "text/javascript";
+    script.src  = "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
+    document.getElementsByTagName("head")[0].appendChild(script);
+  })();
+</script>
+
+</body>
+</html>
diff --git a/inst/doc/Networx.R b/inst/doc/Networx.R
index dcd4933..c510d99 100644
--- a/inst/doc/Networx.R
+++ b/inst/doc/Networx.R
@@ -8,7 +8,7 @@ set.seed(1)
 bs <- bootstrap.phyDat(yeast, FUN = function(x)nj(dist.hamming(x)), 
     bs=100)
 tree <- nj(dist.hamming(yeast))
-par("mar" = rep(2, 4))
+par("mar" = rep(1, 4))
 tree <- plotBS(tree, bs, "phylogram")
 cnet <- consensusNet(bs, .3)
 plot(cnet, "2D", show.edge.label=TRUE)
@@ -23,22 +23,23 @@ plot(cnet, "2D", show.edge.label=TRUE)
 ## ---- eval=TRUE----------------------------------------------------------
 dm <- dist.hamming(yeast)
 nnet <- neighborNet(dm)
-par("mar" = rep(2, 4))
+par("mar" = rep(1, 4))
 plot(nnet, "2D")
 
 ## ---- eval=TRUE----------------------------------------------------------
 nnet <- addConfidences(nnet, tree)
-par("mar" = rep(2, 4))
+par("mar" = rep(1, 4))
 plot(nnet, "2D", show.edge.label=TRUE)
 
 ## ---- eval=TRUE----------------------------------------------------------
 tree2 <- rNNI(tree, 2)
 tree2 <- addConfidences(tree2, tree)
 # several support values are missing
+par("mar" = rep(1, 4))
 plot(tree2, show.node.label=TRUE)
 
 ## ---- eval=TRUE----------------------------------------------------------
 cnet <- nnls.networx(cnet, dm)
-par("mar" = rep(2, 4))
+par("mar" = rep(1, 4))
 plot(cnet, "2D", show.edge.label=TRUE)
 
diff --git a/inst/doc/Networx.Rmd b/inst/doc/Networx.Rmd
index 4086c5a..129ba78 100644
--- a/inst/doc/Networx.Rmd
+++ b/inst/doc/Networx.Rmd
@@ -11,10 +11,10 @@ vignette: >
 ---
 
 
-This tutorial gives a basic introduction on constructing phylogenetic networks and to add parameter to trees or networx using [phangorn](http://cran.r-project.org/package=phangorn) [@Schliep2011] in R. 
-Splits graph or phylogenetic networks are a nice way to display conflict data or summarize different trees. Here we present to popular networks, consensus networks [@Holland2004]
-and neighborNet [@Bryant2004].                                  
-Often trees or networks are missing either edge weights or support values about the edges. We show how to improve a tree/networx by adding support values or estimating edge weights using non-negative Least-Squares (nnls).
+This tutorial gives a basic introduction for constructing phylogenetic networks and adding parameters to trees or networx objects using [phangorn](http://cran.r-project.org/package=phangorn) [@Schliep2011] in R. 
+Splits graphs or phylogenetic networks are a useful way to display conflicting data or to summarize different trees. Here, we present two popular networks, consensus networks [@Holland2004]
+and Neighbor-Net [@Bryant2004].                                  
+Trees or networks are often missing either edge weights or edge support values. We show how to improve a tree/networx object by adding support values or estimating edge weights using non-negative Least-Squares (nnls).
 
 We first load the phangorn package and a few data sets we use in this vignette.
 ```{r, eval=TRUE}
@@ -23,21 +23,21 @@ data(Laurasiatherian)
 data(yeast)
 ```
 ## consensusNet
-A consensusNet [@Holland2004] is a generalization of a consensus tree. Instead only representing splits with at least 50% in a bootstrap or MCMC sample one can use a lower threshold. However of important competing splits are left out. 
+A consensusNet [@Holland2004] is a generalization of a consensus tree. Instead of only representing splits (taxon bipartitions) occurring in at least 50% of the trees in a bootstrap or MCMC sample one can use a lower threshold and explore competing splits. Note that, in its basic implementation used here, the consensusNet edge lengths are proportional to the frequence of the corresponding splits in the provided list of trees. 
 
-The input for `consensusNet` is  a list of trees i.e. an object of class `multiPhylo`.
+The input for `consensusNet` is a list of trees i.e. an object of class `multiPhylo`.
 ```{r, eval=TRUE}
 set.seed(1)
 bs <- bootstrap.phyDat(yeast, FUN = function(x)nj(dist.hamming(x)), 
     bs=100)
 tree <- nj(dist.hamming(yeast))
-par("mar" = rep(2, 4))
+par("mar" = rep(1, 4))
 tree <- plotBS(tree, bs, "phylogram")
 cnet <- consensusNet(bs, .3)
 plot(cnet, "2D", show.edge.label=TRUE)
 ```
 
-Often `consensusNet` will return incompatible splits, which cannot plotted as a planar graph. A nice way to  get still a good impression of the network is to plot it in 3 dimensions. 
+In many cases, `consensusNet` will return more than two incompatible (competing) splits. This cannot be plotted as a planar (2-dimensional) graph. Such as situation requires a n-dimensional graph, where the maximum number of dimensions equals the maximum number of incompatible splits. For example, if we have three alternative incompatible splits: (A,B)|(C,D) vs. (A,C)|(B,D) vs. (A,D)|(B,C), we need a 3-dimensional graph to show all three alternatives. A nice way to get still a good impre [...]
 
 ```{r, eval=FALSE}
 plot(cnet)
@@ -53,44 +53,50 @@ which will result in a spinning graph similar to this
 
 
 ## neighborNet
-The function `neighborNet` implements the popular method of @Bryant2004. The  Neighbor-Net algorithm extends the Neighbor joining allowing again algorithm is computed in 2 parts, the first computes a circular ordering. The second step involves estimation of edge weights using non-negative Least-Squares (nnls).    
+The function `neighborNet` implements the popular method of @Bryant2004. The Neighbor-Net algorithm is essentially a 2D-version of the Neighbor joining algorithm. The Neighbour-net is computed in two steps: the first computes a circular ordering of the taxa in the data set; the second step involves the estimation of edge weights using non-negative Least-Squares (nnls).    
 
 ```{r, eval=TRUE}
 dm <- dist.hamming(yeast)
 nnet <- neighborNet(dm)
-par("mar" = rep(2, 4))
+par("mar" = rep(1, 4))
 plot(nnet, "2D")
 ```
 
-The advantage of Neighbor-Net is that it returns a circular split system which can be always displayed in a planar (2D) graph. The plots displayed in `phangorn` may not planar, but re-plotting may gives you a planar graph. This unwanted behavior will be improved in future version. 
+The advantage of Neighbor-Net is that it returns a circular split system which can be always displayed in a planar (2D) graph. The plots displayed in `phangorn` may (however) not be planar, but re-plotting can give you a planar graph. This unwanted behavior will be improved in future version. 
 The rendering of the `networx` is done using the the fantastic igraph package [@Csardi2006]. 
 
 
 ## Adding support values
 
-We can use the generic function `addConfidences` to add support values from a tree, i.e. an object of class `phylo` to a `networx`, `splits` or `phylo` object. The Neighbor-Net object we computed above contains no support values. We can add the support values fro  the tree we computed to the splits these two objects share. 
+We can use the generic function `addConfidences` to add (branch) support values from a tree, i.e. an object of class `phylo` to a `networx`, `splits` or `phylo` object. The Neighbor-Net object we computed above provides no support values. We can add the support values from the tree we computed to the splits (edges) shared by both objects. 
 ```{r, eval=TRUE}
 nnet <- addConfidences(nnet, tree)
-par("mar" = rep(2, 4))
+par("mar" = rep(1, 4))
 plot(nnet, "2D", show.edge.label=TRUE)
 ```    
 
-We can also add support values to a tree:
+Analogously, we can also add support values to a tree:
 ```{r, eval=TRUE}
 tree2 <- rNNI(tree, 2)
 tree2 <- addConfidences(tree2, tree)
 # several support values are missing
+par("mar" = rep(1, 4))
 plot(tree2, show.node.label=TRUE)
 ```   
 
 ## Estimating edge weights (nnls)
 
-Consensus networks on the other hand have information about support values corresponding to a split, but are generally without edge weights. 
-Given a distance matrix we can estimate edge weights using non-negative Least-Squares. 
+Consensus networks, on the other hand, provide primarily information about support values corresponding to a split, but no information about the actual difference between the taxon bipartitions defined by that split. For example, one may be interested how the alternative support values correspond with the actual genetic distance between the involved taxa.
+Given a distance matrix, we can estimate edge weights using non-negative Least-Squares, and plot them onto the consensusNet splits graph. 
 ```{r, eval=TRUE}
 cnet <- nnls.networx(cnet, dm)
-par("mar" = rep(2, 4))
+par("mar" = rep(1, 4))
 plot(cnet, "2D", show.edge.label=TRUE)
 ```
     
+    
+### Import and export networks, advanced functions for networx objects 
+
+The functions `read.nexus.networx` and `write.nexus.networx` can read and write nexus files for or from SplitsTree [@Huson2006]. Check-out the new vignette IntertwiningTreesAndNetworks for additional functions, examples, and advanced applications. 
+
 ## References
diff --git a/inst/doc/Networx.html b/inst/doc/Networx.html
index a589175..21e1b4a 100644
--- a/inst/doc/Networx.html
+++ b/inst/doc/Networx.html
@@ -8,9 +8,11 @@
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <meta name="generator" content="pandoc" />
 
+<meta name="viewport" content="width=device-width, initial-scale=1">
+
 <meta name="author" content="Klaus Schliep" />
 
-<meta name="date" content="2015-02-13" />
+<meta name="date" content="2016-06-20" />
 
 <title>Splits and Networx</title>
 
@@ -18,32 +20,46 @@
 
 <style type="text/css">code{white-space: pre;}</style>
 <style type="text/css">
+div.sourceCode { overflow-x: auto; }
 table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
   margin: 0; padding: 0; vertical-align: baseline; border: none; }
 table.sourceCode { width: 100%; line-height: 100%; }
 td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
 td.sourceCode { padding-left: 5px; }
-code > span.kw { color: #007020; font-weight: bold; }
-code > span.dt { color: #902000; }
-code > span.dv { color: #40a070; }
-code > span.bn { color: #40a070; }
-code > span.fl { color: #40a070; }
-code > span.ch { color: #4070a0; }
-code > span.st { color: #4070a0; }
-code > span.co { color: #60a0b0; font-style: italic; }
-code > span.ot { color: #007020; }
-code > span.al { color: #ff0000; font-weight: bold; }
-code > span.fu { color: #06287e; }
-code > span.er { color: #ff0000; font-weight: bold; }
-</style>
-<style type="text/css">
-  pre:not([class]) {
-    background-color: white;
-  }
+code > span.kw { color: #007020; font-weight: bold; } /* Keyword */
+code > span.dt { color: #902000; } /* DataType */
+code > span.dv { color: #40a070; } /* DecVal */
+code > span.bn { color: #40a070; } /* BaseN */
+code > span.fl { color: #40a070; } /* Float */
+code > span.ch { color: #4070a0; } /* Char */
+code > span.st { color: #4070a0; } /* String */
+code > span.co { color: #60a0b0; font-style: italic; } /* Comment */
+code > span.ot { color: #007020; } /* Other */
+code > span.al { color: #ff0000; font-weight: bold; } /* Alert */
+code > span.fu { color: #06287e; } /* Function */
+code > span.er { color: #ff0000; font-weight: bold; } /* Error */
+code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
+code > span.cn { color: #880000; } /* Constant */
+code > span.sc { color: #4070a0; } /* SpecialChar */
+code > span.vs { color: #4070a0; } /* VerbatimString */
+code > span.ss { color: #bb6688; } /* SpecialString */
+code > span.im { } /* Import */
+code > span.va { color: #19177c; } /* Variable */
+code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
+code > span.op { color: #666666; } /* Operator */
+code > span.bu { } /* BuiltIn */
+code > span.ex { } /* Extension */
+code > span.pp { color: #bc7a00; } /* Preprocessor */
+code > span.at { color: #7d9029; } /* Attribute */
+code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
+code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
+code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
+code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
 </style>
 
 
-<link href="data:text/css,body%20%7B%0A%20%20background%2Dcolor%3A%20%23fff%3B%0A%20%20margin%3A%201em%20auto%3B%0A%20%20max%2Dwidth%3A%20700px%3B%0A%20%20overflow%3A%20visible%3B%0A%20%20padding%2Dleft%3A%202em%3B%0A%20%20padding%2Dright%3A%202em%3B%0A%20%20font%2Dfamily%3A%20%22Open%20Sans%22%2C%20%22Helvetica%20Neue%22%2C%20Helvetica%2C%20Arial%2C%20sans%2Dserif%3B%0A%20%20font%2Dsize%3A%2014px%3B%0A%20%20line%2Dheight%3A%201%2E35%3B%0A%7D%0A%0A%23header%20%7B%0A%20%20text%2Dalign%3A% [...]
+
+<link href="data:text/css;charset=utf-8,body%20%7B%0Abackground%2Dcolor%3A%20%23fff%3B%0Amargin%3A%201em%20auto%3B%0Amax%2Dwidth%3A%20700px%3B%0Aoverflow%3A%20visible%3B%0Apadding%2Dleft%3A%202em%3B%0Apadding%2Dright%3A%202em%3B%0Afont%2Dfamily%3A%20%22Open%20Sans%22%2C%20%22Helvetica%20Neue%22%2C%20Helvetica%2C%20Arial%2C%20sans%2Dserif%3B%0Afont%2Dsize%3A%2014px%3B%0Aline%2Dheight%3A%201%2E35%3B%0A%7D%0A%23header%20%7B%0Atext%2Dalign%3A%20center%3B%0A%7D%0A%23TOC%20%7B%0Aclear%3A%20bot [...]
 
 </head>
 
@@ -51,79 +67,100 @@ code > span.er { color: #ff0000; font-weight: bold; }
 
 
 
-<div id="header">
-<h1 class="title">Splits and Networx</h1>
+
+<h1 class="title toc-ignore">Splits and Networx</h1>
 <h4 class="author"><em>Klaus Schliep</em></h4>
-<h4 class="date"><em>February 13, 2015</em></h4>
-</div>
+<h4 class="date"><em>June 20, 2016</em></h4>
 
 
-<p>This tutorial gives a basic introduction on constructing phylogenetic networks and to add parameter to trees or networx using <a href="http://cran.r-project.org/package=phangorn">phangorn</a> <span class="citation">(Schliep 2011)</span> in R. Splits graph or phylogenetic networks are a nice way to display conflict data or summarize different trees. Here we present to popular networks, consensus networks <span class="citation">(Holland et al. 2004)</span> and neighborNet <span class="c [...]
+
+<p>This tutorial gives a basic introduction for constructing phylogenetic networks and adding parameters to trees or networx objects using <a href="http://cran.r-project.org/package=phangorn">phangorn</a> <span class="citation">(Schliep 2011)</span> in R. Splits graphs or phylogenetic networks are a useful way to display conflicting data or to summarize different trees. Here, we present two popular networks, consensus networks <span class="citation">(Holland et al. 2004)</span> and Neigh [...]
+Trees or networks are often missing either edge weights or edge support values. We show how to improve a tree/networx object by adding support values or estimating edge weights using non-negative Least-Squares (nnls).</p>
 <p>We first load the phangorn package and a few data sets we use in this vignette.</p>
-<pre class="sourceCode r"><code class="sourceCode r"><span class="kw">library</span>(phangorn)</code></pre>
-<pre><code>## Loading required package: ape</code></pre>
-<pre class="sourceCode r"><code class="sourceCode r"><span class="kw">data</span>(Laurasiatherian)
-<span class="kw">data</span>(yeast)</code></pre>
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">library</span>(phangorn)
+<span class="kw">data</span>(Laurasiatherian)
+<span class="kw">data</span>(yeast)</code></pre></div>
 <div id="consensusnet" class="section level2">
 <h2>consensusNet</h2>
-<p>A consensusNet <span class="citation">(Holland et al. 2004)</span> is a generalization of a consensus tree. Instead only representing splits with at least 50% in a bootstrap or MCMC sample one can use a lower threshold. However of important competing splits are left out.</p>
+<p>A consensusNet <span class="citation">(Holland et al. 2004)</span> is a generalization of a consensus tree. Instead of only representing splits (taxon bipartitions) occurring in at least 50% of the trees in a bootstrap or MCMC sample one can use a lower threshold and explore competing splits. Note that, in its basic implementation used here, the consensusNet edge lengths are proportional to the frequence of the corresponding splits in the provided list of trees.</p>
 <p>The input for <code>consensusNet</code> is a list of trees i.e. an object of class <code>multiPhylo</code>.</p>
-<pre class="sourceCode r"><code class="sourceCode r"><span class="kw">set.seed</span>(<span class="dv">1</span>)
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">set.seed</span>(<span class="dv">1</span>)
 bs <-<span class="st"> </span><span class="kw">bootstrap.phyDat</span>(yeast, <span class="dt">FUN =</span> function(x)<span class="kw">nj</span>(<span class="kw">dist.hamming</span>(x)), 
     <span class="dt">bs=</span><span class="dv">100</span>)
 tree <-<span class="st"> </span><span class="kw">nj</span>(<span class="kw">dist.hamming</span>(yeast))
-<span class="kw">par</span>(<span class="st">"mar"</span> =<span class="st"> </span><span class="kw">rep</span>(<span class="dv">2</span>, <span class="dv">4</span>))
-tree <-<span class="st"> </span><span class="kw">plotBS</span>(tree, bs, <span class="st">"phylogram"</span>)</code></pre>
-<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASAAAAEgCAMAAAAjXV6yAAAC/VBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZ [...]
-<pre class="sourceCode r"><code class="sourceCode r">cnet <-<span class="st"> </span><span class="kw">consensusNet</span>(bs, .<span class="dv">3</span>)
-<span class="kw">plot</span>(cnet, <span class="st">"2D"</span>, <span class="dt">show.edge.label=</span><span class="ot">TRUE</span>)</code></pre>
-<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASAAAAEgCAIAAACb4TnXAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAgAElEQVR4nO2deVxTV/r/PzcBQkgCIbLJEpRFNpFFFAW1LnU6Y1fr1r3T1qpt1WrHWnVal7E/W8dp7eJ0rJ06tbNY2zp1+da2YrF2qChhcUEQAVllJ6wJIcs9vz9umgACboRAct6vvvq6uc9NODfy4Zz7nGdhCCGgUCiWgWftAVAotgwVGIViQajAKBQLQgVGoVgQKjAKxYJQgVEoFoQKjEKxIFRgFIoFoQKjUCwIFRiFYkGowCgUC0IFRqFYECowCsWCUIFRKBaECoxCsSBUYBSKBaECo1AsCBUYhWJBqMAoFAtCBUahWBAqMArFglCBUSgWhAqMQrEgVGAUigWhAqNQLAgVGIViQajAKBQLQgVGoVgQKjAKxYJQgVEoF [...]
-<p>Often <code>consensusNet</code> will return incompatible splits, which cannot plotted as a planar graph. A nice way to get still a good impression of the network is to plot it in 3 dimensions.</p>
-<pre class="sourceCode r"><code class="sourceCode r"><span class="kw">plot</span>(cnet)
+<span class="kw">par</span>(<span class="st">"mar"</span> =<span class="st"> </span><span class="kw">rep</span>(<span class="dv">1</span>, <span class="dv">4</span>))
+tree <-<span class="st"> </span><span class="kw">plotBS</span>(tree, bs, <span class="st">"phylogram"</span>)</code></pre></div>
+<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASAAAAEgCAMAAAAjXV6yAAAC91BMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZGRlZ [...]
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">cnet <-<span class="st"> </span><span class="kw">consensusNet</span>(bs, .<span class="dv">3</span>)
+<span class="kw">plot</span>(cnet, <span class="st">"2D"</span>, <span class="dt">show.edge.label=</span><span class="ot">TRUE</span>)</code></pre></div>
+<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASAAAAEgCAMAAAAjXV6yAAADAFBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZ [...]
+<p>In many cases, <code>consensusNet</code> will return more than two incompatible (competing) splits. This cannot be plotted as a planar (2-dimensional) graph. Such as situation requires a n-dimensional graph, where the maximum number of dimensions equals the maximum number of incompatible splits. For example, if we have three alternative incompatible splits: (A,B)|(C,D) vs. (A,C)|(B,D) vs. (A,D)|(B,C), we need a 3-dimensional graph to show all three alternatives. A nice way to get stil [...]
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">plot</span>(cnet)
 <span class="co"># rotate 3d plot</span>
 <span class="kw">play3d</span>(<span class="kw">spin3d</span>(<span class="dt">axis=</span><span class="kw">c</span>(<span class="dv">0</span>,<span class="dv">1</span>,<span class="dv">0</span>), <span class="dt">rpm=</span><span class="dv">6</span>), <span class="dt">duration=</span><span class="dv">10</span>)
 <span class="co"># create animated gif file </span>
-<span class="kw">movie3d</span>(<span class="kw">spin3d</span>(<span class="dt">axis=</span><span class="kw">c</span>(<span class="dv">0</span>,<span class="dv">1</span>,<span class="dv">0</span>), <span class="dt">rpm=</span><span class="dv">6</span>), <span class="dt">duration=</span><span class="dv">10</span>)</code></pre>
+<span class="kw">movie3d</span>(<span class="kw">spin3d</span>(<span class="dt">axis=</span><span class="kw">c</span>(<span class="dv">0</span>,<span class="dv">1</span>,<span class="dv">0</span>), <span class="dt">rpm=</span><span class="dv">6</span>), <span class="dt">duration=</span><span class="dv">10</span>)</code></pre></div>
 <p>which will result in a spinning graph similar to this</p>
-<p><img src="data:image/gif;base64,R0lGODlhAAEAAfQQAAAA/xgY9y8v719f3nd31kdH576+vo6OzqamxsbGxs7OztbW1t7e3ufn5+/v7/f39////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAKAAAAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAAAEAAQAF/iAkjmRpnmiqrmzrvnAsz3Rt33iu73zv/8CgcEgsGo/IpHLJbDqf0Kh0Sq1ar9isdsvter/gsHhMLpvP6LR6zW673/C4fE6v2+/4vH7P7/v/gIGCg4SFhoeIiYqLjI2Oj5CRkpOUlZaXmJmam5ydnkIAoaGfmwAlpqSXqKeplqskrwYHBQ8joq+mo619uigBBgYJqLi2r7u8xiIADMAMw7C2x4O9EKbABg3KrNrS08MP18W3q8ndduXDzAYK0Sfl5nXoy [...]
+<div class="figure">
+<img src="data:image/gif;base64,R0lGODlhAAEAAfQQAAAA/xgY9y8v719f3nd31kdH576+vo6OzqamxsbGxs7OztbW1t7e3ufn5+/v7/f39////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAKAAAAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAAAEAAQAF/iAkjmRpnmiqrmzrvnAsz3Rt33iu73zv/8CgcEgsGo/IpHLJbDqf0Kh0Sq1ar9isdsvter/gsHhMLpvP6LR6zW673/C4fE6v2+/4vH7P7/v/gIGCg4SFhoeIiYqLjI2Oj5CRkpOUlZaXmJmam5ydnkIAoaGfmwAlpqSXqKeplqskrwYHBQ8joq+mo619uigBBgYJqLi2r7u8xiIADMAMw7C2x4O9EKbABg3KrNrS08MP18W3q8ndduXDzAYK0Sfl5nXoytfO [...]
+<p class="caption">rotatingNetworx</p>
+</div>
 </div>
 <div id="neighbornet" class="section level2">
 <h2>neighborNet</h2>
-<p>The function <code>neighborNet</code> implements the popular method of <span class="citation">Bryant and Moulton (2004)</span>. The Neighbor-Net algorithm extends the Neighbor joining allowing again algorithm is computed in 2 parts, the first computes a circular ordering. The second step involves estimation of edge weights using non-negative Least-Squares (nnls).</p>
-<pre class="sourceCode r"><code class="sourceCode r">dm <-<span class="st"> </span><span class="kw">dist.hamming</span>(yeast)
+<p>The function <code>neighborNet</code> implements the popular method of <span class="citation">D. Bryant and Moulton (2004)</span>. The Neighbor-Net algorithm is essentially a 2D-version of the Neighbor joining algorithm. The Neighbour-net is computed in two steps: the first computes a circular ordering of the taxa in the data set; the second step involves the estimation of edge weights using non-negative Least-Squares (nnls).</p>
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">dm <-<span class="st"> </span><span class="kw">dist.hamming</span>(yeast)
 nnet <-<span class="st"> </span><span class="kw">neighborNet</span>(dm)
-<span class="kw">par</span>(<span class="st">"mar"</span> =<span class="st"> </span><span class="kw">rep</span>(<span class="dv">2</span>, <span class="dv">4</span>))
-<span class="kw">plot</span>(nnet, <span class="st">"2D"</span>)</code></pre>
-<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASAAAAEgCAIAAACb4TnXAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAgAElEQVR4nO3de3hTZZ4H8O9J0vSS9EKBNr0CvSVp2hQKtChVlBEdH0dHxcuIAyPsirgrio7r42V0YJzxMuyj464+42XUdZx9fHCHFZwFV0BEt0yBNIW2ofcKhdL7Lb2mSZuzf5xwmqb3yzmnTX6fxz84J036pvbb8+Z33gvDsiwIIcKQSd0AQrwZBYwQAVHACBEQBYwQAVHACBEQBYwQAVHACBEQBYwQAVHACBEQBYwQAVHACBEQBYwQAVHACBEQBYwQAVHACBEQBYwQAVHACBEQBYwQAVHACBEQBYwQAVHACBEQBYwQAVHACBEQBYwQAVHACBEQBYwQAVHACBEQBYwQAVHACBEQBYwQAVHACBEQBYwQAVHACBEQBYwQA [...]
-<p>The advantage of Neighbor-Net is that it returns a circular split system which can be always displayed in a planar (2D) graph. The plots displayed in <code>phangorn</code> may not planar, but re-plotting may gives you a planar graph. This unwanted behavior will be improved in future version. The rendering of the <code>networx</code> is done using the the fantastic igraph package <span class="citation">(Csardi and Nepusz 2006)</span>.</p>
+<span class="kw">par</span>(<span class="st">"mar"</span> =<span class="st"> </span><span class="kw">rep</span>(<span class="dv">1</span>, <span class="dv">4</span>))
+<span class="kw">plot</span>(nnet, <span class="st">"2D"</span>)</code></pre></div>
+<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASAAAAEgCAMAAAAjXV6yAAAC+lBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZ [...]
+<p>The advantage of Neighbor-Net is that it returns a circular split system which can be always displayed in a planar (2D) graph. The plots displayed in <code>phangorn</code> may (however) not be planar, but re-plotting can give you a planar graph. This unwanted behavior will be improved in future version. The rendering of the <code>networx</code> is done using the the fantastic igraph package <span class="citation">(Csardi and Nepusz 2006)</span>.</p>
 </div>
 <div id="adding-support-values" class="section level2">
 <h2>Adding support values</h2>
-<p>We can use the generic function <code>addConfidences</code> to add support values from a tree, i.e. an object of class <code>phylo</code> to a <code>networx</code>, <code>splits</code> or <code>phylo</code> object. The Neighbor-Net object we computed above contains no support values. We can add the support values fro the tree we computed to the splits these two objects share.</p>
-<pre class="sourceCode r"><code class="sourceCode r">nnet <-<span class="st"> </span><span class="kw">addConfidences</span>(nnet, tree)
-<span class="kw">par</span>(<span class="st">"mar"</span> =<span class="st"> </span><span class="kw">rep</span>(<span class="dv">2</span>, <span class="dv">4</span>))
-<span class="kw">plot</span>(nnet, <span class="st">"2D"</span>, <span class="dt">show.edge.label=</span><span class="ot">TRUE</span>)</code></pre>
-<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASAAAAEgCAIAAACb4TnXAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAgAElEQVR4nO3deXhU1f0/8PedLZlMlsmEkJUEEiAJSUgMhFiTgmBRqcojWrFqRaEswk+sS2ur1gr1cW9FvmoLPH7d+kW+WHwMfisoYBCFsEzCZlYCZCUbCdm3ycx8fn/c6yQB2ULu3Jnk83r44+aemcm5A2/uveece45ARGCMyUOldAUYG844YIzJiAPGmIw4YIzJiAPGmIw4YIzJiAPGmIw4YIzJiAPGmIw4YIzJiAPGmIw4YIzJiAPGmIw4YIzJiAPGmIw4YIzJiAPGmIw4YIzJiAPGmIw4YIzJiAPGmIw4YIzJiAPGmIw4YIzJiAPGmIw4YIzJiAPGmIw4YIzJiAPGmIw4YIzJiAPGmIw4YIzJiAPGmIw4YIzJiAPGm [...]
-<p>We can also add support values to a tree:</p>
-<pre class="sourceCode r"><code class="sourceCode r">tree2 <-<span class="st"> </span><span class="kw">rNNI</span>(tree, <span class="dv">2</span>)
+<p>We can use the generic function <code>addConfidences</code> to add (branch) support values from a tree, i.e. an object of class <code>phylo</code> to a <code>networx</code>, <code>splits</code> or <code>phylo</code> object. The Neighbor-Net object we computed above provides no support values. We can add the support values from the tree we computed to the splits (edges) shared by both objects.</p>
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">nnet <-<span class="st"> </span><span class="kw">addConfidences</span>(nnet, tree)
+<span class="kw">par</span>(<span class="st">"mar"</span> =<span class="st"> </span><span class="kw">rep</span>(<span class="dv">1</span>, <span class="dv">4</span>))
+<span class="kw">plot</span>(nnet, <span class="st">"2D"</span>, <span class="dt">show.edge.label=</span><span class="ot">TRUE</span>)</code></pre></div>
+<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASAAAAEgCAMAAAAjXV6yAAADAFBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZ [...]
+<p>Analogously, we can also add support values to a tree:</p>
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">tree2 <-<span class="st"> </span><span class="kw">rNNI</span>(tree, <span class="dv">2</span>)
 tree2 <-<span class="st"> </span><span class="kw">addConfidences</span>(tree2, tree)
 <span class="co"># several support values are missing</span>
-<span class="kw">plot</span>(tree2, <span class="dt">show.node.label=</span><span class="ot">TRUE</span>)</code></pre>
-<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASAAAAEgCAMAAAAjXV6yAAAC61BMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJERERFRUVGRkZISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJkZGRlZWVmZmZnZ [...]
+<span class="kw">par</span>(<span class="st">"mar"</span> =<span class="st"> </span><span class="kw">rep</span>(<span class="dv">1</span>, <span class="dv">4</span>))
+<span class="kw">plot</span>(tree2, <span class="dt">show.node.label=</span><span class="ot">TRUE</span>)</code></pre></div>
+<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASAAAAEgCAMAAAAjXV6yAAAC61BMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw+Pj4/Pz9AQEBBQUFCQkJERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZGRlZWVnZ [...]
 </div>
 <div id="estimating-edge-weights-nnls" class="section level2">
 <h2>Estimating edge weights (nnls)</h2>
-<p>Consensus networks on the other hand have information about support values corresponding to a split, but are generally without edge weights. Given a distance matrix we can estimate edge weights using non-negative Least-Squares.</p>
-<pre class="sourceCode r"><code class="sourceCode r">cnet <-<span class="st"> </span><span class="kw">nnls.networx</span>(cnet, dm)
-<span class="kw">par</span>(<span class="st">"mar"</span> =<span class="st"> </span><span class="kw">rep</span>(<span class="dv">2</span>, <span class="dv">4</span>))
-<span class="kw">plot</span>(cnet, <span class="st">"2D"</span>, <span class="dt">show.edge.label=</span><span class="ot">TRUE</span>)</code></pre>
-<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASAAAAEgCAIAAACb4TnXAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAgAElEQVR4nO3deVhU59k/8O+ZGRhmhmEH2RERARFBXLBCjCYmGlOXGKPZtDVJK3nT5I1JaqNtjTZt2jS9YrNr2iymSayNeYPJW/NGE6P94RIHUBAXXAHZZV8GZr1/f5xxZkBARQ6DcH+u/MHMc2Y4g/nOOec59/M8AhGBMSYNmat3gLGhjAPGmIQ4YIxJiAPGmIQ4YIxJiAPGmIQ4YIxJiAPGmIQ4YIxJiAPGmIQ4YIxJiAPGmIQ4YIxJiAPGmIQ4YIxJiAPGmIQ4YIxJiAPGmIQ4YIxJiAPGmIQ4YIxJiAPGmIQ4YIxJiAPGmIQ4YIxJiAPGmIQ4YIxJiAPGmIQ4YIxJiAPGmIQ4YIxJiAPGmIQ4YIxJiAPGmIQ4YIxJi [...]
-<div class="references">
+<p>Consensus networks, on the other hand, provide primarily information about support values corresponding to a split, but no information about the actual difference between the taxon bipartitions defined by that split. For example, one may be interested how the alternative support values correspond with the actual genetic distance between the involved taxa. Given a distance matrix, we can estimate edge weights using non-negative Least-Squares, and plot them onto the consensusNet splits  [...]
+<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">cnet <-<span class="st"> </span><span class="kw">nnls.networx</span>(cnet, dm)
+<span class="kw">par</span>(<span class="st">"mar"</span> =<span class="st"> </span><span class="kw">rep</span>(<span class="dv">1</span>, <span class="dv">4</span>))
+<span class="kw">plot</span>(cnet, <span class="st">"2D"</span>, <span class="dt">show.edge.label=</span><span class="ot">TRUE</span>)</code></pre></div>
+<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASAAAAEgCAMAAAAjXV6yAAADAFBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZ [...]
+<div id="import-and-export-networks-advanced-functions-for-networx-objects" class="section level3">
+<h3>Import and export networks, advanced functions for networx objects</h3>
+<p>The functions <code>read.nexus.networx</code> and <code>write.nexus.networx</code> can read and write nexus files for or from SplitsTree <span class="citation">(Huson and Bryant 2006)</span>. Check-out the new vignette IntertwiningTreesAndNetworks for additional functions, examples, and advanced applications.</p>
+</div>
+</div>
+<div id="references" class="section level2 unnumbered">
 <h2>References</h2>
-<p>Bryant, David, and Vincent Moulton. 2004. “Neighbor-Net: An Agglomerative Method for the Construction of Phylogenetic Networks.” <em>Molecular Biology and Evolution</em> 21 (2): 255–65. doi:<a href="http://dx.doi.org/10.1093/molbev/msh018">10.1093/molbev/msh018</a>. <a href="http://mbe.oxfordjournals.org/content/21/2/255.abstract">http://mbe.oxfordjournals.org/content/21/2/255.abstract</a>.</p>
-<p>Csardi, Gabor, and Tamas Nepusz. 2006. “The Igraph Software Package for Complex Network Research.” <em>InterJournal</em> Complex Systems: 1695. <a href="http://igraph.org">http://igraph.org</a>.</p>
-<p>Holland, Barbara R., Katharina T. Huber, Vincent Moulton, and Peter J. Lockhart. 2004. “Using Consensus Networks to Visualize Contradictory Evidence for Species Phylogeny.” <em>Molecular Biology and Evolution</em> 21 (7): 1459–61. doi:<a href="http://dx.doi.org/10.1093/molbev/msh145">10.1093/molbev/msh145</a>. <a href="http://mbe.oxfordjournals.org/content/21/7/1459.abstract">http://mbe.oxfordjournals.org/content/21/7/1459.abstract</a>.</p>
-<p>Schliep, Klaus Peter. 2011. “phangorn: Phylogenetic Analysis in R.” <em>Bioinformatics</em> 27 (4): 592–93. doi:<a href="http://dx.doi.org/10.1093/bioinformatics/btq706">10.1093/bioinformatics/btq706</a>. <a href="http://bioinformatics.oxfordjournals.org/content/27/4/592.abstract">http://bioinformatics.oxfordjournals.org/content/27/4/592.abstract</a>.</p>
+<div id="refs" class="references">
+<div id="ref-Bryant2004">
+<p>Bryant, David, and Vincent Moulton. 2004. “Neighbor-Net: An Agglomerative Method for the Construction of Phylogenetic Networks.” <em>Molecular Biology and Evolution</em> 21 (2): 255–65. doi:<a href="https://doi.org/10.1093/molbev/msh018">10.1093/molbev/msh018</a>.</p>
+</div>
+<div id="ref-Csardi2006">
+<p>Csardi, Gabor, and Tamas Nepusz. 2006. “The Igraph Software Package for Complex Network Research.” <em>InterJournal</em> Complex Systems: 1695. <a href="http://igraph.org" class="uri">http://igraph.org</a>.</p>
+</div>
+<div id="ref-Holland2004">
+<p>Holland, Barbara R., Katharina T. Huber, Vincent Moulton, and Peter J. Lockhart. 2004. “Using Consensus Networks to Visualize Contradictory Evidence for Species Phylogeny.” <em>Molecular Biology and Evolution</em> 21 (7): 1459–61. doi:<a href="https://doi.org/10.1093/molbev/msh145">10.1093/molbev/msh145</a>.</p>
+</div>
+<div id="ref-Huson2006">
+<p>Huson, D.H., and D. Bryant. 2006. “Application of Phylogenetic Networks in Evolutionary Studies.” <em>Molecular Biology and Evolution</em> 23 (2): 254–67.</p>
+</div>
+<div id="ref-Schliep2011">
+<p>Schliep, Klaus Peter. 2011. “Phangorn: Phylogenetic Analysis in R.” <em>Bioinformatics</em> 27 (4): 592–93. doi:<a href="https://doi.org/10.1093/bioinformatics/btq706">10.1093/bioinformatics/btq706</a>.</p>
+</div>
 </div>
 </div>
 
diff --git a/inst/doc/Trees.R b/inst/doc/Trees.R
index 7bb7665..bfac4da 100644
--- a/inst/doc/Trees.R
+++ b/inst/doc/Trees.R
@@ -1,32 +1,34 @@
 ### R code from vignette source 'Trees.Rnw'
 
 ###################################################
-### code chunk number 1: Trees.Rnw:48-50
+### code chunk number 1: Trees.Rnw:49-52
 ###################################################
 options(width=70)
 foo <- packageDescription("phangorn")
+options("show.signif.stars" = FALSE)
 
 
 ###################################################
-### code chunk number 2: Trees.Rnw:66-68
+### code chunk number 2: Trees.Rnw:68-71
 ###################################################
 library(phangorn)
-primates = read.phyDat("primates.dna", format="phylip", type="DNA")
+primates <- read.phyDat("primates.dna", format="phylip", 
+    type="DNA")
 
 
 ###################################################
-### code chunk number 3: Trees.Rnw:75-78
+### code chunk number 3: Trees.Rnw:77-80
 ###################################################
-dm = dist.ml(primates)
-treeUPGMA = upgma(dm)
-treeNJ = NJ(dm)
+dm  <- dist.ml(primates)
+treeUPGMA  <- upgma(dm)
+treeNJ  <- NJ(dm)
 
 
 ###################################################
 ### code chunk number 4: plotNJ
 ###################################################
 layout(matrix(c(1,2), 2, 1), height=c(1,2))
-par(mar = c(.1,.1,.1,.1))
+par(mar = c(0,0,2,0)+ 0.1)
 plot(treeUPGMA, main="UPGMA")
 plot(treeNJ, "unrooted", main="NJ")
 
@@ -36,101 +38,111 @@ plot(treeNJ, "unrooted", main="NJ")
 ###################################################
 getOption("SweaveHooks")[["fig"]]()
 layout(matrix(c(1,2), 2, 1), height=c(1,2))
-par(mar = c(.1,.1,.1,.1))
+par(mar = c(0,0,2,0)+ 0.1)
 plot(treeUPGMA, main="UPGMA")
 plot(treeNJ, "unrooted", main="NJ")
 
 
 ###################################################
-### code chunk number 6: Trees.Rnw:100-102
+### code chunk number 6: Trees.Rnw:102-104
 ###################################################
 parsimony(treeUPGMA, primates)
 parsimony(treeNJ, primates)
 
 
 ###################################################
-### code chunk number 7: Trees.Rnw:105-108
+### code chunk number 7: Trees.Rnw:107-110
 ###################################################
-treePars = optim.parsimony(treeUPGMA, primates)
-treeRatchet = pratchet(primates, trace = 0)
+treePars  <- optim.parsimony(treeUPGMA, primates)
+treeRatchet  <- pratchet(primates, trace = 0)
 parsimony(c(treePars, treeRatchet), primates)
 
 
 ###################################################
-### code chunk number 8: Trees.Rnw:111-112 (eval = FALSE)
+### code chunk number 8: Trees.Rnw:113-114 (eval = FALSE)
 ###################################################
 ## (trees <- bab(subset(primates,1:10)))
 
 
 ###################################################
-### code chunk number 9: Trees.Rnw:118-120
+### code chunk number 9: Trees.Rnw:120-122
 ###################################################
 fit = pml(treeNJ, data=primates)
 fit
 
 
 ###################################################
-### code chunk number 10: Trees.Rnw:123-124
+### code chunk number 10: Trees.Rnw:125-126
 ###################################################
 methods(class="pml")
 
 
 ###################################################
-### code chunk number 11: Trees.Rnw:127-129
+### code chunk number 11: Trees.Rnw:129-131
 ###################################################
-fitJC = optim.pml(fit, TRUE)
+fitJC  <- optim.pml(fit, TRUE)
 logLik(fitJC)
 
 
 ###################################################
-### code chunk number 12: Trees.Rnw:132-136
+### code chunk number 12: Trees.Rnw:134-138
 ###################################################
-fitGTR = update(fit, k=4, inv=0.2) 
-fitGTR = optim.pml(fitGTR, TRUE,TRUE, TRUE, TRUE, TRUE, 
-    control = pml.control(trace = 0))
+fitGTR <- update(fit, k=4, inv=0.2) 
+fitGTR <- optim.pml(fitGTR, model="GTR", optInv=TRUE, optGamma=TRUE, 
+    rearrangement = "NNI", control = pml.control(trace = 0))
 fitGTR 
 
 
 ###################################################
-### code chunk number 13: Trees.Rnw:139-140
+### code chunk number 13: Trees.Rnw:143-146
 ###################################################
-anova(fitJC, fitGTR) 
+fitGTR <- optim.pml(fitGTR, model="GTR", optInv=TRUE, optGamma=TRUE, 
+    rearrangement = "stochastic", control = pml.control(trace = 0))
+fitGTR 
 
 
 ###################################################
-### code chunk number 14: Trees.Rnw:143-145
+### code chunk number 14: Trees.Rnw:150-151
 ###################################################
-AIC(fitGTR) 
-AIC(fitJC)
+anova(fitJC, fitGTR) 
 
 
 ###################################################
-### code chunk number 15: Trees.Rnw:148-149
+### code chunk number 15: Trees.Rnw:154-155
 ###################################################
 SH.test(fitGTR, fitJC) 
 
 
 ###################################################
-### code chunk number 16: Trees.Rnw:152-153
+### code chunk number 16: Trees.Rnw:158-162
+###################################################
+AIC(fitJC)
+AIC(fitGTR) 
+AICc(fitGTR) 
+BIC(fitGTR) 
+
+
+###################################################
+### code chunk number 17: Trees.Rnw:165-166
 ###################################################
 load("Trees.RData")
 
 
 ###################################################
-### code chunk number 17: Trees.Rnw:155-156 (eval = FALSE)
+### code chunk number 18: Trees.Rnw:168-169 (eval = FALSE)
 ###################################################
 ## mt = modelTest(primates)
 
 
 ###################################################
-### code chunk number 18: Trees.Rnw:160-162
+### code chunk number 19: Trees.Rnw:173-175
 ###################################################
 library(xtable)
-xtable(mt, caption="Summary table of modelTest", label="tab:modelTest")
+print(xtable(mt, caption="Summary table of modelTest", label="tab:modelTest"), include.rownames=FALSE)
 
 
 ###################################################
-### code chunk number 19: Trees.Rnw:166-169
+### code chunk number 20: Trees.Rnw:179-182
 ###################################################
 env <- attr(mt, "env")
 ls(envir=env)
@@ -138,83 +150,106 @@ ls(envir=env)
 
 
 ###################################################
-### code chunk number 20: Trees.Rnw:173-175 (eval = FALSE)
+### code chunk number 21: Trees.Rnw:185-187 (eval = FALSE)
 ###################################################
 ## bs = bootstrap.pml(fitJC, bs=100, optNni=TRUE, 
 ##     control = pml.control(trace = 0))
 
 
 ###################################################
-### code chunk number 21: plotBS
+### code chunk number 22: plotBS
 ###################################################
-par(mar=c(.1,.1,.1,.1))
-plotBS(fitJC$tree, bs)
+par(mfrow=c(2,1))
+par(mar=c(1,1,3,1))
+plotBS(midpoint(fitJC$tree), bs, p = 50, type="p")
+title("a)")
+cnet <- consensusNet(bs, p=0.2)
+plot(cnet, "2D", show.edge.label=TRUE)
+title("b)")
 
 
 ###################################################
-### code chunk number 22: figBS
+### code chunk number 23: figBS
 ###################################################
 getOption("SweaveHooks")[["fig"]]()
-par(mar=c(.1,.1,.1,.1))
-plotBS(fitJC$tree, bs)
+par(mfrow=c(2,1))
+par(mar=c(1,1,3,1))
+plotBS(midpoint(fitJC$tree), bs, p = 50, type="p")
+title("a)")
+cnet <- consensusNet(bs, p=0.2)
+plot(cnet, "2D", show.edge.label=TRUE)
+title("b)")
 
 
 ###################################################
-### code chunk number 23: Trees.Rnw:199-201
+### code chunk number 24: Trees.Rnw:218-220
 ###################################################
 options(prompt=" ")
 options(continue="  ")
 
 
 ###################################################
-### code chunk number 24: Trees.Rnw:203-226 (eval = FALSE)
+### code chunk number 25: Trees.Rnw:222-251 (eval = FALSE)
 ###################################################
-## library(parallel) # supports parallel computing
 ## library(phangorn)
 ## file="myfile"
 ## dat = read.phyDat(file)
-## dm = dist.ml(dat)
+## dm = dist.ml(dat, "F81")
 ## tree = NJ(dm)
 ## # as alternative for a starting tree:
-## tree <- pratchet(dat) 
+## tree <- pratchet(dat)          # parsimony tree 
+## tree <- nnls.phylo(tree, dm)   # need edge weights
 ## 
-## # 1. alternative: estimate an GTR model
-## fitStart = pml(tree, dat, k=4, inv=.2)
-## fit = optim.pml(fitStart, TRUE, TRUE, TRUE, TRUE, TRUE) 
+## 
+## # 1. alternative: quick and dirty: GTR + G 
+## fitStart = pml(tree, dat, k=4)
+## fit = optim.pml(fitStart, model="GTR", optGamma=TRUE, rearrangement="stochastic") 
 ##  
-## # 2. alternative: modelTest  
-## (mt <- modelTest(dat, multicore=TRUE)) 
-## mt$Model[which.min(mt$BIC)]
-## # choose best model from the table, assume now GTR+G+I
+## # 2. alternative: preper with modelTest  
+## mt <- modelTest(dat, tree=tree, multicore=TRUE)
+## mt[order(mt$AICc),]
+## # choose best model from the table according to AICc
+## bestmodel <- mt$Model[which.min(mt$AICc)]
+## 
 ## env = attr(mt, "env")
 ## fitStart = eval(get("GTR+G+I", env), env) 
-## fitStart = eval(get(mt$Model[which.min(mt$BIC)], env), env) 
-## fit = optim.pml(fitStart, optNni=TRUE, optGamma=TRUE, optInv=TRUE, 
-##     model="GTR")
+## 
+## # or let R search the table
+## fitStart = eval(get(bestmodel, env), env) 
+## # equivalent to:   fitStart = eval(get("GTR+G+I", env), env) 
+## fit = optim.pml(fitStart, rearrangement = "stochastic", 
+##     optGamma=TRUE, optInv=TRUE, model="GTR")
 ## bs = bootstrap.pml(fit, bs=100, optNni=TRUE, multicore=TRUE)
 
 
 ###################################################
-### code chunk number 25: Trees.Rnw:230-244 (eval = FALSE)
+### code chunk number 26: Trees.Rnw:257-278 (eval = FALSE)
 ###################################################
-## library(parallel) # supports parallel computing
 ## library(phangorn)
 ## file="myfile"
 ## dat = read.phyDat(file, type = "AA")
 ## dm = dist.ml(dat, model="JTT")
 ## tree = NJ(dm)
 ## 
-## (mt <- modelTest(dat, model=c("JTT", "LG", "WAG"), multicore=TRUE)) 
+## # parallel will only work safely from command line 
+## # and not at all windows
+## (mt <- modelTest(dat, model=c("JTT", "LG", "WAG"), 
+##     multicore=TRUE)) 
+## # run all available amino acid models
+## (mt <- modelTest(dat, model="all", multicore=TRUE))
+## 
 ## fitStart = eval(get(mt$Model[which.min(mt$BIC)], env), env) 
 ## 
 ## fitNJ = pml(tree, dat, model="JTT", k=4, inv=.2)
-## fit = optim.pml(fitNJ, optNni=TRUE, optInv=TRUE, optGamma=TRUE)
+## fit = optim.pml(fitNJ, rearrangement = "stochastic", 
+##     optInv=TRUE, optGamma=TRUE)
 ## fit
+## 
 ## bs = bootstrap.pml(fit, bs=100, optNni=TRUE, multicore=TRUE)
 
 
 ###################################################
-### code chunk number 26: Trees.Rnw:252-253
+### code chunk number 27: Trees.Rnw:290-291
 ###################################################
 toLatex(sessionInfo())
 
diff --git a/inst/doc/Trees.Rnw b/inst/doc/Trees.Rnw
index 8fba8fb..a77f5d4 100644
--- a/inst/doc/Trees.Rnw
+++ b/inst/doc/Trees.Rnw
@@ -9,6 +9,7 @@
 
 
 \begin{document}
+\SweaveOpts{concordance=TRUE}
 
 \newcommand{\Rfunction}[1]{{\texttt{#1}}}
 \newcommand{\Robject}[1]{{\texttt{#1}}}
@@ -48,6 +49,7 @@
 <<echo=FALSE>>=
 options(width=70)
 foo <- packageDescription("phangorn")
+options("show.signif.stars" = FALSE)
 @
 
 
@@ -58,35 +60,35 @@ foo <- packageDescription("phangorn")
 \nocite{Paradis2012}
 \section{Introduction}
 
-These notes should enable the user to estimate phylogenetic trees from alignment data with different methods using the \phangorn{} package \cite{Schliep2011}. Several functions of \phangorn{} are also described in more detail in \cite{Paradis2012}. For more theoretical background on all the methods see e.g. \cite{Felsenstein2004, Yang2006}. This document illustrates some of the \phangorn{} features to estimate phylogenetic trees using different reconstruction methods. Small adaptations t [...]
+These notes should enable the user to estimate phylogenetic trees from alignment data with different methods using the \phangorn{} package \cite{Schliep2011}. Several functions of \phangorn{} are also described in more detail in \cite{Paradis2012}. For more theoretical background on all the methods see e.g. \cite{Felsenstein2004, Yang2006}. This document illustrates some of the \phangorn{} features to estimate phylogenetic trees using different reconstruction methods. Small adaptations t [...]
 \section{Getting started}
 The first thing we have to do is to read in an alignment. Unfortunately there exists many different file formats that alignments can be stored in. The function \Rfunction{read.phyDat} is used to  read in an alignment. There are several functions to read in alignments depending on the format of the data set (nexus, phylip, fasta) and the kind of data (amino acid or nucleotides) in the \ape{} package \cite{Paradis2004} and \phangorn{}. The function \Rfunction{read.phyDat} calls these other [...]
 %When using the \Rfunction{read.dna} from \ape{} the parameter the we have to use as.character=TRUE.  
 We start our analysis loading the \phangorn{} package and then reading in an alignment.  
 <<echo=TRUE>>=
 library(phangorn)
-primates = read.phyDat("primates.dna", format="phylip", type="DNA")
+primates <- read.phyDat("primates.dna", format="phylip", 
+    type="DNA")
 @
-%require("multicore")
 \section{Distance based methods}
-After reading in the alignment we can build a first tree with distance based methods. The function dist.dna from the ape package computes distances for many DNA substitution models. To use the function dist.dna we have to transform the data to class DNAbin. For amino acids the function dist.ml offers common substitution models ("WAG", "JTT", "LG", "Dayhoff", "cpREV", "mtmam", "mtArt", "MtZoa" and "mtREV24").  
+After reading in the alignment we can build a first tree with distance based methods. The function dist.dna from the ape package computes distances for many DNA substitution models. To use the function dist.dna we have to transform the data to class DNAbin. For amino acids the function \Rfunction{dist.ml} offers common substitution models (for example "WAG", "JTT", "LG", "Dayhoff", "cpREV", "mtmam", "mtArt", "MtZoa" or "mtREV24").  
  
-After constructing a distance matrix we reconstruct a rooted tree with UPGMA and alternatively an unrooted tree using Neighbor Joining \cite{Saitou1987,Studier1988}. 
+After constructing a distance matrix we reconstruct a rooted tree with UPGMA and alternatively an unrooted tree using Neighbor Joining \cite{Saitou1987,Studier1988}. More distance methods like fastme are available in the \Rpackage{ape} package.
 <<echo=TRUE>>=
-dm = dist.ml(primates)
-treeUPGMA = upgma(dm)
-treeNJ = NJ(dm)
+dm  <- dist.ml(primates)
+treeUPGMA  <- upgma(dm)
+treeNJ  <- NJ(dm)
 @
 We can plot the trees treeUPGMA and treeNJ (figure \ref{fig:NJ}) with the commands:
 <<label=plotNJ,include=FALSE>>=
 layout(matrix(c(1,2), 2, 1), height=c(1,2))
-par(mar = c(.1,.1,.1,.1))
+par(mar = c(0,0,2,0)+ 0.1)
 plot(treeUPGMA, main="UPGMA")
 plot(treeNJ, "unrooted", main="NJ")
 @
 \begin{figure}
 \begin{center}
-<<label=figNJ,fig=TRUE,echo=FALSE>>=
+<<label=figNJ,fig=TRUE,echo=FALSE, height=8>>=
 <<plotNJ>>
 @
 \end{center}
@@ -101,10 +103,10 @@ The function parsimony returns the parsimony score, that is the number of change
 parsimony(treeUPGMA, primates)
 parsimony(treeNJ, primates)
 @
-The function optim.parsimony performs tree rearrangements to find trees with a lower parsimony score. So far the only tree rearrangement implemented is nearest-neighbor interchanges (NNI). However is also a version of the parsimony ratchet \cite{Nixon1999} implemented, which is likely to find better trees than just doing NNI rearrangements. 
+The function optim.parsimony performs tree rearrangements to find trees with a lower parsimony score. The tree rearrangement implemented are  nearest-neighbor interchanges (NNI) and subtree pruning and regrafting (SPR). The later one only works so far with the fitch algorithm. However is also a version of the parsimony ratchet \cite{Nixon1999} implemented, which is likely to find better trees than just doing NNI / SPR rearrangements. 
 <<echo=TRUE>>=
-treePars = optim.parsimony(treeUPGMA, primates)
-treeRatchet = pratchet(primates, trace = 0)
+treePars  <- optim.parsimony(treeUPGMA, primates)
+treeRatchet  <- pratchet(primates, trace = 0)
 parsimony(c(treePars, treeRatchet), primates)
 @
 For small data sets it is also possible to find all most parsimonious trees using a branch and bound algorithm \cite{Hendy1982}. For data sets with more than 10 taxa this can take a long time and depends strongly on how tree like the data are.  
@@ -119,47 +121,58 @@ We can easily compute the likelihood for a tree given the data
 fit = pml(treeNJ, data=primates)
 fit
 @
-The function pml returns an object of class pml. This object contains the data, the tree and many different parameters of the model like the likelihood etc. There are many generic functions for the class pml available, which allow the handling of these objects.
+The function \Rfunction{pml} returns an object of class \Robject{pml}. This object contains the data, the tree and many different parameters of the model like the likelihood. There are many generic functions for the class Robject{pml} available, which allow the handling of these objects.
 <<echo=TRUE>>=
 methods(class="pml")
 @ 
-The object fit just estimated the likelihood for the tree it got supplied, but the branch length are not optimized for the Jukes-Cantor model yet, which can be done with the function optim.pml. 
+The object fit just estimated the likelihood for the tree it got supplied, but the branch length are not optimized for the Jukes-Cantor model yet, which can be done with the function \Rfunction{optim.pml}. 
 <<echo=TRUE, results=hide>>=
-fitJC = optim.pml(fit, TRUE)
+fitJC  <- optim.pml(fit, TRUE)
 logLik(fitJC)
 @
 With the default values \Rfunction{pml} will estimate a Jukes-Cantor model. The function \Rfunction{update.pml} allows to change parameters. We will change the model to the GTR + $\Gamma(4)$ + I model and then optimize all the parameters. 
 <<echo=TRUE>>=
-fitGTR = update(fit, k=4, inv=0.2) 
-fitGTR = optim.pml(fitGTR, TRUE,TRUE, TRUE, TRUE, TRUE, 
-    control = pml.control(trace = 0))
+fitGTR <- update(fit, k=4, inv=0.2) 
+fitGTR <- optim.pml(fitGTR, model="GTR", optInv=TRUE, optGamma=TRUE, 
+    rearrangement = "NNI", control = pml.control(trace = 0))
 fitGTR 
 @
-We can compare the objects for the JC and GTR + $\Gamma(4)$ + I model using likelihood ratio statistic
+With the control parameters the threshols for the fitting process can be changed. Here we want just to supress output during the fitting process. For larger trees the NNI rearrangements often get stuck in local maxima. We added two stochatic algorithm to improve topology search. The first (set rearrangement="stochastic") performs stochastic rearrangements similar as in \cite{Nguyen2015}, which makes random NNI permuation to the tree, which than gets optimised to escape local optima. The  [...]
+
+While these algorithms may find better trees they will also take more time.      
 <<echo=TRUE>>=
-anova(fitJC, fitGTR) 
+fitGTR <- optim.pml(fitGTR, model="GTR", optInv=TRUE, optGamma=TRUE, 
+    rearrangement = "stochastic", control = pml.control(trace = 0))
+fitGTR 
 @
-with the AIC
+\subsection{Model selection}
+We can compare nested models for the JC and GTR + $\Gamma(4)$ + I model using likelihood ratio statistic
 <<echo=TRUE>>=
-AIC(fitGTR) 
-AIC(fitJC)
+anova(fitJC, fitGTR) 
 @
-or the Shimodaira-Hasegawa test.
+with the Shimodaira-Hasegawa \cite{Shimodaira1999} test
 <<echo=TRUE>>=
 SH.test(fitGTR, fitJC) 
 @
-An alternative is to use the function \Rfunction{modelTest}  to compare different models the AIC or BIC, similar to popular program of \cite{Posada1998, Posada2008}.  
+or with the AIC
+<<echo=TRUE>>=
+AIC(fitJC)
+AIC(fitGTR) 
+AICc(fitGTR) 
+BIC(fitGTR) 
+@
+An alternative is to use the function \Rfunction{modelTest}  to compare different nucleotide or protein models the AIC, AICc or BIC, similar to popular programs ModelTest and ProtTest \cite{Posada1998, Posada2008, Abascal2005}.  
 <<echo=FALSE>>=
 load("Trees.RData")
 @
 <<echo=TRUE, eval=FALSE>>=
 mt = modelTest(primates)
 @
-The results of is illustrated in table \ref{tab:modelTest}
+The results of \Rfunction{modelTest} is illustrated in table \ref{tab:modelTest}
 \begin{center}
 <<echo=FALSE,results=tex>>=
 library(xtable)
-xtable(mt, caption="Summary table of modelTest", label="tab:modelTest")
+print(xtable(mt, caption="Summary table of modelTest", label="tab:modelTest"), include.rownames=FALSE)
 @
 \end{center}
 The thresholds for the optimization in  \Rfunction{modelTest} are not as strict as for \Rfunction{optim.pml} and no tree rearrangements are performed. As \Rfunction{modelTest} computes and optimizes a lot of models it would be a waste of computer time not to save these results. The results are saved as call together with the optimized trees in an environment and this call can be evaluated to get a "pml" object back to use for further optimization or analysis.
@@ -168,7 +181,6 @@ env <- attr(mt, "env")
 ls(envir=env)
 (fit <- eval(get("HKY+G+I", env), env))
 @
-
 At last we may want to apply bootstrap to test how well the edges of the tree are supported: %, results=hide
 <<echo=TRUE, eval=FALSE>>=
 bs = bootstrap.pml(fitJC, bs=100, optNni=TRUE, 
@@ -176,74 +188,100 @@ bs = bootstrap.pml(fitJC, bs=100, optNni=TRUE,
 @
    
 %$
-Now we can plot the tree with the bootstrap support values on the edges
+Now we can plot the tree with the bootstrap support values on the edges and also look at consensusNet to identify potential conflict. 
 <<label=plotBS,include=FALSE>>=
-par(mar=c(.1,.1,.1,.1))
-plotBS(fitJC$tree, bs)
+par(mfrow=c(2,1))
+par(mar=c(1,1,3,1))
+plotBS(midpoint(fitJC$tree), bs, p = 50, type="p")
+title("a)")
+cnet <- consensusNet(bs, p=0.2)
+plot(cnet, "2D", show.edge.label=TRUE)
+title("b)")
 @
 %$
 \begin{figure}
 \begin{center}
-<<label=figBS,fig=TRUE,echo=FALSE>>=
+<<label=figBS,fig=TRUE,echo=FALSE, height=9>>=
 <<plotBS>>
 @
 \end{center}
-\caption{Unrooted tree with bootstrap support values}
+\caption{a) Unrooted tree (midpoint rooted) with bootstrap support values. b) ConsensusNet from the bootstrap sample}
 \label{fig:BS}
 \end{figure}
 
 Several analyses, e.g. \Rfunction{bootstrap} and  \Rfunction{modelTest}, can be computationally demanding, but as nowadays most computers have several cores one can distribute the computations using the  \multicore{} package. However it is only possible to use this approach if R is running from command line ("X11"), but not using  a GUI (for example "Aqua" on Macs) and unfortunately the \multicore{} package does not work at all under Windows. 
-\section{Appendix: Standard scripts for nucleotide or amino acid analysis}\label{sec:Appendix}
+
+\newpage
+\section{Appendix: Standard scripts for nucleotide analysis}\label{sec:Appendix1}
 Here we provide two standard scripts which can be adapted for the most common tasks. 
-Most likely the arguments for \Rfunction{read.phyDat} have to be adapted to accommodate your file format. Both scripts assume that the \multicore{} package, see comments above. 
+Most likely the arguments for \Rfunction{read.phyDat} have to be adapted to accommodate your file format. Both scripts assume that the \multicore{} package works on your platform, see comments above. 
 <<echo=FALSE>>=
 options(prompt=" ")
 options(continue="  ")
 @
 <<eval=FALSE>>=
-library(parallel) # supports parallel computing
 library(phangorn)
 file="myfile"
 dat = read.phyDat(file)
-dm = dist.ml(dat)
+dm = dist.ml(dat, "F81")
 tree = NJ(dm)
 # as alternative for a starting tree:
-tree <- pratchet(dat) 
+tree <- pratchet(dat)          # parsimony tree 
+tree <- nnls.phylo(tree, dm)   # need edge weights
+
 
-# 1. alternative: estimate an GTR model
-fitStart = pml(tree, dat, k=4, inv=.2)
-fit = optim.pml(fitStart, TRUE, TRUE, TRUE, TRUE, TRUE) 
+# 1. alternative: quick and dirty: GTR + G 
+fitStart = pml(tree, dat, k=4)
+fit = optim.pml(fitStart, model="GTR", optGamma=TRUE, rearrangement="stochastic") 
  
-# 2. alternative: modelTest  
-(mt <- modelTest(dat, multicore=TRUE)) 
-mt$Model[which.min(mt$BIC)]
-# choose best model from the table, assume now GTR+G+I
+# 2. alternative: preper with modelTest  
+mt <- modelTest(dat, tree=tree, multicore=TRUE)
+mt[order(mt$AICc),]
+# choose best model from the table according to AICc
+bestmodel <- mt$Model[which.min(mt$AICc)]
+
 env = attr(mt, "env")
 fitStart = eval(get("GTR+G+I", env), env) 
-fitStart = eval(get(mt$Model[which.min(mt$BIC)], env), env) 
-fit = optim.pml(fitStart, optNni=TRUE, optGamma=TRUE, optInv=TRUE, 
-    model="GTR")
+
+# or let R search the table
+fitStart = eval(get(bestmodel, env), env) 
+# equivalent to:   fitStart = eval(get("GTR+G+I", env), env) 
+fit = optim.pml(fitStart, rearrangement = "stochastic", 
+    optGamma=TRUE, optInv=TRUE, model="GTR")
 bs = bootstrap.pml(fit, bs=100, optNni=TRUE, multicore=TRUE)
 @
 
-You can specify different several models build in which you can specify, e.g. "WAG", "JTT", "Dayhoff", "LG". Optimizing the rate matrix for amino acids is possible, but would take a long, a very long time. So make sure to set optBf=FALSE and optQ=FALSE in the function \Rfunction{optim.pml}, which is also the default.
+\newpage
+\section{Appendix 2: Standard scripts for amino acid analysis}%\label{sec:Appendix2}
+You can specify different several models build in which you can specify, e.g. "WAG", "JTT", "Dayhoff", "LG". Optimizing the rate matrix for amino acids is possible, but would take a long, a very long time and you will need to have a large alignement to estimate all the parameters. So make sure to set optBf=FALSE and optQ=FALSE in the function \Rfunction{optim.pml}, which is also the default.
 <<eval=FALSE>>=
-library(parallel) # supports parallel computing
 library(phangorn)
 file="myfile"
 dat = read.phyDat(file, type = "AA")
 dm = dist.ml(dat, model="JTT")
 tree = NJ(dm)
 
-(mt <- modelTest(dat, model=c("JTT", "LG", "WAG"), multicore=TRUE)) 
+# parallel will only work safely from command line 
+# and not at all windows
+(mt <- modelTest(dat, model=c("JTT", "LG", "WAG"), 
+    multicore=TRUE)) 
+# run all available amino acid models
+(mt <- modelTest(dat, model="all", multicore=TRUE))
+
 fitStart = eval(get(mt$Model[which.min(mt$BIC)], env), env) 
 
 fitNJ = pml(tree, dat, model="JTT", k=4, inv=.2)
-fit = optim.pml(fitNJ, optNni=TRUE, optInv=TRUE, optGamma=TRUE)
+fit = optim.pml(fitNJ, rearrangement = "stochastic", 
+    optInv=TRUE, optGamma=TRUE)
 fit
+
 bs = bootstrap.pml(fit, bs=100, optNni=TRUE, multicore=TRUE)
 @
 
+\newpage
+
+% \cite{Sugiura1978}
+
 \bibliographystyle{plain}
 \bibliography{phangorn}
 
diff --git a/inst/doc/Trees.pdf b/inst/doc/Trees.pdf
index a1a0de3..dc9a6bf 100644
Binary files a/inst/doc/Trees.pdf and b/inst/doc/Trees.pdf differ
diff --git a/inst/doc/phangorn-specials.R b/inst/doc/phangorn-specials.R
index d6dc383..e2d28e6 100644
--- a/inst/doc/phangorn-specials.R
+++ b/inst/doc/phangorn-specials.R
@@ -1,14 +1,15 @@
 ### R code from vignette source 'phangorn-specials.Rnw'
 
 ###################################################
-### code chunk number 1: phangorn-specials.Rnw:46-48
+### code chunk number 1: phangorn-specials.Rnw:48-51
 ###################################################
 options(width=70)
+options("show.signif.stars" = FALSE)
 foo <- packageDescription("phangorn")
 
 
 ###################################################
-### code chunk number 2: phangorn-specials.Rnw:70-76
+### code chunk number 2: phangorn-specials.Rnw:73-79
 ###################################################
 library(phangorn)
 data = matrix(c("r","a","y","g","g","a","c","-","c","t","c","g", 
@@ -19,14 +20,14 @@ data
 
 
 ###################################################
-### code chunk number 3: phangorn-specials.Rnw:79-81
+### code chunk number 3: phangorn-specials.Rnw:82-84
 ###################################################
 gapsdata1 = phyDat(data)
 gapsdata1
 
 
 ###################################################
-### code chunk number 4: phangorn-specials.Rnw:84-87
+### code chunk number 4: phangorn-specials.Rnw:87-90
 ###################################################
 gapsdata2 = phyDat(data, type="USER", levels=c("a","c","g","t","-"), 
     ambiguity = c("?", "n"))
@@ -34,7 +35,7 @@ gapsdata2
 
 
 ###################################################
-### code chunk number 5: phangorn-specials.Rnw:91-106
+### code chunk number 5: phangorn-specials.Rnw:94-109
 ###################################################
 contrast = matrix(data = c(1,0,0,0,0,
     0,1,0,0,0,
@@ -54,7 +55,7 @@ gapsdata3
 
 
 ###################################################
-### code chunk number 6: phangorn-specials.Rnw:137-142
+### code chunk number 6: phangorn-specials.Rnw:165-170
 ###################################################
 tree = unroot(rtree(3))
 fit = pml(tree, gapsdata3)
@@ -64,7 +65,7 @@ fit
 
 
 ###################################################
-### code chunk number 7: phangorn-specials.Rnw:205-215
+### code chunk number 7: phangorn-specials.Rnw:233-243
 ###################################################
 library(phangorn)
 primates = read.phyDat("primates.dna", format="phylip", type="DNA")
@@ -96,13 +97,13 @@ for(i in 1:15)plot(trees[[i]], cex=1, type="u")
 
 
 ###################################################
-### code chunk number 10: phangorn-specials.Rnw:242-243
+### code chunk number 10: phangorn-specials.Rnw:271-272
 ###################################################
 trees = nni(trees[[1]])
 
 
 ###################################################
-### code chunk number 11: phangorn-specials.Rnw:254-255
+### code chunk number 11: phangorn-specials.Rnw:283-284
 ###################################################
 toLatex(sessionInfo())
 
diff --git a/inst/doc/phangorn-specials.Rnw b/inst/doc/phangorn-specials.Rnw
index 9d33093..53b99b4 100644
--- a/inst/doc/phangorn-specials.Rnw
+++ b/inst/doc/phangorn-specials.Rnw
@@ -8,6 +8,7 @@
 % tools::texi2dvi("phangorn-specials.tex", pdf=TRUE)
 \usepackage{times}
 \usepackage{hyperref}
+\usepackage{amsmath}
 
 \newcommand{\Rfunction}[1]{{\texttt{#1}}}
 \newcommand{\Robject}[1]{{\texttt{#1}}}
@@ -35,6 +36,7 @@
 
 
 \begin{document}
+\SweaveOpts{concordance=TRUE}
 
 % Ross Ihakas extenstion for nicer representation 
 \DefineVerbatimEnvironment{Sinput}{Verbatim} {xleftmargin=2em}
@@ -45,6 +47,7 @@
 
 <<echo=FALSE>>=
 options(width=70)
+options("show.signif.stars" = FALSE)
 foo <- packageDescription("phangorn")
 @
 
@@ -110,6 +113,30 @@ Here we defined "n" as a state which can be any nucleotide but not a gap "-" and
 These data can be used in all functions available in \phangorn{} to compute distance matrices or perform parsimony and maximum likelihood analysis.  
 
 
+\section{Markov models of character evolution}
+To model nucleotide substitutions across the edges of a tree T we can assign a transition matrix. In the case of nucleotides, with four character states, each 4 $\times$ 4 transition matrix has, at most, 12 free parameters.
+
+Time-reversible Markov models are used to describe how characters change over time, and use fewer parameters. Time-reversible means that these models need not be directed in time, and the Markov property states that these models depend only on the current state. These models are used in analysis of phylogenies using maximum likelihood and MCMC, computing pairwise distances, as well in simulating sequence evolution.
+
+We will now describe the General Time-Reversible (GTR) model \cite{Tavare1986}. The parameters
+of the GTR model are the equilibrium frequencies $\pi = (\pi_A ,\pi_C ,\pi_G ,\pi_T)$ and a rate
+matrix $Q$ which has the form
+\begin{equation}\label{eq:GTR}
+Q = 
+\begin{pmatrix}
+\ast  & \alpha\pi_C & \beta\pi_G & \gamma\pi_T \\
+\alpha\pi_A & \ast & \delta\pi_G & \epsilon\pi_T \\
+\beta\pi_A & \delta\pi_C & \ast & \eta\pi_T \\
+\gamma\pi_A &  \epsilon\pi_C & \eta\pi_G & \ast \\
+\end{pmatrix}
+\end{equation}
+where we need to assign 6 paramters $\alpha, \dots, \eta$. The elements on the diagonal are chosen so that the rows sum to zero. The Jukes-Cantor (JC) \cite{Jukes1969} model can be derived as special case from the GTR model, for equal equilibrium frequencies $\pi_A = \pi_C = \pi_G = \pi_T = 0.25$ and equal rates set to $\alpha = \beta = \gamma = \delta = \eta$. Table \ref{models} lists all built-in nucleotide models in \phangorn. 
+The transition probabilities which describe the probabilities of change from character $i$ to $j$ in time $t$, are given by the corresponding entries of the matrix exponential
+\[
+P(t) = (p_{ij}(t)) = e^{Qt}, \qquad \sum_j p_{ij}=1
+\]
+where $P(t)$ is the transition matrix spanning a period of time $t$.
+
 \section{Estimation of non-standard transition rate matrices}
 In the last section \ref{sec:USER} we described how to set up user defined data formats. Now we describe how to estimate transition matrices with pml. 
 
@@ -132,8 +159,9 @@ We will now show how to estimate a rate matrix with different transition ($\alph
    \caption{Rate matrix K to optimise. }\label{gaps} 
 \end{table}
 
-
-The parameters subs accepts a vector of consecutive integers and at least one element has to be zero (these gets the reference rate of 1).
+If we want to fit a non-standard transition rate matrices, we have to tell \Rfunction{optim.pml}, which transitions in Q get the same rate. 
+The parameter vector subs accepts a vector of consecutive integers and at least one element has to be zero (these gets the reference rate of 1).
+Negative values indicate that there is no direct transition is possible and the rate is set to zero. 
 <<>>=
 tree = unroot(rtree(3))
 fit = pml(tree, gapsdata3)
@@ -180,11 +208,11 @@ If optQ=TRUE and neither a model or subs are supplied than a symmetric (optBf=FA
          GTR & TRUE & TRUE & $c(1, 2, 3, 4, 5, 0)$ & 8 \\
          \hline
    \end{tabular}
-   \caption{DNA models available in phangorn, how they are defined and number of parameters to estimate. }\label{models} 
+   \caption{DNA models available in phangorn, how they are defined and number of parameters to estimate. The elements of the vector subs correspond to $\alpha, \dots, \eta$ in equation (\ref{eq:GTR})}\label{models} 
 \end{table}
 
 \section{Codon substitution models}
-A special case of the transition rates are codon models. \phangorn{} now offers the possibility to estimate the $d_N/d_S$ ratio (sometimes called ka/ks), for an overview see \cite{Yang2006}. These functions extend the option to estimates the $d_N/d_S$ ratio for pairwise sequence comparison as it is available through the function \Rfunction{kaks} in \Rpackage{seqinr}. The transition rate between between codon $i$ and $j$ is defined as follows:
+A special case of the transition rates are codon models. \phangorn{} now offers the possibility to estimate the $d_N/d_S$ ratio (sometimes called ka/ks), for an overview see \cite{Yang2014}. These functions extend the option to estimates the $d_N/d_S$ ratio for pairwise sequence comparison as it is available through the function \Rfunction{kaks} in \Rpackage{seqinr}. The transition rate between between codon $i$ and $j$ is defined as follows:
 \begin{eqnarray}
 q_{ij}=\left\{ 
     \begin{array}{l@{\quad}l}
@@ -215,6 +243,7 @@ fit3 <- optim.pml(fit, model="codon3", control=pml.control(trace=0))
 anova(fit0, fit2, fit3, fit1)
 @
 The models described here all assume equal frequencies for each codon (=1/61). One can optimise the codon frequencies setting the option to optBf=TRUE. As the convergence of the 61 parameters the convergence is likely slow set the maximal iterations to a higher value than the default (e.g. control = pml.control(maxit=50)).  
+The "YN98" model \cite{Yang98} is similar to the "codon1", but addional optimises the codon frequencies.   
 
 \section{Generating trees}
 \phangorn{} has several functions to generate tree topologies, which may are interesting for simulation studies. \Rfunction{allTrees} computes all possible bifurcating tree topologies either rooted or unrooted for up to 10 taxa. One has to keep in mind that the number of trees is growing exponentially, use \Rfunction(howmanytrees) from \ape{} as a reminder. 
diff --git a/inst/doc/phangorn-specials.pdf b/inst/doc/phangorn-specials.pdf
index 28b5022..d5653c8 100644
Binary files a/inst/doc/phangorn-specials.pdf and b/inst/doc/phangorn-specials.pdf differ
diff --git a/inst/extdata/trees/RAxML_bipartitions.woodmouse b/inst/extdata/trees/RAxML_bipartitions.woodmouse
new file mode 100644
index 0000000..95e99cd
--- /dev/null
+++ b/inst/extdata/trees/RAxML_bipartitions.woodmouse
@@ -0,0 +1 @@
+(No305:0.00622878382196208596,(((No1007S:0.00000170671604060440,(No0909S:0.00108390188878723214,No1208S:0.00108436668237289475)52:0.00108405665369984980)99:0.00776063902846151413,(No0912S:0.00328637227135690751,No1103S:0.00109428209179901806)77:0.00000170671604060440)74:0.00223367776102044056,((No0908S:0.00552992494657482316,(No1206S:0.00557570157809361960,((No1202S:0.00108229934579785574,No0910S:0.00222680065047513396)95:0.00225951139716124754,No0906S:0.00571167759421415972)73:0.0010873 [...]
diff --git a/inst/extdata/trees/RAxML_bootstrap.woodmouse b/inst/extdata/trees/RAxML_bootstrap.woodmouse
new file mode 100644
index 0000000..575ddc2
--- /dev/null
+++ b/inst/extdata/trees/RAxML_bootstrap.woodmouse
@@ -0,0 +1,1000 @@
+(((No1007S,(No0909S,No1208S)),(((No0906S,(No0910S,No1202S)),((No0912S,No1103S),(No0908S,No1206S))),(No306,(No0913S,No304)))),No1114S,No305);
+(((No306,((No0906S,(No0913S,(No0910S,No1202S))),(((No1208S,(No1007S,No0909S)),(No0912S,No1103S)),No304))),(No0908S,No1206S)),No1114S,No305);
+(((No0909S,(No1208S,No1007S)),((No0912S,No1103S),((No0908S,No1206S),((No304,No306),(No0906S,(No0913S,(No0910S,No1202S))))))),No1114S,No305);
+(((No1007S,(No0909S,No1208S)),((No0906S,(No0908S,(((((No0913S,No304),No306),No1103S),No1206S),No0912S))),(No0910S,No1202S))),No1114S,No305);
+(((((No0908S,No1206S),(No304,No306)),((No0913S,(No0910S,No1202S)),No0906S)),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No1114S,No305);
+(No1114S,(((No0908S,((No0910S,No1202S),(No1206S,No0906S))),(No306,(No0913S,No304))),((No1208S,(No1007S,No0909S)),(No0912S,No1103S))),No305);
+((No1114S,(No306,(No0913S,No304))),(((No0909S,(No1208S,No1007S)),(No0912S,No1103S)),((No0910S,No1202S),((No0908S,No1206S),No0906S))),No305);
+((((No0906S,(No0910S,No1202S)),No1206S),(No0908S,((No0909S,(No1208S,No1007S)),(No0912S,No1103S)))),(No306,(No0913S,(No1114S,No304))),No305);
+((((No0912S,No1103S),(No1007S,(No0909S,No1208S))),(((No304,No0913S),No306),(((No0906S,(No0910S,No1202S)),No1206S),No0908S))),No1114S,No305);
+(((No0912S,No1103S),((No1007S,(No0909S,No1208S)),(((No304,No0913S),No306),((No0906S,(No0910S,No1202S)),(No1206S,No0908S))))),No1114S,No305);
+((((No1103S,No0912S),(((((No1202S,No0910S),No0906S),No1206S),No0908S),(No306,(No304,No0913S)))),((No1208S,No0909S),No1007S)),No1114S,No305);
+(((((((No1202S,No0910S),No0906S),No1206S),No0908S),(No306,(No304,No0913S))),(No1103S,(((No1208S,No0909S),No1007S),No0912S))),No1114S,No305);
+(((((((No1202S,No0910S),No0906S),No1206S),No0908S),(No306,(No304,No0913S))),(No1103S,(((No1208S,No0909S),No1007S),No0912S))),No1114S,No305);
+((((No0906S,(No1206S,No0908S)),(No306,(No304,((No1202S,No0910S),No0913S)))),((((No1208S,No0909S),No1007S),No0912S),No1103S)),No1114S,No305);
+((((No0908S,(((No1202S,No0910S),No0906S),No1206S)),(No306,(No304,No0913S))),((No0909S,(No1007S,No1208S)),(No0912S,No1103S))),No1114S,No305);
+(((No306,((No304,No0913S),(No0908S,(((No1202S,No0910S),No0906S),No1206S)))),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No1114S,No305);
+(((((No306,(No0913S,(((No1202S,No0910S),No0906S),No1206S))),No0908S),No304),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No1114S,No305);
+((((((No0913S,No304),No306),No0908S),(((No1202S,No0910S),No0906S),No1206S)),(((No1007S,(No1208S,No0909S)),No0912S),No1103S)),No1114S,No305);
+((((((No0913S,No304),No306),No0908S),(((No1202S,No0910S),No0906S),No1206S)),(((No0909S,(No1007S,No1208S)),No0912S),No1103S)),No1114S,No305);
+((((((No304,No0908S),(No306,(((No0913S,(No1202S,No0910S)),No0906S),No1206S))),(No0909S,(No1007S,No1208S))),No0912S),No1103S),No1114S,No305);
+(((No1103S,(No0912S,(No0909S,(No1007S,No1208S)))),(((((No1202S,No0910S),No0906S),No1206S),No0908S),(No306,(No304,No0913S)))),No1114S,No305);
+(((No1007S,(No1208S,No0909S)),(No1103S,No0912S)),((No0908S,(((No1202S,No0910S),No0906S),No1206S)),(No306,(No1114S,(No304,No0913S)))),No305);
+(((No1103S,No0912S),(((No0908S,(((No1202S,No0910S),No0906S),No1206S)),(No306,(No304,No0913S))),(No1007S,(No1208S,No0909S)))),No1114S,No305);
+((No1103S,(((((No1202S,No0910S),No0906S),(No1206S,No0908S)),(No306,(No304,No0913S))),(No0912S,(No1007S,(No1208S,No0909S))))),No1114S,No305);
+((((No306,(No304,No0913S)),(No0908S,(((No1202S,No0910S),No0906S),No1206S))),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No1114S,No305);
+((((No306,(No304,No0913S)),(No0908S,(((No1202S,No0910S),No0906S),No1206S))),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No1114S,No305);
+((((No306,(No304,No0913S)),(No0908S,(((No1202S,No0910S),No0906S),No1206S))),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No1114S,No305);
+(((No306,(No0908S,((((No1202S,No0910S),No0906S),No1206S),(No304,No0913S)))),((No0909S,(No1007S,No1208S)),(No0912S,No1103S))),No1114S,No305);
+((No0908S,((No306,(No304,No0913S)),((((No1202S,No0910S),No0906S),No1206S),((No0909S,(No1007S,No1208S)),(No0912S,No1103S))))),No1114S,No305);
+((((No0912S,No1103S),(No1007S,(No1208S,No0909S))),(((No0908S,No1206S),((No1202S,No0910S),No0906S)),(No306,(No304,No0913S)))),No1114S,No305);
+(((No0913S,No304),(No306,(((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),(No0908S,((No0906S,(No0910S,No1202S)),No1206S))))),No1114S,No305);
+((((No0912S,No1103S),(No1007S,(No1208S,No0909S))),(((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),((No0913S,No304),No306))),No1114S,No305);
+((((No0912S,No1103S),(No1007S,(No1208S,No0909S))),(((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),((No0913S,No304),No306))),No1114S,No305);
+((((No0912S,No1103S),(No0909S,(No1007S,No1208S))),(((No1206S,(No0910S,(No1202S,No0906S))),No0908S),((No0913S,No304),No306))),No1114S,No305);
+(((No0909S,(No1007S,No1208S)),(No0912S,(No1103S,(No306,(((No0913S,No0910S),No1202S),(No304,(No0906S,(No0908S,No1206S)))))))),No1114S,No305);
+(((No306,((No304,No0908S),(No0913S,(No1206S,(No0906S,(No0910S,No1202S)))))),((No0909S,(No1007S,No1208S)),(No1103S,No0912S))),No1114S,No305);
+(((No1103S,No0912S),(((No0908S,(No306,(No304,No0913S))),(No0906S,((No1206S,No1202S),No0910S))),(No0909S,(No1007S,No1208S)))),No1114S,No305);
+(((No1103S,No1114S),No0912S),((((No1206S,No0908S),(No306,(No304,No0913S))),(No0906S,(No1202S,No0910S))),(No0909S,(No1007S,No1208S))),No305);
+(No1114S,((No0912S,((No1007S,(No1208S,No0909S)),No1103S)),((((No306,(No304,No0913S)),((No1202S,No0910S),No0906S)),No1206S),No0908S)),No305);
+(No1114S,((No0912S,((No0909S,(No1007S,No1208S)),No1103S)),((No0908S,(No1206S,((No1202S,No0910S),No0906S))),(No306,(No304,No0913S)))),No305);
+((((No0909S,(No1007S,No1208S)),(No0912S,No1103S)),((No306,((No0910S,((No0913S,No304),No1202S)),No0906S)),(No0908S,No1206S))),No1114S,No305);
+((((No0909S,(No1007S,No1208S)),(No0912S,No1103S)),((((No0913S,No304),No306),(((No1202S,No0910S),No1206S),No0906S)),No0908S)),No1114S,No305);
+((((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),(((No1202S,No0910S),No0906S),(((No0913S,No304),No306),(No0908S,No1206S)))),No1114S,No305);
+((((No0909S,(No1007S,No1208S)),(No0912S,No1103S)),(((No1202S,No0910S),No0906S),(((No0913S,No304),No306),(No0908S,No1206S)))),No1114S,No305);
+((((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),((No0908S,No1206S),(No304,(No306,(No0913S,((No1202S,No0910S),No0906S)))))),No1114S,No305);
+(((No1208S,(No0909S,No1007S)),((No0912S,No1103S),((No0908S,(No1206S,((No1202S,No0910S),No0906S))),((No0913S,No304),No306)))),No1114S,No305);
+((((No0908S,(No1206S,((No1202S,No0910S),No0906S))),((No0913S,No304),No306)),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No1114S,No305);
+((((No0908S,(No1206S,((No1202S,No0910S),No0906S))),((No0913S,No304),No306)),((No0909S,(No1007S,No1208S)),(No0912S,No1103S))),No1114S,No305);
+(((No1007S,(No1208S,No0909S)),((No0912S,No1103S),((No0908S,((No0906S,(No1202S,No0910S)),No1206S)),((No0913S,No304),No306)))),No1114S,No305);
+((((No0908S,((No1202S,No0910S),(No1206S,No0906S))),((No0913S,No304),No306)),((No0909S,(No1007S,No1208S)),(No0912S,No1103S))),No1114S,No305);
+(No1114S,(((No1103S,No0912S),(No1007S,(No1208S,No0909S))),(((No306,(No304,No0913S)),(No1206S,No0908S)),(No0906S,(No0910S,No1202S)))),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No1208S,No0909S))),((No306,(No304,No0913S)),(No0908S,(No1206S,(No0906S,(No0910S,No1202S)))))),No305);
+(No1114S,((No304,No0913S),(((((No0912S,No1103S),(No1007S,(No1208S,No0909S))),(No0908S,No1206S)),(No0906S,(No0910S,No1202S))),No306)),No305);
+(((No0908S,(No1206S,(No0906S,(No0910S,No1202S)))),(No306,(No1114S,(No304,No0913S)))),((No0912S,No1103S),(No1007S,(No1208S,No0909S))),No305);
+(No1114S,((No306,((((No304,No0913S),(No0910S,No1202S)),No0906S),(No0908S,No1206S))),((No0912S,No1103S),(No0909S,(No1007S,No1208S)))),No305);
+(No1114S,((No306,(No304,No0913S)),((((No1007S,(No1208S,No0909S)),No0912S),No1103S),(No0908S,(No1206S,((No1202S,No0910S),No0906S))))),No305);
+(No1114S,((No1103S,No0912S),((No306,(No304,No0913S)),((((No1202S,No0910S),No0906S),(No0909S,(No1007S,No1208S))),(No0908S,No1206S)))),No305);
+(No1114S,(((No1103S,No0912S),(No1007S,(No1208S,No0909S))),((No0908S,(No306,(No304,No0913S))),(No1206S,((No1202S,No0910S),No0906S)))),No305);
+(No1114S,(((No1103S,No0912S),(No1007S,(No1208S,No0909S))),((No0908S,(No306,(No304,No0913S))),(No1206S,((No1202S,No0910S),No0906S)))),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No1208S,No0909S))),((No306,(No304,No0913S)),((No1202S,No0910S),((No0908S,No1206S),No0906S)))),No305);
+(No1114S,(((No1007S,(No1208S,No0909S)),(No1103S,No0912S)),(((No0906S,(No1202S,No0910S)),(No0908S,No1206S)),((No0913S,No304),No306))),No305);
+(No1114S,((No0912S,No1103S),(No0906S,((((No1202S,No0910S),(No1007S,(No1208S,No0909S))),((No0913S,No304),No306)),(No0908S,No1206S)))),No305);
+(No1114S,((((No1007S,(No1208S,No0909S)),No0912S),No1103S),(((No0913S,No304),No306),(No0908S,(No1206S,(No0906S,(No1202S,No0910S)))))),No305);
+(No1114S,((No0912S,No1103S),(((No0908S,(No1206S,(No0906S,(No1202S,No0910S)))),((No0913S,No304),No306)),(No0909S,(No1007S,No1208S)))),No305);
+(No1114S,(((No0908S,(No1206S,(No0906S,(No1202S,No0910S)))),((No0913S,No304),No306)),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No305);
+(No1114S,(((No0908S,(No1206S,(No0906S,(No1202S,No0910S)))),((No0913S,No304),No306)),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No305);
+((((No0906S,(No1202S,No0910S)),(No1206S,No0908S)),(No1114S,((No0913S,No304),No306))),((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),No305);
+(((((No0913S,No304),No306),(No0908S,(((No1202S,No0910S),No0906S),No1206S))),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No1114S,No305);
+(((((No0913S,No304),No306),(No0908S,(((No1202S,No0910S),No0906S),No1206S))),((No0909S,(No1007S,No1208S)),(No0912S,No1103S))),No1114S,No305);
+((No0908S,((((No1202S,No0910S),No0906S),No1206S),((No0913S,(No1114S,No304)),No306))),(No1103S,((No0909S,(No1007S,No1208S)),No0912S)),No305);
+(No1114S,((No1007S,(No1208S,No0909S)),(((((No1103S,No0912S),No1206S),(No0906S,(No1202S,No0910S))),No0908S),((No0913S,No304),No306))),No305);
+((((((No1206S,No0908S),No0912S),(No0906S,(No1202S,No0910S))),No1103S),((No0913S,No304),No306)),((No1114S,(No1007S,No1208S)),No0909S),No305);
+(No1114S,((((No1206S,(No0906S,(No1202S,No0910S))),No0908S),((No0913S,No304),No306)),(((No1007S,No1208S),No0909S),(No0912S,No1103S))),No305);
+(No1114S,((((No1206S,(No0906S,(No1202S,No0910S))),No0908S),((No0913S,No304),No306)),(((No1007S,No1208S),No0909S),(No0912S,No1103S))),No305);
+(No1114S,(((No1007S,No1208S),No0909S),((No306,(No1103S,(((No0906S,(No1202S,No0910S)),No1206S),(No0908S,No0912S)))),(No0913S,No304))),No305);
+(No1114S,(No0912S,(No1103S,((No306,((No0906S,((No1202S,No0910S),No1206S)),((No1007S,(No1208S,No0909S)),No0908S))),(No304,No0913S)))),No305);
+(No1114S,(((No1007S,(No1208S,No0909S)),((No0908S,No1206S),(((No304,No0913S),No306),(No0906S,(No1202S,No0910S))))),(No0912S,No1103S)),No305);
+(No1114S,(((No0910S,(((No0908S,No1206S),No1202S),((No304,No0913S),No306))),No0906S),((No0912S,No1103S),(No1007S,(No1208S,No0909S)))),No305);
+(((No0912S,No1103S),(((No1206S,(No0906S,(No0910S,No1202S))),(No0908S,((No304,No0913S),No306))),(No1007S,(No1208S,No0909S)))),No1114S,No305);
+((No304,(No306,((((No0909S,(No1007S,No1208S)),(No0912S,No1103S)),(No0908S,No1206S)),(No0906S,(No0913S,(No0910S,No1202S)))))),No1114S,No305);
+(((((No1208S,No0909S),No1007S),(No0912S,No1103S)),((((No0906S,(No0910S,No1202S)),No1206S),No0908S),(No306,(No304,No0913S)))),No1114S,No305);
+((((No0909S,(No1007S,No1208S)),(No0912S,No1103S)),(((No0906S,(No0910S,No1202S)),(No1206S,No0908S)),(No306,(No304,No0913S)))),No1114S,No305);
+((No0912S,(((((No0906S,(No0910S,No1202S)),No0908S),((No0909S,No1208S),No1007S)),((No306,(No304,No0913S)),No1206S)),No1103S)),No1114S,No305);
+((((((No0906S,(No0910S,No1202S)),No1206S),(No306,(No304,No0913S))),No0908S),((((No0909S,No1208S),No1007S),No1103S),No0912S)),No1114S,No305);
+(((((((No0913S,No1202S),No0910S),No0906S),(No0908S,No1206S)),(No306,No304)),(No1103S,(No0912S,((No0909S,No1208S),No1007S)))),No1114S,No305);
+(((No304,((No1206S,((No0913S,(No1202S,No0910S)),No0906S)),(No306,No0908S))),(((No0909S,No1208S),No1007S),(No1103S,No0912S))),No1114S,No305);
+(((((No1206S,((No0913S,(No1202S,No0910S)),No0906S)),No0908S),(No304,No306)),(((No0909S,No1208S),No1007S),(No1103S,No0912S))),No1114S,No305);
+((((No0908S,(No306,(No1206S,((No0913S,(No1202S,No0910S)),No0906S)))),(((No0909S,No1208S),No1007S),(No1103S,No0912S))),No304),No1114S,No305);
+(((((No0909S,No1208S),No1007S),(No1103S,No0912S)),((No306,(No0913S,No304)),(No0908S,(No1206S,((No1202S,No0910S),No0906S))))),No1114S,No305);
+(((No1103S,No0912S),(((No0909S,No1208S),No1007S),((No0908S,(No1206S,((No1202S,No0910S),No0906S))),(No306,(No0913S,No304))))),No1114S,No305);
+(No1114S,(((((No304,No0913S),No306),No0908S),(No1206S,(No0906S,(No1202S,No0910S)))),(No0912S,(No1103S,(No1007S,(No0909S,No1208S))))),No305);
+(No1114S,(((((No304,No0913S),No306),No0908S),(No1206S,(No0906S,(No1202S,No0910S)))),(No0912S,(No1103S,(No1007S,(No0909S,No1208S))))),No305);
+(No1114S,(((((No304,No0913S),No306),No0908S),(No1206S,(No0906S,(No1202S,No0910S)))),(No0912S,(No1103S,(No1007S,(No0909S,No1208S))))),No305);
+(No1114S,(((((No304,No0913S),No306),No0908S),(No1206S,(No0906S,(No1202S,No0910S)))),(No0912S,(No1103S,(No0909S,(No1208S,No1007S))))),No305);
+(No1114S,(No304,((((No0906S,(No0913S,(No1202S,No0910S))),No306),(No0908S,No1206S)),(No0912S,(No1103S,(No1208S,(No1007S,No0909S)))))),No305);
+(No1114S,(((No0908S,((No0906S,(No1202S,No0910S)),No1206S)),(No0912S,(No1103S,(No1007S,(No0909S,No1208S))))),((No304,No0913S),No306)),No305);
+(((No1007S,(No0909S,No1208S)),(No0912S,No1103S)),((((No1114S,(No304,No0913S)),No306),No0908S),((No0906S,(No1202S,No0910S)),No1206S)),No305);
+(No0912S,(No1103S,((((No306,((No1114S,No304),No0913S)),(No0906S,(No1202S,No0910S))),(No1206S,(No1007S,(No0909S,No1208S)))),No0908S)),No305);
+(((((No1206S,No0908S),(No306,No304)),(((No1202S,No0910S),No0913S),No0906S)),No1114S),((No0912S,No1103S),(No1208S,(No1007S,No0909S))),No305);
+(No1114S,((((No306,No304),(((No1202S,No0910S),No0913S),No0906S)),(No1206S,No0908S)),((No0912S,No1103S),(No1007S,(No0909S,No1208S)))),No305);
+(No1114S,(((((No304,No0913S),No306),No0908S),(No1206S,(No0906S,(No1202S,No0910S)))),(No0912S,(No1103S,(No1007S,(No0909S,No1208S))))),No305);
+(No1114S,((((No304,No0913S),No306),((No0908S,No1206S),(No0906S,(No1202S,No0910S)))),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No305);
+(No1114S,((No0912S,(((No0913S,(No306,No304)),No1103S),(No0908S,(No1206S,(No0906S,(No1202S,No0910S)))))),(No1007S,(No0909S,No1208S))),No305);
+(No1114S,(((No0908S,No1206S),(((No0913S,(No306,No304)),No0906S),(No1202S,No0910S))),(((No0909S,(No1208S,No1007S)),No0912S),No1103S)),No305);
+(No1114S,(((No0908S,No1206S),((No306,(No304,No0913S)),(No0906S,(No1202S,No0910S)))),((No0909S,(No1208S,No1007S)),(No0912S,No1103S))),No305);
+(No1114S,(((No0908S,No1206S),((No306,(No304,No0913S)),(No0906S,(No1202S,No0910S)))),((No0909S,(No1208S,No1007S)),(No0912S,No1103S))),No305);
+(((No1114S,(No306,(No304,No0913S))),((No1206S,(No0906S,(No1202S,No0910S))),No0908S)),((No0909S,(No1208S,No1007S)),(No0912S,No1103S)),No305);
+(No1114S,((No0909S,(No1208S,No1007S)),(((No306,(No304,No0913S)),((No0906S,((No1202S,No0910S),No1206S)),No0908S)),(No0912S,No1103S))),No305);
+(No1114S,(((No306,(No304,No0913S)),((No0908S,No1206S),(No0906S,(No1202S,No0910S)))),((No1007S,(No0909S,No1208S)),(No1103S,No0912S))),No305);
+(No1114S,(((((No1202S,No0910S),No0906S),No1206S),(No0908S,(No306,(No304,No0913S)))),((No1007S,(No0909S,No1208S)),(No1103S,No0912S))),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No0909S,No1208S))),(((No0906S,(No1202S,No0910S)),(No0908S,No1206S)),(No306,(No304,No0913S)))),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No0909S,No1208S))),((((No0906S,(No1202S,No0910S)),No1206S),No0908S),(No306,(No304,No0913S)))),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No0909S,No1208S))),((((No0906S,(No1202S,No0910S)),No1206S),No0908S),(No306,(No304,No0913S)))),No305);
+(No1114S,(((No0912S,No1103S),((No1007S,No1208S),No0909S)),((No0906S,(No1202S,No0910S)),((No306,(No304,No0913S)),(No1206S,No0908S)))),No305);
+(No1114S,(((No0912S,No1103S),((No1007S,No1208S),No0909S)),((No1206S,(No0906S,(No1202S,No0910S))),((No306,(No304,No0913S)),No0908S))),No305);
+(No1114S,(((No0912S,No1103S),((No1007S,No1208S),No0909S)),((No1206S,(No0906S,(No1202S,No0910S))),((No306,(No304,No0913S)),No0908S))),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No1208S,No0909S))),(No0908S,((No1206S,(No0906S,(No1202S,No0910S))),(No306,(No304,No0913S))))),No305);
+((No1208S,(No0909S,No1007S)),((No1114S,(No306,(No304,No0913S))),((No1206S,No0908S),(No1103S,((No0906S,(No1202S,No0910S)),No0912S)))),No305);
+((((((No1202S,No0910S),No0906S),(No1206S,No0908S)),(((No1208S,No1007S),No0909S),(No0912S,No1103S))),(No306,(No304,No0913S))),No1114S,No305);
+((((((No1202S,No0910S),No0906S),(No1206S,No0908S)),(((No1208S,No1007S),No0909S),(No0912S,No1103S))),(No306,(No304,No0913S))),No1114S,No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No0909S,No1208S))),(((No0906S,(No1202S,No0910S)),(No0908S,No1206S)),(No306,(No304,No0913S)))),No305);
+(No1114S,((No1007S,(No0909S,No1208S)),(((((No306,(No304,No0913S)),(No0908S,No1206S)),(No1202S,No0910S)),No0906S),(No0912S,No1103S))),No305);
+((((No1114S,((No304,No0913S),No306)),No0906S),((No0908S,No1206S),(No1202S,No0910S))),((No0912S,No1103S),(No1208S,(No1007S,No0909S))),No305);
+(No1114S,((No1007S,(No0909S,No1208S)),((((No304,No0913S),No306),(No0908S,(No1206S,(No0906S,(No1202S,No0910S))))),(No0912S,No1103S))),No305);
+((((No1206S,(No0906S,(No1202S,No0910S))),No0908S),(No1114S,((No304,No0913S),No306))),((No1007S,(No0909S,No1208S)),(No0912S,No1103S)),No305);
+(No1114S,((((No304,No0913S),No306),((No0908S,No1206S),((No1202S,No0910S),No0906S))),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No305);
+(No1114S,(((No1206S,((No1202S,No0910S),No0906S)),(No0908S,((No304,No0913S),No306))),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No305);
+(No1114S,((No0912S,No1103S),((((No1206S,((No1202S,No0910S),No0906S)),No0908S),((No304,No0913S),No306)),(No1007S,(No0909S,No1208S)))),No305);
+(No1114S,((((No1206S,((No1202S,No0910S),No0906S)),No0908S),((No304,No0913S),No306)),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No305);
+(No1114S,(((((No1202S,No0910S),No0906S),(No0908S,No1206S)),((No304,No0913S),No306)),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No305);
+(((((No0906S,(No1202S,No0910S)),No1206S),(No306,((No0913S,No304),No0908S))),(No0912S,(No1103S,(No1208S,(No1007S,No0909S))))),No1114S,No305);
+(((No0906S,((No306,(No0913S,No304)),((No0908S,No1206S),(No1202S,No0910S)))),((No0912S,(No0909S,(No1208S,No1007S))),No1103S)),No1114S,No305);
+(((((No1206S,(No0906S,(No1202S,No0910S))),No0908S),(No306,(No0913S,No304))),((No0912S,(No1007S,(No0909S,No1208S))),No1103S)),No1114S,No305);
+(((((No1206S,(No0906S,(No1202S,No0910S))),No0908S),(No306,(No0913S,No304))),((No0912S,(No1007S,(No0909S,No1208S))),No1103S)),No1114S,No305);
+((((((No1206S,No0908S),No0906S),(No1202S,No0910S)),(No306,(No0913S,No304))),(No0912S,((No1007S,(No0909S,No1208S)),No1103S))),No1114S,No305);
+((No304,((((No0908S,((No0909S,(No1208S,No1007S)),(No1103S,No0912S))),(No1206S,(No0906S,(No1202S,No0910S)))),No306),No0913S)),No1114S,No305);
+(((No0909S,(No1208S,No1007S)),(No1103S,No0912S)),(((No0908S,No1206S),(No0906S,(No1202S,No0910S))),(No306,(No1114S,(No0913S,No304)))),No305);
+((((No1103S,No0912S),(No0909S,(No1208S,No1007S))),(((No1206S,(No0906S,(No1202S,No0910S))),(No306,(No0913S,No304))),No0908S)),No1114S,No305);
+((((No1103S,No0912S),(No0909S,(No1208S,No1007S))),(((No1206S,(No0906S,(No1202S,No0910S))),(No306,(No0913S,No304))),No0908S)),No1114S,No305);
+(((No0906S,(No1202S,No0910S)),(((No1103S,No0912S),(No1007S,(No0909S,No1208S))),(No0908S,No1206S))),(No1114S,(No306,(No0913S,No304))),No305);
+((No304,(No306,(((No0912S,(No1103S,(No0909S,(No1208S,No1007S)))),(No0908S,No1206S)),(No0906S,(No0913S,(No1202S,No0910S)))))),No1114S,No305);
+((No304,((No306,((((No1202S,No0910S),No0906S),(No0912S,(No1103S,(No0909S,(No1208S,No1007S))))),(No0908S,No1206S))),No0913S)),No1114S,No305);
+((((No0912S,No1103S),(No0909S,(No1208S,No1007S))),((No0908S,No1206S),(((No0913S,No304),No306),((No1202S,No0910S),No0906S)))),No1114S,No305);
+((No0908S,(((No0913S,No304),No306),(((No0912S,No1103S),(No0909S,(No1208S,No1007S))),((No1202S,No0910S),(No1206S,No0906S))))),No1114S,No305);
+((((No0912S,No1103S),(No1007S,(No0909S,No1208S))),(((No0913S,No304),No306),((No0906S,(No1202S,No0910S)),(No0908S,No1206S)))),No1114S,No305);
+(((No1007S,(No0909S,No1208S)),((((((No1202S,No0910S),No0913S),No304),No306),((No0908S,No1206S),No0906S)),(No0912S,No1103S))),No1114S,No305);
+((No304,(No306,(((No0908S,((((No1208S,(No1007S,No0909S)),No0912S),No1103S),No1206S)),No0906S),((No1202S,No0910S),No0913S)))),No1114S,No305);
+((No304,(No306,(((((No1208S,(No1007S,No0909S)),No0912S),No1103S),(No1206S,No0908S)),(No0906S,(No1202S,(No0910S,No0913S)))))),No1114S,No305);
+((((No0909S,(No1208S,No1007S)),(No0912S,No1103S)),(((No304,No306),(No1206S,No0908S)),(No0906S,(No0913S,(No1202S,No0910S))))),No1114S,No305);
+((((No0909S,(No1208S,No1007S)),(No0912S,No1103S)),((No306,(No0913S,No304)),((No1206S,No0908S),(No0906S,(No1202S,No0910S))))),No1114S,No305);
+((((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),((No0908S,No1206S),(No0906S,(No1202S,No0910S)))),(No1114S,(No306,(No0913S,No304))),No305);
+(No1114S,(((No306,(No0913S,No304)),((No0908S,No1206S),(No0906S,(No1202S,No0910S)))),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No305);
+(No1114S,((No0912S,(((No306,(No0913S,No304)),((No1206S,(No0906S,(No1202S,No0910S))),No0908S)),(No1007S,(No1208S,No0909S)))),No1103S),No305);
+(No1114S,(No304,(((((No0906S,(No1202S,No0910S)),(No0908S,No1206S)),(((No1007S,(No1208S,No0909S)),No0912S),No1103S)),No306),No0913S)),No305);
+(No1114S,((((No1007S,(No1208S,No0909S)),No0912S),No1103S),((No306,(No0913S,No304)),((No0906S,(No1202S,No0910S)),(No0908S,No1206S)))),No305);
+(No1114S,((No0909S,(No1007S,No1208S)),((No0912S,No1103S),((No306,(No0913S,No304)),((No0908S,No1206S),(No0906S,(No1202S,No0910S)))))),No305);
+(No1114S,((No306,(No0913S,No304)),((No0908S,(No1206S,(No0906S,(No1202S,No0910S)))),(No1103S,(No0912S,(No1007S,(No1208S,No0909S)))))),No305);
+(No1114S,((No0913S,(((No0908S,(No1206S,(No0906S,(No1202S,No0910S)))),(((No1007S,(No1208S,No0909S)),No0912S),No1103S)),No306)),No304),No305);
+(No1114S,(((No1103S,No0912S),(No1007S,(No1208S,No0909S))),(No0908S,((No306,(No304,No0913S)),(No1206S,(No0906S,(No1202S,No0910S)))))),No305);
+(No1114S,(((No1103S,No0912S),(No1007S,(No1208S,No0909S))),(No0908S,((No306,(No304,No0913S)),(No1206S,(No0906S,(No1202S,No0910S)))))),No305);
+((((No0912S,(No0909S,(No1007S,No1208S))),No1103S),(((No304,No0913S),No306),(No0908S,(No1206S,(No0906S,(No0910S,No1202S)))))),No1114S,No305);
+((((No0912S,(No0909S,(No1007S,No1208S))),No1103S),(((No304,No0913S),No306),(No0908S,(No1206S,(No0906S,(No0910S,No1202S)))))),No1114S,No305);
+((((No1007S,(No1208S,No0909S)),(No1103S,No0912S)),(((No304,No0913S),No306),(No0908S,(No0906S,((No0910S,No1202S),No1206S))))),No1114S,No305);
+((((No1007S,(No1208S,No0909S)),(No1103S,No0912S)),((((No304,No0913S),No306),(No0906S,(No0910S,No1202S))),(No0908S,No1206S))),No1114S,No305);
+(((No0909S,(No1007S,No1208S)),((((No304,No0913S),No306),((No1206S,(No0906S,(No0910S,No1202S))),No0908S)),(No1103S,No0912S))),No1114S,No305);
+((No304,(No306,((No0913S,(No0906S,(No0910S,No1202S))),(((No1103S,No0912S),(No0909S,(No1007S,No1208S))),(No0908S,No1206S))))),No1114S,No305);
+((((No0909S,(No1007S,No1208S)),(No0908S,(((No306,No304),No0913S),(No0906S,((No0910S,No1202S),No1206S))))),(No0912S,No1103S)),No1114S,No305);
+(No0908S,((((No1007S,(No1208S,No0909S)),No0912S),No1103S),(((No0906S,(No1202S,No0910S)),No1206S),(No306,(No1114S,(No0913S,No304))))),No305);
+((((No1103S,No0912S),(No1208S,(No0909S,No1007S))),((No306,No304),((No0908S,No1206S),(No0906S,(No0913S,(No1202S,No0910S)))))),No1114S,No305);
+(((No0909S,(No1007S,No1208S)),(((No0908S,No1206S),((No0906S,(No1202S,No0910S)),(No306,(No0913S,No304)))),(No0912S,No1103S))),No1114S,No305);
+(((No0912S,(((No0906S,((No0910S,No1202S),No1206S)),(((No304,No0913S),No306),No0908S)),No1103S)),(No1007S,(No1208S,No0909S))),No1114S,No305);
+(((No0912S,No1103S),((No1007S,(No1208S,No0909S)),(((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),((No304,No0913S),No306)))),No1114S,No305);
+(((((No0908S,No1206S),(No0906S,(No0910S,No1202S))),((No304,No0913S),No306)),((No0912S,No1103S),(No1208S,(No0909S,No1007S)))),No1114S,No305);
+(((No0908S,(((No1206S,No0906S),(No0910S,No1202S)),((No304,No0913S),No306))),((No0912S,No1103S),(No0909S,(No1007S,No1208S)))),No1114S,No305);
+(No0908S,((No1206S,(No0906S,(No0910S,No1202S))),(((No1114S,(No304,No0913S)),No306),((No0912S,No1103S),(No0909S,(No1007S,No1208S))))),No305);
+(No1114S,(((((No0909S,No1007S),No1208S),No0912S),No1103S),((No306,(No304,No0913S)),((No0908S,No1206S),(No0906S,(No0910S,No1202S))))),No305);
+(No1114S,((((No1007S,(No1208S,No0909S)),No0912S),No1103S),(No0908S,((No306,(No304,No0913S)),(No1206S,((No0910S,No1202S),No0906S))))),No305);
+(No1114S,((((No1007S,(No1208S,No0909S)),No0912S),No1103S),(((No0910S,No1202S),No0906S),((No306,(No304,No0913S)),(No0908S,No1206S)))),No305);
+(No1114S,((No0909S,(No1007S,No1208S)),((No0912S,No1103S),((No306,(No304,No0913S)),(No0908S,(No1206S,((No0910S,No1202S),No0906S)))))),No305);
+(No1114S,(((((No1206S,((No0910S,No1202S),No0906S)),No0908S),No306),(No304,No0913S)),(((No0909S,(No1007S,No1208S)),No0912S),No1103S)),No305);
+(((No0912S,(No1103S,(No1007S,(No0909S,No1208S)))),(((No0913S,No304),No306),((No0906S,(No0910S,No1202S)),(No1206S,No0908S)))),No1114S,No305);
+((No0912S,(No1103S,(No1007S,(No0909S,No1208S)))),((No1114S,((No0913S,No304),No306)),(No0908S,((No0906S,(No0910S,No1202S)),No1206S))),No305);
+(No1114S,((((No0913S,No304),No306),(No0908S,((No0906S,(No0910S,No1202S)),No1206S))),((No0909S,(No1208S,No1007S)),(No0912S,No1103S))),No305);
+(No1114S,((No0912S,No1103S),((((No0913S,No304),No306),((No0906S,(No0910S,No1202S)),(No1206S,No0908S))),(No1007S,(No0909S,No1208S)))),No305);
+(No1114S,(((((No0906S,(No0910S,No1202S)),No1206S),(No0908S,((No0913S,No304),No306))),(No1007S,(No0909S,No1208S))),(No0912S,No1103S)),No305);
+(No1114S,(No304,((No306,(((No1007S,(No0909S,No1208S)),(No0912S,No1103S)),(((No0906S,(No0910S,No1202S)),No1206S),No0908S))),No0913S)),No305);
+(No1114S,((((No1007S,(No0909S,No1208S)),No0912S),No1103S),((((No0906S,(No0913S,(No0910S,No1202S))),No1206S),(No304,No0908S)),No306)),No305);
+(No1114S,(((No0909S,(No1208S,No1007S)),(No0912S,No1103S)),((No304,No306),(No0906S,((No0913S,(No0910S,No1202S)),(No0908S,No1206S))))),No305);
+(No1114S,(((No1206S,(No0906S,(No0910S,No1202S))),No0908S),(((No304,No0913S),No306),((No1007S,(No0909S,No1208S)),(No0912S,No1103S)))),No305);
+(No1114S,(((No1007S,(No0909S,No1208S)),(No0912S,No1103S)),((((No304,No0913S),No306),(No1206S,(No0906S,(No0910S,No1202S)))),No0908S)),No305);
+((((No0912S,No1103S),(No0908S,(((No0913S,No304),No306),(No1206S,(No0906S,(No0910S,No1202S)))))),(No1007S,(No0909S,No1208S))),No1114S,No305);
+((((No0908S,(No1206S,(No0906S,(No0910S,No1202S)))),((No0909S,(No1208S,No1007S)),(No0912S,No1103S))),((No0913S,No304),No306)),No1114S,No305);
+((((No0908S,(No1206S,(No0906S,(No0910S,No1202S)))),((No0909S,(No1208S,No1007S)),(No0912S,No1103S))),((No0913S,No304),No306)),No1114S,No305);
+((No0912S,No1103S),(((No1206S,((No0906S,(No0910S,No1202S)),((No1114S,(No0913S,No304)),No306))),No0908S),(No1007S,(No0909S,No1208S))),No305);
+(No1114S,((No0913S,No304),(No306,((No0908S,((No1206S,No0906S),(No0910S,No1202S))),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))))),No305);
+(No1114S,((No1007S,(No0909S,No1208S)),((No0912S,No1103S),((((No0910S,No1202S),No0906S),(No1206S,No0908S)),(No306,(No304,No0913S))))),No305);
+(No1114S,((No0912S,No1103S),(((((No1206S,No0908S),No0910S),(No1202S,(No306,(No304,No0913S)))),No0906S),(No1007S,(No0909S,No1208S)))),No305);
+(No1114S,((((No0913S,(No0906S,(No0910S,No1202S))),No306),((No1206S,No0908S),(((No0909S,(No1208S,No1007S)),No0912S),No1103S))),No304),No305);
+((((((No0906S,(No0910S,No1202S)),(No304,No0913S)),(No1206S,No0908S)),No306),(((No1007S,(No0909S,No1208S)),No0912S),No1103S)),No1114S,No305);
+((((((No1206S,No0906S),(No0910S,No1202S)),((No304,No0913S),No0908S)),No306),((No1208S,(No1007S,No0909S)),(No0912S,No1103S))),No1114S,No305);
+(No1114S,(((((No0912S,No1103S),(No1007S,(No0909S,No1208S))),(No0906S,((No0910S,No1202S),No1206S))),((No0913S,No304),No306)),No0908S),No305);
+(No1114S,(((((No0912S,No1103S),(No1007S,(No0909S,No1208S))),No0908S),(No1206S,(No0906S,(No0910S,No1202S)))),((No0913S,No304),No306)),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No0909S,No1208S))),(((No0908S,No1206S),((No0906S,(No0910S,No1202S)),(No0913S,No304))),No306)),No305);
+(No1114S,(No0912S,((((((No0908S,No1206S),No0906S),(No0910S,No1202S)),(No306,(No0913S,No304))),(No1007S,(No0909S,No1208S))),No1103S)),No305);
+(No1114S,(((No1206S,(No0906S,(No0910S,No1202S))),No0908S),(No306,(((No0912S,(No1007S,(No0909S,No1208S))),No1103S),(No0913S,No304)))),No305);
+(No1114S,(((No1208S,(No1007S,No0909S)),(No1103S,No0912S)),(No0908S,((No306,(No304,No0913S)),(No1206S,(No0906S,(No0910S,No1202S)))))),No305);
+(No1114S,((No1103S,No0912S),(((No0908S,(No306,(No304,No0913S))),(No1206S,(No0906S,(No0910S,No1202S)))),(No1007S,(No0909S,No1208S)))),No305);
+(No1114S,((No1007S,(No0909S,No1208S)),((No1103S,No0912S),(((No1206S,(No0906S,(No0910S,No1202S))),No0908S),(No306,(No304,No0913S))))),No305);
+(No1114S,((No1007S,(No0909S,No1208S)),((No1103S,No0912S),(((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),(No306,(No304,No0913S))))),No305);
+(No1114S,((((No0913S,(No0906S,(No0910S,No1202S))),(No0908S,No1206S)),(No306,No304)),((No0909S,(No1208S,No1007S)),(No1103S,No0912S))),No305);
+((((No1103S,(No0912S,((No1208S,No0909S),No1007S))),No0908S),(No1206S,(No0906S,(No0910S,No1202S)))),(((No0913S,No304),No306),No1114S),No305);
+(((((No1208S,No0909S),No1007S),(No1103S,No0912S)),((No0908S,No1206S),(((No0913S,No304),No306),(No0906S,(No0910S,No1202S))))),No1114S,No305);
+((((No0909S,(No1007S,No1208S)),(No1103S,No0912S)),(((No0913S,No304),No306),((No1206S,(No0906S,(No0910S,No1202S))),No0908S))),No1114S,No305);
+(((No0909S,(No1007S,No1208S)),(No0912S,(((No1114S,(No0913S,No304)),No306),(((No0910S,No1202S),(No0908S,No1206S)),No0906S)))),No1103S,No305);
+(No1114S,(((No0913S,No304),No306),(((No0908S,No1206S),((No0910S,No1202S),No0906S)),((No1208S,(No0909S,No1007S)),(No1103S,No0912S)))),No305);
+(No1114S,(((((No0913S,No304),No306),((No1206S,(No1202S,No0910S)),No0906S)),No0908S),((No1007S,(No1208S,No0909S)),(No1103S,No0912S))),No305);
+(No1114S,(((((No1202S,No0910S),No0906S),(No0908S,No1206S)),((No0913S,No304),No306)),((No1007S,(No1208S,No0909S)),(No1103S,No0912S))),No305);
+(No1114S,(((((No1202S,No0910S),No0906S),(No0908S,No1206S)),((No0913S,No304),No306)),((No1007S,(No1208S,No0909S)),(No1103S,No0912S))),No305);
+(No1114S,(((((No1202S,No0910S),No0906S),(No0908S,No1206S)),((No0913S,No304),No306)),((No1007S,(No1208S,No0909S)),(No1103S,No0912S))),No305);
+(No1114S,((No0909S,(No1007S,No1208S)),((No1103S,No0912S),((((No1202S,No0910S),No0906S),(No0908S,No1206S)),((No0913S,No304),No306)))),No305);
+((((No1103S,No0912S),(((No0913S,No304),No306),((No1206S,(No0906S,(No0910S,No1202S))),No0908S))),((No1208S,No0909S),No1007S)),No1114S,No305);
+(((No1103S,No0912S),(((No1206S,(No0906S,(No0910S,No1202S))),(No0908S,(No1208S,(No0909S,No1007S)))),((No0913S,No304),No306))),No1114S,No305);
+((((No1206S,(No0906S,(No0910S,No1202S))),(((No0913S,No304),No306),((No1103S,No0912S),(No1007S,(No1208S,No0909S))))),No0908S),No1114S,No305);
+(((No0912S,((No0909S,(No1007S,No1208S)),No1103S)),(((No0908S,No1206S),(No0906S,(No0910S,No1202S))),((No0913S,No304),No306))),No1114S,No305);
+(((No0912S,((No1007S,(No1208S,No0909S)),No1103S)),(((No1206S,(No0906S,(No0910S,No1202S))),((No0913S,No304),No306)),No0908S)),No1114S,No305);
+(((No1007S,(No1208S,No0909S)),((No1103S,No0912S),(((No1206S,(No0906S,(No0910S,No1202S))),((No0913S,No304),No306)),No0908S))),No1114S,No305);
+((((No0908S,No1206S),((No0910S,No1202S),No0906S)),(No1114S,((No0913S,No304),No306))),((No1103S,No0912S),(No0909S,(No1007S,No1208S))),No305);
+(No1114S,(((((No0908S,No1206S),No0906S),(((No0913S,No304),No306),(No0910S,No1202S))),(No1208S,(No0909S,No1007S))),(No1103S,No0912S)),No305);
+(No1114S,((No0906S,(((No0913S,No304),No306),((No0908S,No1206S),(No0910S,No1202S)))),((No0909S,(No1007S,No1208S)),(No1103S,No0912S))),No305);
+(No1114S,((((No0913S,No304),No306),((No0908S,No1206S),(No0906S,(No0910S,No1202S)))),((No0909S,(No1007S,No1208S)),(No1103S,No0912S))),No305);
+(((No0912S,No1103S),((No1007S,(No1208S,No0909S)),(((No306,(No304,No0913S)),No1206S),((No0906S,(No1202S,No0910S)),No0908S)))),No1114S,No305);
+((((No306,(No304,No0913S)),((No0908S,No1206S),(No0906S,(No1202S,No0910S)))),((No0912S,No1103S),(No1208S,(No0909S,No1007S)))),No1114S,No305);
+(((No1007S,(No1208S,No0909S)),((((No0908S,No1206S),(No0906S,(No1202S,No0910S))),(No306,(No304,No0913S))),(No0912S,No1103S))),No1114S,No305);
+(((((No0908S,No1206S),(No0906S,(No1202S,No0910S))),(No306,(No304,No0913S))),((No0912S,No1103S),(No0909S,(No1007S,No1208S)))),No1114S,No305);
+(((No1007S,(No1208S,No0909S)),(((((((No1202S,No0910S),No0906S),No1206S),No0908S),(No306,(No304,No0913S))),No0912S),No1103S)),No1114S,No305);
+(((No0908S,(No306,((No304,No0913S),((No0906S,No1202S),(No0910S,No1206S))))),(((No1007S,(No1208S,No0909S)),No0912S),No1103S)),No1114S,No305);
+((((No1007S,(No1208S,No0909S)),No0912S),No1103S),(No1114S,(((No1206S,No0908S),(No0913S,((No1202S,No0910S),No0906S))),(No306,No304))),No305);
+(No1114S,((((No1206S,No0906S),No0908S),(((No1202S,No0910S),(No304,No0913S)),No306)),(No0912S,(No1103S,(No1007S,(No1208S,No0909S))))),No305);
+((((No1114S,(No304,No0913S)),No306),((No1206S,No0908S),(No0906S,(No1202S,No0910S)))),((No0909S,(No1007S,No1208S)),(No0912S,No1103S)),No305);
+((((No304,No0913S),No306),((((No1007S,(No1208S,No0909S)),No0912S),No1103S),(No0908S,((No1206S,No0906S),(No1202S,No0910S))))),No1114S,No305);
+(No1114S,((No0912S,(No1103S,(No0909S,(No1007S,No1208S)))),((((No0910S,No1202S),No0906S),(No0908S,No1206S)),(No306,(No0913S,No304)))),No305);
+(No1114S,((No0912S,(No1103S,(No0909S,(No1007S,No1208S)))),(((((No0910S,No1202S),No0906S),No1206S),No0908S),(No306,(No0913S,No304)))),No305);
+(No1114S,((No0912S,(No1103S,(No0909S,(No1007S,No1208S)))),((((No0910S,No1202S),No0906S),(No1206S,No0908S)),(No306,(No0913S,No304)))),No305);
+((No0912S,No1103S),((No0909S,(No1007S,No1208S)),((((No0910S,No1202S),No0906S),(No1206S,No0908S)),(No1114S,(No306,(No0913S,No304))))),No305);
+(No1114S,(No306,((No0908S,(((No0912S,No1103S),(No1007S,(No1208S,No0909S))),((No0910S,No1202S),(No0913S,No304)))),(No1206S,No0906S))),No305);
+(No1114S,(No306,(((No0908S,(No1206S,((No0910S,No1202S),No0906S))),((No0912S,No1103S),(No1007S,(No1208S,No0909S)))),(No0913S,No304))),No305);
+(No1114S,((No1007S,(No1208S,No0909S)),(((((No0913S,No304),No306),No0908S),(No1206S,((No0910S,No1202S),No0906S))),(No0912S,No1103S))),No305);
+(No1114S,((((No0913S,No304),No306),(No0908S,(No1206S,((No0910S,No1202S),No0906S)))),((No0912S,No1103S),(No1208S,(No0909S,No1007S)))),No305);
+(No1114S,((((No0913S,No304),No306),(No0908S,(No1206S,((No0910S,No1202S),No0906S)))),((No0912S,No1103S),(No1208S,(No0909S,No1007S)))),No305);
+(No1114S,((((No0913S,No304),No306),(No0908S,(No1206S,((No0910S,No1202S),No0906S)))),((No0912S,No1103S),(No1007S,(No1208S,No0909S)))),No305);
+(No1114S,((No0912S,(No1103S,(No1007S,(No1208S,No0909S)))),(((((No0910S,No1202S),No0906S),No1206S),((No0913S,No304),No306)),No0908S)),No305);
+(No1114S,((No1007S,(No1208S,No0909S)),(No0912S,(((((No0910S,No1202S),No0906S),(No0908S,No1206S)),((No0913S,No304),No306)),No1103S))),No305);
+(No1114S,((((No1206S,((No0910S,No1202S),No0906S)),No0908S),((No0913S,No304),No306)),(((No1007S,(No1208S,No0909S)),No1103S),No0912S)),No305);
+(No1114S,((((No1206S,((No0910S,No1202S),No0906S)),No0908S),((No0913S,No304),No306)),(((No1007S,(No1208S,No0909S)),No1103S),No0912S)),No305);
+(No1114S,((((No1206S,((No0910S,No1202S),No0906S)),No0908S),((No0913S,No304),No306)),(((No1007S,(No1208S,No0909S)),No1103S),No0912S)),No305);
+(No1114S,((((No1206S,((No0910S,No1202S),No0906S)),No0908S),((No0913S,No304),No306)),(((No0909S,(No1007S,No1208S)),No1103S),No0912S)),No305);
+(No1114S,((No306,(No0913S,No304)),(((No0910S,No1202S),No0906S),(((No1007S,(No1208S,No0909S)),(No1103S,No0912S)),(No0908S,No1206S)))),No305);
+(No1114S,(((No0913S,No306),((((No0906S,(No0910S,No1202S)),No1206S),((No0909S,(No1007S,No1208S)),(No1103S,No0912S))),No0908S)),No304),No305);
+(No1114S,((No1103S,(No0912S,(No1007S,(No1208S,No0909S)))),(((No304,No0913S),No306),(No0908S,((No0906S,(No0910S,No1202S)),No1206S)))),No305);
+(No1114S,((No1103S,(No0912S,(No0909S,(No1007S,No1208S)))),(No306,((No0908S,((No0906S,(No0910S,No1202S)),No1206S)),(No304,No0913S)))),No305);
+(No1114S,((No1103S,(No0912S,(No1007S,(No0909S,No1208S)))),(No0908S,((No1206S,(No0906S,(No1202S,No0910S))),((No0913S,No304),No306)))),No305);
+(((No0909S,(No1208S,No1007S)),No1114S),(((((No0908S,No1206S),((No0910S,No1202S),No0906S)),((No0913S,No304),No306)),No1103S),No0912S),No305);
+((((No1103S,(No0912S,(No1007S,(No0909S,No1208S)))),((No0910S,No1202S),No0906S)),(No1206S,No0908S)),(No1114S,((No0913S,No304),No306)),No305);
+((((No1103S,No0912S),(No1007S,(No0909S,No1208S))),(((No0910S,No1202S),(No1206S,No0906S)),(No0908S,((No0913S,No304),No306)))),No1114S,No305);
+(((((No1007S,(No0909S,No1208S)),No0912S),No1103S),((((No0906S,No0910S),No1202S),(No0908S,No1206S)),((No0913S,No304),No306))),No1114S,No305);
+((((No0909S,(No1208S,No1007S)),No0912S),No1103S),(((((No0910S,No1202S),No1206S),No0906S),No0908S),((No0913S,(No1114S,No304)),No306)),No305);
+(((No0912S,(((No0908S,(((No0906S,No1202S),No0910S),No1206S)),((No0913S,No304),No306)),(No0909S,(No1208S,No1007S)))),No1103S),No1114S,No305);
+((No0908S,(((No0913S,No304),No306),(((No0906S,(No1007S,(No0909S,No1208S))),(No0912S,(No1202S,No0910S))),(No1206S,No1103S)))),No1114S,No305);
+(((No0912S,No1103S),(No0908S,(((No0913S,No304),No306),(No0906S,((No1202S,No0910S),No1206S))))),((No0909S,(No1208S,No1007S)),No1114S),No305);
+(No1114S,((No0912S,No1103S),(((No0906S,(No1202S,No0910S)),((No0908S,No1206S),((No0913S,No304),No306))),(No0909S,(No1208S,No1007S)))),No305);
+(No1114S,((No1103S,(No0912S,(No1007S,(No0909S,No1208S)))),(No0908S,((No1206S,(No0906S,(No1202S,No0910S))),((No0913S,No304),No306)))),No305);
+(No1114S,(((No1007S,(No0909S,No1208S)),(No1103S,No0912S)),(((No0908S,No1206S),(No0906S,(No1202S,No0910S))),((No0913S,No304),No306))),No305);
+(No1114S,(((No0909S,(No1208S,No1007S)),(No1103S,No0912S)),(((No0908S,No1206S),(No0906S,(No1202S,No0910S))),((No0913S,No304),No306))),No305);
+(No1114S,(((No0909S,(No1208S,No1007S)),(No1103S,No0912S)),(((No0908S,No1206S),(No0906S,(No1202S,No0910S))),((No0913S,No304),No306))),No305);
+(No1114S,((No1103S,No0912S),(((No0906S,(No1202S,No0910S)),((No0909S,(No1208S,No1007S)),(No0908S,No1206S))),((No0913S,No304),No306))),No305);
+(No1114S,(No1103S,(No0912S,((No0909S,(No1208S,No1007S)),(No0908S,(((No0913S,No304),No306),(No1206S,(No0906S,(No1202S,No0910S)))))))),No305);
+(No1114S,(((No1007S,(No0909S,No1208S)),((((((No1202S,No0910S),No0913S),No304),No306),No0906S),(No0908S,No1206S))),(No1103S,No0912S)),No305);
+(No1114S,((No0908S,(No1206S,(((No0913S,No304),No306),((No1202S,No0910S),No0906S)))),((No1103S,No0912S),(No0909S,(No1208S,No1007S)))),No305);
+(No1114S,(((((No0913S,No304),No306),((No1202S,No0910S),No0906S)),(No0908S,No1206S)),((No1103S,No0912S),(No0909S,(No1208S,No1007S)))),No305);
+((((No0908S,(No1206S,((No1202S,No0910S),No0906S))),((No0913S,No304),No306)),(No0912S,No1103S)),(No1114S,(No1007S,(No0909S,No1208S))),No305);
+(((No0909S,(No1208S,No1007S)),(No0912S,No1103S)),((No0908S,(No1206S,((No1202S,No0910S),No0906S))),(No1114S,(No306,(No0913S,No304)))),No305);
+(No1114S,(((No1206S,No0908S),(((No1202S,No0910S),No0906S),(No306,(No0913S,No304)))),((No0909S,(No1208S,No1007S)),(No0912S,No1103S))),No305);
+(No1114S,(((No306,(No0913S,No304)),(No0908S,(No1206S,((No1202S,No0910S),No0906S)))),((No0909S,(No1208S,No1007S)),(No0912S,No1103S))),No305);
+(No1114S,((No0909S,(No1208S,No1007S)),((No0912S,No1103S),((No0908S,(No1206S,((No1202S,No0910S),No0906S))),(No306,(No0913S,No304))))),No305);
+(No1114S,((((No306,No0913S),(((No1202S,No0910S),No0906S),(No0908S,No1206S))),((No0909S,(No1208S,No1007S)),(No0912S,No1103S))),No304),No305);
+(No1114S,((((No0909S,No1208S),No1007S),(No0912S,No1103S)),((No306,(No304,No0913S)),((((No1202S,No0910S),No0906S),No1206S),No0908S))),No305);
+(No1114S,((((No0909S,No1208S),No1007S),(No0912S,No1103S)),((No306,(No304,No0913S)),((((No1202S,No0910S),No0906S),No1206S),No0908S))),No305);
+(No1114S,(((No0909S,(No1208S,No1007S)),(No0912S,No1103S)),((No306,(No304,No0913S)),(((No1202S,No0910S),No0906S),(No1206S,No0908S)))),No305);
+(((No1103S,No0912S),(((No306,(No304,No0913S)),(((No1202S,No0910S),No0906S),(No1206S,No0908S))),(No0909S,(No1208S,No1007S)))),No1114S,No305);
+(((No1103S,No0912S),(((No306,(No304,No0913S)),(((No1202S,No0910S),No0906S),(No1206S,No0908S))),(No0909S,(No1208S,No1007S)))),No1114S,No305);
+((((No1007S,(No0909S,No1208S)),(No0912S,No1103S)),((No0908S,(No1206S,((No1202S,No0910S),No0906S))),(No306,(No0913S,No304)))),No1114S,No305);
+((((No1007S,(No0909S,No1208S)),(No0912S,No1103S)),((No0908S,(No1206S,((No1202S,No0910S),No0906S))),(No306,(No0913S,No304)))),No1114S,No305);
+((((No0909S,(No1208S,No1007S)),(No0912S,No1103S)),(((No0908S,No1206S),No0906S),(No306,(((No1202S,No0910S),No0913S),No304)))),No1114S,No305);
+(((No0913S,(No306,((((No1007S,(No0909S,No1208S)),(No0912S,No1103S)),(No0908S,No1206S)),(No0906S,(No1202S,No0910S))))),No304),No1114S,No305);
+((((No1206S,(No0913S,(No0906S,(No1202S,No0910S)))),(No306,(No0908S,((No0909S,(No1208S,No1007S)),(No0912S,No1103S))))),No304),No1114S,No305);
+(((No0908S,((No306,(No304,(No0913S,(No1202S,No0910S)))),(No0906S,No1206S))),((No0912S,No1103S),(No1208S,(No1007S,No0909S)))),No1114S,No305);
+((No304,((No306,((((No1202S,No0910S),No0906S),No1206S),(((No0912S,No1103S),(No0909S,(No1208S,No1007S))),No0908S))),No0913S)),No1114S,No305);
+(((No0912S,No1103S),(No1007S,(No0909S,No1208S))),((No0908S,(((No1202S,No0910S),No0906S),No1206S)),(No306,((No0913S,No304),No1114S))),No305);
+(No1114S,((((((((No1202S,No0910S),No0906S),No1206S),No306),No0908S),((No0912S,No1103S),(No1208S,(No1007S,No0909S)))),No0913S),No304),No305);
+(No1114S,(((No0912S,No1103S),(No0909S,(No1208S,No1007S))),((No306,(No0913S,No304)),((No1202S,((No1206S,No0906S),No0910S)),No0908S))),No305);
+(((No306,((No304,(No1206S,(No0906S,((No0910S,No1202S),No0913S)))),No0908S)),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No1114S,No305);
+((((No0908S,(No1206S,(No0906S,(No0910S,No1202S)))),((No0913S,No304),No306)),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No1114S,No305);
+((((No0908S,(No1206S,(No0906S,(No0910S,No1202S)))),((No0913S,No304),No306)),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No1114S,No305);
+((No304,((((No0906S,(No0913S,(No0910S,No1202S))),(No0908S,No1206S)),No306),((No1208S,(No1007S,No0909S)),(No0912S,No1103S)))),No1114S,No305);
+(((No1007S,(No0909S,No1208S)),(No0912S,(No1103S,((No0908S,((No1206S,(No0910S,No1202S)),No0906S)),((No304,No0913S),No306))))),No1114S,No305);
+((((No1007S,(No0909S,No1208S)),((No0908S,((No1206S,(No0910S,No1202S)),No0906S)),((No304,No0913S),No306))),(No0912S,No1103S)),No1114S,No305);
+((((((No0906S,(No0913S,(No0910S,No1202S))),No306),(No1206S,No0908S)),(((No1007S,No1208S),No0909S),(No0912S,No1103S))),No304),No1114S,No305);
+((((((No0913S,No304),No306),(No1206S,(No0906S,(No0910S,No1202S)))),No0908S),((No0912S,No1103S),(No1007S,(No1208S,No0909S)))),No1114S,No305);
+((((((No0913S,No304),No306),(No1206S,(No0906S,(No0910S,No1202S)))),No0908S),((No0912S,No1103S),(No1007S,(No1208S,No0909S)))),No1114S,No305);
+((((((No0913S,No304),No306),No0906S),((No0910S,No1202S),(No0908S,No1206S))),((No0912S,No1103S),(No1007S,(No1208S,No0909S)))),No1114S,No305);
+(No1114S,(No306,((((No0913S,No304),No0908S),((No1103S,(No1007S,(No0909S,No1208S))),No0912S)),(No1206S,(No0906S,(No0910S,No1202S))))),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No0909S,No1208S))),(No0908S,((No1206S,(No0906S,(No0910S,No1202S))),(No306,(No0913S,No304))))),No305);
+(No1114S,((No0912S,No1103S),((No1007S,(No0909S,No1208S)),((No306,(No0913S,No304)),(No0908S,(No1206S,(No0906S,(No0910S,No1202S))))))),No305);
+(No1114S,((No0912S,No1103S),((No1007S,(No0909S,No1208S)),((No306,(No0913S,No304)),(No0908S,(No1206S,(No0906S,(No0910S,No1202S))))))),No305);
+(No1114S,(((No306,(No0913S,No304)),((No0906S,(No0910S,No1202S)),(No0908S,No1206S))),((No0912S,No1103S),(No0909S,(No1208S,No1007S)))),No305);
+(No1114S,(((No306,(No0913S,No304)),((No0906S,(No0910S,No1202S)),(No0908S,No1206S))),((No0912S,No1103S),(No0909S,(No1208S,No1007S)))),No305);
+(No1114S,((No0909S,(No1208S,No1007S)),((((No306,(No0913S,No304)),(((No0910S,No1202S),No0906S),No1206S)),No0908S),(No0912S,No1103S))),No305);
+(No1114S,((No0912S,No1103S),((No0909S,(No1208S,No1007S)),((((No306,(No0913S,No304)),No0906S),(No0908S,(No0910S,No1202S))),No1206S))),No305);
+(No1114S,(((No0908S,(No306,(No0913S,No304))),(((No0910S,No1202S),No0906S),No1206S)),((No0912S,No1103S),(No1007S,(No0909S,No1208S)))),No305);
+(No1114S,((((No1206S,No0908S),((No0910S,No1202S),No0906S)),((No0912S,No1103S),(No1007S,(No0909S,No1208S)))),(No306,(No0913S,No304))),No305);
+(No1114S,(((((No0913S,No304),No306),((No0908S,No1206S),(No0906S,(No0910S,No1202S)))),(No1103S,No0912S)),((No1208S,No1007S),No0909S)),No305);
+((No304,((No0913S,No306),(No0908S,((No1206S,(No0906S,(No0910S,No1202S))),(((No1208S,No1007S),No0909S),(No0912S,No1103S)))))),No1114S,No305);
+(((No0912S,No1103S),((((No1206S,(No0906S,(No0910S,No1202S))),((No304,No0913S),No306)),No0908S),(No1007S,(No0909S,No1208S)))),No1114S,No305);
+(((((No1114S,No304),No0913S),No306),(No0908S,(No1206S,(No0906S,(No0910S,No1202S))))),((No0909S,(No1208S,No1007S)),(No0912S,No1103S)),No305);
+((((((No0910S,No1202S),(No1206S,No0906S)),No0908S),((No304,No0913S),No306)),(((No1007S,(No0909S,No1208S)),No0912S),No1103S)),No1114S,No305);
+((No0908S,((((No304,No0913S),No1114S),No306),((No0910S,No1202S),(No1206S,No0906S)))),((No1007S,(No0909S,No1208S)),(No0912S,No1103S)),No305);
+((((No0908S,((No0906S,(No0910S,No1202S)),No1206S)),((No304,No0913S),No306)),((No0912S,No1103S),(No1007S,(No0909S,No1208S)))),No1114S,No305);
+(((No1007S,(No0909S,No1208S)),((((No0906S,(No0910S,No1202S)),(No1206S,No0908S)),((No304,No0913S),No306)),(No0912S,No1103S))),No1114S,No305);
+(((No1007S,(No0909S,No1208S)),((((No0906S,(No0910S,No1202S)),(No1206S,No0908S)),((No304,No0913S),No306)),(No0912S,No1103S))),No1114S,No305);
+(((((No1206S,(No0906S,(No0910S,No1202S))),No0908S),((No304,No0913S),No306)),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No1114S,No305);
+((((No1007S,(No0909S,No1208S)),(No1103S,No0912S)),((No306,(No304,No0913S)),((No1206S,(No0906S,(No0910S,No1202S))),No0908S))),No1114S,No305);
+((((No1007S,(No0909S,No1208S)),(No1103S,No0912S)),((No306,(No304,No0913S)),((No1206S,(No0906S,(No0910S,No1202S))),No0908S))),No1114S,No305);
+((((No306,(No304,No0913S)),((No0906S,(No0910S,No1202S)),(No0908S,No1206S))),(((No1007S,(No0909S,No1208S)),No0912S),No1103S)),No1114S,No305);
+((((No306,(No304,No0913S)),((No0906S,(No0910S,No1202S)),(No0908S,No1206S))),(((No1007S,(No0909S,No1208S)),No0912S),No1103S)),No1114S,No305);
+((No0908S,(((((No1007S,(No0909S,No1208S)),No0912S),No1103S),(No306,(No1114S,(No304,No0913S)))),(No0906S,(No0910S,No1202S)))),No1206S,No305);
+(No1114S,((No306,(No304,No0913S)),(((((No1007S,(No0909S,No1208S)),No0912S),No1103S),No1206S),(No0908S,(No0906S,(No0910S,No1202S))))),No305);
+(No1114S,((No0912S,(No1103S,(No1007S,(No0909S,No1208S)))),((No0908S,(No1206S,(No0910S,(No0906S,No1202S)))),(No306,(No304,No0913S)))),No305);
+(No1114S,(((No1007S,(No0909S,No1208S)),(No0912S,No1103S)),(No0908S,((No306,No304),(No1206S,(No0906S,(No0913S,(No1202S,No0910S))))))),No305);
+(No1114S,((((((No1206S,(No0906S,(No0913S,(No1202S,No0910S)))),No0912S),(No1103S,No306)),No0908S),(No1007S,(No0909S,No1208S))),No304),No305);
+((((No304,No1114S),No0913S),No306),(((No0909S,(No1208S,No1007S)),(No1103S,No0912S)),((No1206S,(No0906S,(No1202S,No0910S))),No0908S)),No305);
+((((No1007S,(No0909S,No1208S)),(No1103S,No0912S)),(((No306,(No304,No0913S)),((No0910S,No1202S),No0906S)),(No1206S,No0908S))),No1114S,No305);
+((No1103S,(No0912S,(No0909S,(No1208S,No1007S)))),((No1114S,(No306,(No304,No0913S))),((No1206S,((No0910S,No1202S),No0906S)),No0908S)),No305);
+(No1114S,((No306,(No304,No0913S)),(((No0910S,No1202S),No0906S),((((No1208S,(No1007S,No0909S)),No0912S),No1103S),(No0908S,No1206S)))),No305);
+(No1114S,(((((((No0908S,No1206S),No0906S),(No306,(No304,No0913S))),(No0910S,No1202S)),(No0909S,(No1208S,No1007S))),No0912S),No1103S),No305);
+(No1114S,((No0909S,(No1208S,No1007S)),((No0912S,No1103S),((No304,No0913S),(((No0908S,No1206S),(No0906S,(No0910S,No1202S))),No306)))),No305);
+(No1114S,((((No0906S,((No0910S,No1202S),No1206S)),No0908S),((No304,No0913S),No306)),(((No0909S,(No1208S,No1007S)),No0912S),No1103S)),No305);
+(No1114S,((((No0906S,((No0910S,No1202S),No1206S)),No0908S),((No304,No0913S),No306)),(((No0909S,(No1208S,No1007S)),No0912S),No1103S)),No305);
+(No1114S,((((No0906S,((No0910S,No1202S),No1206S)),No0908S),((No304,No0913S),No306)),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No305);
+(No1114S,((((No0906S,((No0910S,No1202S),No1206S)),No0908S),((No304,No0913S),No306)),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No305);
+(No1114S,((No0912S,No1103S),((((((No0906S,No0910S),No1202S),No1206S),No0908S),((No304,No0913S),No306)),(No1007S,(No0909S,No1208S)))),No305);
+(No1114S,((No1103S,(No0912S,(No0909S,(No1208S,No1007S)))),(((No0913S,No304),No306),(No0908S,(No1206S,((No1202S,No0910S),No0906S))))),No305);
+(No1114S,((No1103S,No0912S),((No0909S,(No1208S,No1007S)),(((No0913S,No304),No306),(No0908S,(No1206S,((No1202S,No0910S),No0906S)))))),No305);
+((((No0913S,No304),No306),No1114S),(((No1103S,No0912S),((No0909S,No1208S),No1007S)),(No0908S,(No1206S,((No1202S,No0910S),No0906S)))),No305);
+(No1114S,(((No0912S,No1103S),((No0909S,No1208S),No1007S)),(No0908S,((No0906S,(No1206S,(No1202S,No0910S))),((No0913S,No304),No306)))),No305);
+(No1114S,((No0912S,No1103S),(((No0909S,No1208S),No1007S),(((No0906S,(No1202S,No0910S)),No1206S),(((No0913S,No304),No306),No0908S)))),No305);
+(No1114S,((((No0913S,No304),No306),(No0908S,((No0906S,(No1202S,No0910S)),No1206S))),((No0912S,No1103S),((No0909S,No1208S),No1007S))),No305);
+(No1114S,((((No0913S,No304),No306),(No0908S,((No0906S,(No1202S,No0910S)),No1206S))),((No0912S,No1103S),((No0909S,No1208S),No1007S))),No305);
+(No1114S,((((No0913S,No304),No306),(((No0906S,(No1202S,No0910S)),(No1206S,No0908S)),(No1103S,((No0909S,No1208S),No1007S)))),No0912S),No305);
+(No1114S,(((No0912S,No1103S),((No0909S,No1208S),No1007S)),((No0913S,(No304,No306)),(No0908S,((No0906S,(No1202S,No0910S)),No1206S)))),No305);
+(No1114S,(((No0912S,No1103S),((No0909S,No1208S),No1007S)),(((No306,(No0913S,No304)),(No0906S,(No1206S,No0908S))),(No1202S,No0910S))),No305);
+(No1114S,(No304,((No0913S,No306),(((No1007S,(No0909S,No1208S)),(No0912S,No1103S)),((No1206S,((No0910S,No1202S),No0906S)),No0908S)))),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No0909S,No1208S))),(((No0906S,(No1206S,(No0910S,No1202S))),No0908S),((No304,No0913S),No306))),No305);
+(No1114S,((No0912S,No1103S),((No0909S,(No1208S,No1007S)),(((No0906S,(No1202S,No0910S)),(No0908S,No1206S)),((No304,No0913S),No306)))),No305);
+(No1114S,(((No1206S,((No1202S,No0910S),No0906S)),(No0908S,((No304,No0913S),No306))),((No0912S,No1103S),(No1208S,(No1007S,No0909S)))),No305);
+(No1114S,(((No1206S,((No1202S,No0910S),No0906S)),(No0908S,((No304,No0913S),No306))),((No0912S,No1103S),((No1208S,No0909S),No1007S))),No305);
+(No1114S,(((No1206S,((No1202S,No0910S),No0906S)),(No0908S,((No304,No0913S),No306))),((No0912S,No1103S),((No1208S,No0909S),No1007S))),No305);
+(No1114S,(((No1206S,((No1202S,No0910S),No0906S)),(No0908S,((No304,No0913S),No306))),((No0912S,No1103S),((No1208S,No0909S),No1007S))),No305);
+(No1114S,(((No0906S,((No0908S,No1206S),(No1202S,No0910S))),((No304,No0913S),No306)),((No0912S,No1103S),((No1208S,No0909S),No1007S))),No305);
+(No1114S,(No304,((No0913S,No306),(No0908S,(((((No1208S,No0909S),No1007S),No0912S),No1103S),(No1206S,((No1202S,No0910S),No0906S)))))),No305);
+(No1114S,(((No304,No0913S),No306),((((No1202S,No0910S),No0906S),No1206S),(No0908S,((((No1208S,No0909S),No1007S),No0912S),No1103S)))),No305);
+(No1114S,((((No304,No0913S),No306),((No1206S,No0908S),((No0910S,No1202S),No0906S))),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No305);
+(No1114S,((No0912S,No1103S),(((((No0910S,No1202S),(No1206S,No0906S)),No0908S),((No304,No0913S),No306)),(No0909S,(No1208S,No1007S)))),No305);
+(No1114S,((((No0906S,(No1202S,No0910S)),(No1206S,No0908S)),((No304,No0913S),No306)),((No0909S,(No1208S,No1007S)),(No0912S,No1103S))),No305);
+(No1114S,((((No0906S,(No1202S,No0910S)),(No1206S,No0908S)),((No304,No0913S),No306)),((No0909S,(No1208S,No1007S)),(No0912S,No1103S))),No305);
+(No1114S,(((No1206S,((No1202S,No0910S),No0906S)),(No0908S,((No304,No0913S),No306))),(No0912S,(No1103S,(No0909S,(No1208S,No1007S))))),No305);
+(No1114S,(((No304,No0913S),No306),(((No0909S,(No1208S,No1007S)),(No0912S,No1103S)),((No0908S,No1206S),((No1202S,No0910S),No0906S)))),No305);
+(No1114S,((No1208S,(No1007S,No0909S)),((No0912S,No1103S),(No306,((No0908S,((No1202S,No0910S),((No304,No0913S),No1206S))),No0906S)))),No305);
+(((No0912S,((No1007S,(No0909S,No1208S)),No1103S)),((No1206S,((No1202S,No0910S),No0906S)),(No0908S,((No304,No0913S),No306)))),No1114S,No305);
+((((No0912S,No1103S),((((No1202S,No0910S),No0906S),(No0908S,No1206S)),((No304,No0913S),No306))),(No1007S,(No0909S,No1208S))),No1114S,No305);
+(No1114S,((No0912S,No1103S),((((No0908S,No1206S),((No1202S,No0910S),No0906S)),((No304,No0913S),No306)),(No0909S,(No1208S,No1007S)))),No305);
+((((((No0908S,(No0909S,(No1007S,No1208S))),((No0906S,(No0910S,No1202S)),No1206S)),((No0913S,No304),No306)),No0912S),No1103S),No1114S,No305);
+(((((No0910S,No1202S),No0906S),(((No0913S,No304),No306),(No0908S,No1206S))),((No1103S,No0912S),(No0909S,(No1007S,No1208S)))),No1114S,No305);
+(((((No0910S,No1202S),No0906S),(((No0913S,No304),No306),(No0908S,No1206S))),((No1103S,No0912S),(No0909S,(No1007S,No1208S)))),No1114S,No305);
+(((No1103S,No0912S),((No0909S,(No1007S,No1208S)),(((No0913S,No304),No306),((No0908S,No1206S),((No0910S,No1202S),No0906S))))),No1114S,No305);
+(((((No0913S,No304),No306),((No0908S,No1206S),((No0910S,No1202S),No0906S))),((No1103S,No0912S),(No1007S,(No1208S,No0909S)))),No1114S,No305);
+(((No1103S,No0912S),((No0909S,(No1007S,No1208S)),((((No0913S,(No0910S,No1202S)),No0906S),(No304,(No0908S,No1206S))),No306))),No1114S,No305);
+(((((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),((No0913S,No304),No306)),((No1103S,No0912S),(No0909S,(No1007S,No1208S)))),No1114S,No305);
+(((((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),((No0913S,No304),No306)),((No1103S,No0912S),(No0909S,(No1007S,No1208S)))),No1114S,No305);
+(((No1103S,No0912S),((No0909S,(No1007S,No1208S)),(((((No0910S,No1202S),No0906S),No1206S),No0908S),((No0913S,No304),No306)))),No1114S,No305);
+(((No0913S,No304),(No306,(((No1103S,No0912S),(No1007S,(No1208S,No0909S))),(((No0910S,No1202S),No0906S),(No1206S,No0908S))))),No1114S,No305);
+(((No0912S,No1103S),((((No0913S,No304),No306),(No0908S,(No0906S,((No0910S,No1202S),No1206S)))),(No1208S,(No0909S,No1007S)))),No1114S,No305);
+(((((No0913S,No304),No306),(No0908S,(No1206S,(No0906S,(No0910S,No1202S))))),((No0909S,(No1007S,No1208S)),(No0912S,No1103S))),No1114S,No305);
+(((((No0913S,No304),No306),((No0906S,(No0910S,No1202S)),(No0908S,No1206S))),((((No1007S,No1208S),No0912S),No1103S),No0909S)),No1114S,No305);
+((((No1208S,(No0909S,No1007S)),(No1103S,No0912S)),((No0913S,(No1114S,No304)),No306)),((No0908S,No1206S),(No0906S,(No0910S,No1202S))),No305);
+(No1114S,(((No1103S,No0912S),(No1007S,(No1208S,No0909S))),(((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),((No0913S,No304),No306))),No305);
+(No1114S,(((No1103S,No0912S),(No1007S,(No1208S,No0909S))),((No0908S,(No1206S,(No0906S,(No0910S,No1202S)))),((No0913S,No304),No306))),No305);
+((No1007S,(No1208S,No0909S)),((No1103S,((No0908S,(No1206S,(No0906S,(No0910S,No1202S)))),No0912S)),((No0913S,(No1114S,No304)),No306)),No305);
+((No304,((No1206S,(No0906S,(No0913S,(No0910S,No1202S)))),((((No1103S,No0912S),(No0909S,(No1007S,No1208S))),No0908S),No306))),No1114S,No305);
+((No0912S,((((No304,No0913S),No306),((No0908S,No1206S),(No0906S,(No0910S,((No1007S,(No1208S,No0909S)),No1202S))))),No1103S)),No1114S,No305);
+((((No1202S,No0910S),(((No304,No0913S),No306),((No0908S,No1206S),No0906S))),((No0909S,(No1007S,No1208S)),(No1103S,No0912S))),No1114S,No305);
+((((No306,(No304,No0913S)),(((No0910S,No1202S),No0906S),(No0908S,No1206S))),(((No1007S,(No1208S,No0909S)),No1103S),No0912S)),No1114S,No305);
+((((No306,(No304,No0913S)),(((No0910S,No1202S),No0906S),(No0908S,No1206S))),(((No1007S,(No1208S,No0909S)),No1103S),No0912S)),No1114S,No305);
+(((((((No0910S,No1202S),No0906S),No1206S),(No306,(No304,No0913S))),No0908S),((No1007S,(No1208S,No0909S)),(No1103S,No0912S))),No1114S,No305);
+(((((((No0910S,No1202S),No0906S),No1206S),(No306,(No304,No0913S))),No0908S),((No1007S,(No1208S,No0909S)),(No1103S,No0912S))),No1114S,No305);
+(((((No0910S,No1202S),No0906S),(No0908S,No1206S)),(No306,(No304,No0913S))),(((No0909S,(No1007S,(No1208S,No1114S))),No0912S),No1103S),No305);
+(No1114S,((No306,(No304,No0913S)),(((No0906S,(No0910S,No1202S)),No1206S),((((No1208S,(No1007S,No0909S)),No0912S),No1103S),No0908S))),No305);
+(No1114S,((((No1208S,(No1007S,No0909S)),No0912S),No1103S),(((No0910S,No1202S),No0908S),((No306,(No304,No0913S)),(No1206S,No0906S)))),No305);
+(No1114S,(((No0909S,(No1208S,No1007S)),(No0912S,No1103S)),((No306,(No304,No0913S)),((No0908S,No1206S),(No0906S,(No0910S,No1202S))))),No305);
+(No1114S,((No0912S,No1103S),(((No304,((No0906S,(No0910S,No1202S)),No0913S)),((No0908S,No1206S),No306)),(No1007S,(No0909S,No1208S)))),No305);
+(No1114S,((((No1007S,(No0909S,No1208S)),No0912S),No1103S),(No0908S,(((No0913S,No304),No306),(No1206S,((No1202S,No0910S),No0906S))))),No305);
+(No1114S,((No0912S,No1103S),((No0909S,(No1007S,No1208S)),((No306,(No304,No0913S)),((No0906S,(No1202S,No0910S)),(No1206S,No0908S))))),No305);
+(No1114S,(((No0908S,((No0906S,(No1202S,No0910S)),No1206S)),(No306,(No304,No0913S))),((No0912S,No1103S),(No1007S,(No1208S,No0909S)))),No305);
+(No1114S,((((No0906S,(No1202S,No0910S)),(No1206S,No0908S)),(No306,(No304,No0913S))),((No0912S,No1103S),(No0909S,(No1007S,No1208S)))),No305);
+(No1114S,((No0912S,No1103S),((No1007S,(No1208S,No0909S)),(((No0906S,(No1202S,No0910S)),(No1206S,No0908S)),(No0913S,(No306,No304))))),No305);
+((((No0906S,(No1202S,No0910S)),(No1206S,No0908S)),(No306,((No1114S,No304),No0913S))),((No0912S,No1103S),(No0909S,(No1007S,No1208S))),No305);
+((No304,(((No0906S,((No1202S,No0910S),No0913S)),(((No0912S,No1103S),(No1208S,(No0909S,No1007S))),(No1206S,No0908S))),No306)),No1114S,No305);
+(((No0912S,No1103S),((No0908S,(No1206S,(No0906S,(No1202S,No0910S)))),(No306,(No0913S,No304)))),((No1007S,(No1208S,No0909S)),No1114S),No305);
+(((No1206S,No0908S),((No306,(No0913S,No304)),((No1202S,No0910S),No0906S))),(No1114S,((No1103S,No0912S),(No1007S,(No1208S,No0909S)))),No305);
+(No1114S,(((No0908S,((No306,(No0913S,No304)),((No1202S,No0910S),(No1206S,No0906S)))),(No0912S,No1103S)),(No1007S,(No1208S,No0909S))),No305);
+(No1114S,((No0908S,(((No306,(No0913S,No304)),((No1202S,No0910S),No1206S)),No0906S)),((No0909S,(No1007S,No1208S)),(No0912S,No1103S))),No305);
+(((No0912S,No1103S),(No0909S,(No1007S,No1208S))),((No0908S,((No0906S,(No1202S,No0910S)),No1206S)),(No1114S,(No306,(No304,No0913S)))),No305);
+(No1114S,(((No0908S,(((No0906S,No0910S),No1202S),No1206S)),((No0912S,No1103S),(No0909S,(No1007S,No1208S)))),(No306,(No304,No0913S))),No305);
+(No1114S,((((No0910S,(No0906S,(No0908S,No1206S))),No1202S),((No0912S,No1103S),(No1007S,(No1208S,No0909S)))),(No304,(No0913S,No306))),No305);
+(No1114S,((No0912S,No1103S),((No0909S,(No1007S,No1208S)),((((No304,No0913S),No306),No0908S),(No1206S,((No1202S,No0910S),No0906S))))),No305);
+(((No0912S,No1103S),(No1208S,(No0909S,No1007S))),((No0908S,(No1206S,((No1202S,No0910S),No0906S))),(((No1114S,No304),No0913S),No306)),No305);
+((((No0912S,No1103S),(No1007S,(No1208S,No0909S))),((No1206S,((No1202S,No0910S),No0906S)),(((No304,No0913S),No306),No0908S))),No1114S,No305);
+(((No0912S,No1103S),((No0909S,(No1007S,No1208S)),((No306,((No0906S,(No1206S,(No1202S,No0910S))),No0908S)),(No304,No0913S)))),No1114S,No305);
+(((((No306,(No1103S,((No1202S,No0910S),No0913S))),((No0906S,(No1208S,(No0909S,No1007S))),(No0908S,No1206S))),No0912S),No304),No1114S,No305);
+((((No306,((No0912S,No1103S),(No0908S,No1206S))),(No0906S,((No1202S,No0910S),No0913S))),No304),((No1007S,(No1208S,No0909S)),No1114S),No305);
+(No1114S,(((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),(((No0913S,No304),No306),((No0906S,(No1202S,No0910S)),(No0908S,No1206S)))),No305);
+(No1114S,(((No1007S,(No1208S,No0909S)),(No1103S,No0912S)),(((No0913S,No304),No306),(No0908S,((No1206S,No0906S),(No0910S,No1202S))))),No305);
+(No1114S,((No0909S,(No1007S,No1208S)),((No1103S,No0912S),(((No0913S,No304),No306),(No0908S,(No0906S,((No0910S,No1202S),No1206S)))))),No305);
+(No1114S,(((No1103S,No0912S),(No1007S,(No1208S,No0909S))),(((No0906S,(No0910S,No1202S)),((No0913S,No304),No306)),(No0908S,No1206S))),No305);
+(No1114S,(((No1103S,No0912S),(No1007S,(No1208S,No0909S))),(((No0906S,(No0910S,No1202S)),((No0913S,No304),No306)),(No0908S,No1206S))),No305);
+(No1114S,(((No1103S,No0912S),(No0909S,(No1007S,No1208S))),(((No0913S,No304),No306),((No0908S,No1206S),(No0906S,(No0910S,No1202S))))),No305);
+(No1114S,(((No1103S,No0912S),(No1007S,(No1208S,No0909S))),((((No0913S,No304),No306),(((No0910S,No1202S),No0906S),No1206S)),No0908S)),No305);
+(No1114S,(((No1103S,No0912S),(No0909S,(No1007S,No1208S))),(((((No0913S,No304),No306),(No0910S,No1202S)),(No1206S,No0906S)),No0908S)),No305);
+(No1114S,(((No1103S,No0912S),(No0909S,(No1007S,No1208S))),((((No0913S,No304),No306),(No0906S,(No0910S,No1202S))),(No1206S,No0908S))),No305);
+(No1114S,(((No1103S,No0912S),(No0909S,(No1007S,No1208S))),((((No0913S,No304),No306),(No0906S,(No0910S,No1202S))),(No1206S,No0908S))),No305);
+(No1114S,(No304,(No0913S,(No306,(((No1206S,No0908S),(No0906S,(No0910S,No1202S))),((No1103S,No0912S),(No1007S,(No1208S,No0909S))))))),No305);
+((((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),((No0908S,(No1206S,(No0906S,(No0910S,No1202S)))),((No0913S,No304),No306))),No1114S,No305);
+((((No0909S,(No1007S,No1208S)),(No0912S,No1103S)),((No1206S,((No0908S,No0906S),(No0910S,No1202S))),((No0913S,No304),No306))),No1114S,No305);
+((No0912S,((((No0906S,(No0910S,No1202S)),((No1206S,No0908S),((No0913S,No304),No306))),(No0909S,(No1007S,No1208S))),No1103S)),No1114S,No305);
+(((No0906S,(((No1206S,No0908S),((No0910S,No1202S),(No0913S,No304))),No306)),((No1103S,No0912S),(No0909S,(No1007S,No1208S)))),No1114S,No305);
+(((No1103S,No0912S),((No1007S,(No1208S,No0909S)),(((No1202S,(No0906S,No0910S)),(No306,(No0913S,No304))),(No1206S,No0908S)))),No1114S,No305);
+(((No0909S,(No1007S,No1208S)),((((No0906S,(No0913S,(No0910S,No1202S))),(No306,No304)),(No1206S,No0908S)),(No1103S,No0912S))),No1114S,No305);
+(((((No0906S,(No0910S,No1202S)),(No306,(No0913S,No304))),(No1206S,No0908S)),((No0909S,(No1007S,No1208S)),(No0912S,No1103S))),No1114S,No305);
+(((((((No0906S,(No0910S,No1202S)),No0912S),No1103S),(No0908S,No1206S)),(No306,(No0913S,No304))),(No1007S,(No1208S,No0909S))),No1114S,No305);
+(((((No306,(No0913S,No304)),((No0910S,No1202S),((No0908S,No1206S),No0906S))),No1103S),No0912S),((No0909S,(No1007S,No1208S)),No1114S),No305);
+(((((No1206S,(No0906S,(No0910S,No1202S))),No0908S),(No306,(No0913S,No304))),((No1103S,No0912S),(No0909S,(No1007S,No1208S)))),No1114S,No305);
+((((No0909S,(No1007S,No1208S)),(No0912S,No1103S)),(((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),(No306,(No304,No0913S)))),No1114S,No305);
+((((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),((No0908S,(No1206S,(No0906S,(No0910S,No1202S)))),(No306,(No304,No0913S)))),No1114S,No305);
+((((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),(((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),(No306,(No304,No0913S)))),No1114S,No305);
+((((No1208S,(No0909S,No1007S)),(No0912S,No1103S)),((((No0906S,(No0910S,No1202S)),No1206S),(No306,(No304,No0913S))),No0908S)),No1114S,No305);
+((((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),(((No0906S,(No0910S,No1202S)),No1206S),((No306,(No304,No0913S)),No0908S))),No1114S,No305);
+((((No0909S,(No1007S,No1208S)),(No0912S,No1103S)),(No306,((No304,No0913S),(No0908S,((No0906S,(No0910S,No1202S)),No1206S))))),No1114S,No305);
+(((No0912S,No1103S),((((No304,No0913S),No306),(No0908S,No1206S)),((No0906S,(No0910S,No1202S)),(No1007S,(No1208S,No0909S))))),No1114S,No305);
+(((No0909S,(No1007S,No1208S)),(((((No304,No0913S),No306),No0908S),(No1206S,(No0906S,(No0910S,No1202S)))),(No0912S,No1103S))),No1114S,No305);
+(((((No304,No0913S),No306),((No0908S,No1206S),(No0906S,(No0910S,No1202S)))),((No0909S,(No1007S,No1208S)),(No1103S,No0912S))),No1114S,No305);
+(((((No1206S,(No0906S,(No0910S,No1202S))),No0908S),((No304,No0913S),No306)),((No1007S,(No1208S,No0909S)),(No1103S,No0912S))),No1114S,No305);
+(No1114S,((((No0906S,(No0910S,No1202S)),((((No304,No0913S),No306),No0908S),(((No1208S,No1007S),No0909S),No1206S))),No1103S),No0912S),No305);
+((No0909S,(No1208S,No1007S)),((No1103S,((No0908S,No0912S),((No0906S,(No0910S,No1202S)),No1206S))),(No1114S,((No304,No0913S),No306))),No305);
+(No1114S,((((No304,No0913S),No306),((No0906S,(No0910S,No1202S)),(No0908S,No1206S))),(No0912S,(No1103S,(No0909S,(No1208S,No1007S))))),No305);
+(No1114S,(((((No0906S,No1206S),(No1202S,No0910S)),(No0912S,(No1103S,(No1007S,(No0909S,No1208S))))),No0908S),((No304,No0913S),No306)),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No0909S,No1208S))),((((No304,No0913S),No306),((No1202S,No0910S),No0906S)),(No0908S,No1206S))),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No0909S,No1208S))),((((No304,No0913S),No306),((No1202S,No0910S),No0906S)),(No0908S,No1206S))),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No0909S,No1208S))),((((No304,No0913S),No306),((No1202S,No0910S),No0906S)),(No0908S,No1206S))),No305);
+(((No1007S,(No0909S,No1208S)),No1114S),((No0912S,No1103S),(((No304,No0913S),No306),((No1206S,((No1202S,No0910S),No0906S)),No0908S))),No305);
+(No1114S,((No0912S,No1103S),((No0908S,(No1206S,((No1202S,No0910S),No0906S))),((No1007S,(No0909S,No1208S)),((No304,No0913S),No306)))),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No0909S,No1208S))),(((No304,No0913S),No306),(No0908S,(No0906S,(No1206S,(No1202S,No0910S)))))),No305);
+(No1114S,((((No1208S,No1007S),No0909S),(No0912S,No1103S)),(((No1206S,No0908S),No0906S),((No0910S,No1202S),((No304,No0913S),No306)))),No305);
+(No1114S,(((No1007S,(No0909S,No1208S)),(No0912S,No1103S)),(((No1206S,No0908S),(No0906S,(No0913S,(No0910S,No1202S)))),(No304,No306))),No305);
+(No1114S,((No0912S,No1103S),(No306,((No1007S,(No0909S,No1208S)),((No0908S,No304),(No1206S,(No0906S,((No0910S,No1202S),No0913S))))))),No305);
+(No1114S,(((No1007S,(No0909S,No1208S)),(No0912S,No1103S)),((((No0913S,No304),No306),(No0906S,(No0910S,No1202S))),(No1206S,No0908S))),No305);
+(No1114S,((No0912S,No1103S),((((No0913S,No304),No306),(((No0906S,(No0910S,No1202S)),No1206S),No0908S)),(No0909S,(No1208S,No1007S)))),No305);
+(No1114S,((((No0913S,No304),No306),(((No0906S,(No0910S,No1202S)),No1206S),No0908S)),((No1208S,(No1007S,No0909S)),(No0912S,No1103S))),No305);
+(No1114S,((((No0910S,No1202S),No0906S),(((No0913S,No304),No306),(No1206S,No0908S))),((No1208S,(No1007S,No0909S)),(No0912S,No1103S))),No305);
+(No1114S,((((No0910S,No1202S),No0906S),(((No0913S,No304),No306),(No1206S,No0908S))),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No305);
+(No1114S,((((No0910S,No1202S),No0906S),(((No0913S,No304),No306),(No1206S,No0908S))),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No305);
+((No0908S,(((No1007S,(No0909S,No1208S)),(No0912S,No1103S)),(No1206S,((No0910S,No1202S),No0906S)))),(No1114S,((No0913S,No304),No306)),No305);
+(No1114S,(((No0912S,No1103S),((No1208S,No1007S),No0909S)),(((No304,No0913S),No306),((No1206S,No0908S),(No0906S,(No0910S,No1202S))))),No305);
+(No1114S,(((No0912S,No1103S),((No1208S,No1007S),No0909S)),(((No304,No0913S),No306),((No1206S,No0908S),(No0906S,(No0910S,No1202S))))),No305);
+(No1114S,(((No0912S,No1103S),((No1208S,No1007S),No0909S)),(((No304,No0913S),No306),(No0908S,((No0906S,(No0910S,No1202S)),No1206S)))),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No0909S,No1208S))),(((No304,No0913S),No306),(No0908S,(((No0906S,No1202S),No1206S),No0910S)))),No305);
+(No1114S,((No0912S,No1103S),((((No304,No0913S),No306),(No0909S,(No1208S,No1007S))),(No0908S,((No0906S,(No1202S,No0910S)),No1206S)))),No305);
+((((No0906S,(No1202S,No0910S)),(No1206S,No0908S)),((No1114S,(No304,No0913S)),No306)),(No1103S,((No0909S,(No1208S,No1007S)),No0912S)),No305);
+((((No0906S,(No1202S,No0910S)),(No1206S,No0908S)),((No306,(No0913S,No304)),No1114S)),(No1103S,((No0909S,(No1208S,No1007S)),No0912S)),No305);
+(No1114S,((((No0906S,(No1202S,No0910S)),(No1206S,No0908S)),(No306,(No0913S,No304))),((No1208S,(No1007S,No0909S)),(No0912S,No1103S))),No305);
+(No1114S,(((No0906S,(No1206S,No0908S)),(No306,(((No1202S,No0910S),No0913S),No304))),((No0909S,(No1208S,No1007S)),(No0912S,No1103S))),No305);
+(No1114S,(((No0913S,No304),No306),(((No1007S,(No0909S,No1208S)),(No0912S,No1103S)),(No0908S,(((No1202S,No0910S),No0906S),No1206S)))),No305);
+(No1114S,(((No0908S,(No1206S,(No0906S,(No0910S,No1202S)))),((No0913S,No304),No306)),((No1007S,(No1208S,No0909S)),(No1103S,No0912S))),No305);
+(No1114S,(((No0908S,(No1206S,(No0906S,(No0910S,No1202S)))),((No0913S,No304),No306)),((No0909S,(No1007S,No1208S)),(No1103S,No0912S))),No305);
+(No1114S,(((No0908S,(No1206S,(No0906S,(No0910S,No1202S)))),((No0913S,No304),No306)),((No1007S,(No1208S,No0909S)),(No1103S,No0912S))),No305);
+(No1114S,((No0909S,(No1007S,No1208S)),((No1103S,No0912S),(No306,((No0908S,(No1206S,(No0906S,(No0913S,(No0910S,No1202S))))),No304)))),No305);
+(No1114S,((No306,((No0913S,No304),((No1206S,(No0906S,(No0910S,No1202S))),No0908S))),((No0909S,(No1007S,No1208S)),(No0912S,No1103S))),No305);
+(No1114S,((((No1206S,(No0906S,(No0910S,No1202S))),No0908S),(No306,(No304,No0913S))),((No0909S,(No1007S,No1208S)),(No0912S,No1103S))),No305);
+(No1114S,((No0909S,(No1007S,No1208S)),((No0912S,No1103S),(((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),(No306,(No304,No0913S))))),No305);
+(No1114S,((((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),(No306,(No304,No0913S))),(((No1208S,(No0909S,No1007S)),No0912S),No1103S)),No305);
+(No1114S,((((No1206S,((No0910S,No1202S),No0906S)),No0908S),(No306,(No304,No0913S))),((No0909S,(No1007S,No1208S)),(No0912S,No1103S))),No305);
+(No1114S,((((No1206S,((No0910S,No1202S),No0906S)),No0908S),(No306,(No304,No0913S))),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No305);
+(No1114S,(((No0906S,((No0910S,No1202S),((No304,No306),No0913S))),(No0908S,No1206S)),((No0909S,(No1007S,No1208S)),(No1103S,No0912S))),No305);
+(No1114S,((((No304,No306),No0913S),((No0906S,(No0910S,No1202S)),(No0908S,No1206S))),((No1208S,(No0909S,No1007S)),(No1103S,No0912S))),No305);
+(No1114S,(No304,(((((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),((No0909S,(No1007S,No1208S)),(No1103S,No0912S))),No306),No0913S)),No305);
+(No1114S,((((No0909S,(No1007S,No1208S)),No0912S),No1103S),((No306,((No0913S,No304),((No1202S,(No1206S,No0910S)),No0906S))),No0908S)),No305);
+(No1114S,((((No1007S,(No1208S,No0909S)),No0912S),No1103S),((No306,(No0913S,No304)),(((No1202S,No0910S),No0906S),(No0908S,No1206S)))),No305);
+(No1114S,((No0912S,(No1208S,(No0909S,(No1103S,No1007S)))),(((No306,(No0913S,No304)),(No1206S,((No1202S,No0910S),No0906S))),No0908S)),No305);
+(No1114S,(((No0912S,(No0909S,(No1007S,No1208S))),No1103S),((((No1202S,No0910S),No0906S),(No1206S,No0908S)),(No306,(No0913S,No304)))),No305);
+(No1114S,((No0912S,((((((No1202S,No0910S),No1206S),No0906S),((No0913S,No304),No0908S)),No306),(No1007S,(No1208S,No0909S)))),No1103S),No305);
+((No0909S,((No1114S,No1007S),No1208S)),((No0912S,No1103S),((No306,(No0913S,No304)),(No0908S,(No1206S,(No0906S,(No1202S,No0910S)))))),No305);
+((((No0909S,(No1007S,No1208S)),(No0912S,No1103S)),(((No1206S,(No0906S,(No1202S,No0910S))),No0908S),(No306,(No0913S,No304)))),No1114S,No305);
+(((No1103S,(No0912S,(No1007S,(No0909S,No1208S)))),(((No306,(No304,No0913S)),((No0906S,(No0910S,No1202S)),No1206S)),No0908S)),No1114S,No305);
+((((No0909S,(No1208S,No1007S)),(((No0906S,(No0910S,No1202S)),No1206S),(No0908S,(No306,(No304,No0913S))))),(No0912S,No1103S)),No1114S,No305);
+(((((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),(No306,(No304,No0913S))),((No0912S,No1103S),(No1208S,(No1007S,No0909S)))),No1114S,No305);
+(((No0912S,No1103S),((No0909S,(No1208S,No1007S)),((((No0906S,(No0910S,No1202S)),No1206S),No0908S),(No306,(No304,No0913S))))),No1114S,No305);
+((((((No0906S,(No0913S,(No0910S,No1202S))),(No1206S,No0908S)),No306),((No0912S,No1103S),(No1007S,(No0909S,No1208S)))),No304),No1114S,No305);
+(((No0912S,No1103S),((No0909S,(No1208S,No1007S)),(((No304,No306),(No1206S,No0908S)),(No0906S,(No0913S,(No0910S,No1202S)))))),No1114S,No305);
+(((((No0910S,(No0906S,No1202S)),(No1206S,No0908S)),((No304,No0913S),No306)),((No0912S,No1103S),(No1007S,(No0909S,No1208S)))),No1114S,No305);
+((((No306,((((No0910S,No1202S),No1206S),No0906S),(No304,No0913S))),No0908S),((No0912S,No1103S),(No1007S,(No0909S,No1208S)))),No1114S,No305);
+(((No0912S,No1103S),(((No0909S,No1208S),No1007S),((No0908S,(No1206S,(No0906S,(No0910S,No1202S)))),((No304,No0913S),No306)))),No1114S,No305);
+(((No0908S,(No1206S,(No0906S,(No0910S,No1202S)))),((No0912S,No1103S),(No0909S,(No1208S,No1007S)))),(((No304,No0913S),No306),No1114S),No305);
+(((No1103S,(No0912S,(No1007S,(No0909S,No1208S)))),(((No306,(No304,No0913S)),((No0906S,(No0910S,No1202S)),No1206S)),No0908S)),No1114S,No305);
+((No1103S,(No0912S,(No0909S,(No1208S,No1007S)))),((No306,(No1114S,(No304,No0913S))),((No0906S,(No0910S,No1202S)),(No0908S,No1206S))),No305);
+((No1103S,(No0912S,((No0909S,(No1208S,No1007S)),((No1206S,(No306,(No304,No0913S))),((No0906S,(No0910S,No1202S)),No0908S))))),No1114S,No305);
+(((((No0908S,No1206S),(No306,(No304,No0913S))),(No0906S,(No0910S,No1202S))),((No1103S,No0912S),(No1007S,(No0909S,No1208S)))),No1114S,No305);
+((((No306,((No304,No0913S),No0908S)),((No1206S,No0906S),(No0910S,No1202S))),((No1103S,No0912S),(No1007S,(No0909S,No1208S)))),No1114S,No305);
+((((No1103S,No0912S),(No1208S,(No1007S,No0909S))),(((No1206S,(No306,(No304,No0913S))),((No0908S,No1202S),No0906S)),No0910S)),No1114S,No305);
+((No304,((No306,(((No1007S,(No0909S,No1208S)),(No1103S,No0912S)),((No1206S,No0908S),((No0910S,No1202S),No0906S)))),No0913S)),No1114S,No305);
+(((No1103S,(No0912S,(No0909S,(No1208S,No1007S)))),(No0908S,(((No0910S,No1202S),No0906S),No1206S))),(No1114S,((No0913S,No304),No306)),No305);
+(No1114S,(((No0908S,(((No0910S,No1202S),No0906S),No1206S)),(((No1007S,(No0909S,No1208S)),No0912S),No1103S)),((No0913S,No304),No306)),No305);
+(No1114S,((((No0908S,((No0913S,(No0910S,No1202S)),No306)),(No1206S,(((No1208S,(No1007S,No0909S)),No0912S),No1103S))),No0906S),No304),No305);
+(No1114S,(((No0908S,No1206S),((No1202S,No0910S),((No306,(No304,No0913S)),No0906S))),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No305);
+((No0906S,(((No0908S,No1206S),(No1202S,No0910S)),(No306,(No304,No0913S)))),((No1114S,(No1007S,(No0909S,No1208S))),(No0912S,No1103S)),No305);
+(No1114S,((((No1007S,No0909S),No1208S),(No0912S,No1103S)),((No0908S,(No1206S,(No0906S,(No0913S,(No1202S,No0910S))))),(No306,No304))),No305);
+(No1114S,((((No1007S,(No0909S,No1208S)),(No0912S,No0908S)),((No1206S,(No0906S,(No1202S,No0910S))),No1103S)),(No306,(No0913S,No304))),No305);
+(((No0908S,(No306,(No1114S,(No0913S,No304)))),(No1206S,(No0906S,(No1202S,No0910S)))),((No1007S,(No0909S,No1208S)),(No0912S,No1103S)),No305);
+((((No0908S,No1206S),(((No306,(No0913S,No304)),No0906S),(No1202S,No0910S))),(((No0909S,(No1208S,No1007S)),No0912S),No1103S)),No1114S,No305);
+(((((((No0908S,No1206S),(No0906S,(No1202S,No0910S))),(No306,(No0913S,No304))),(No1007S,(No0909S,No1208S))),No0912S),No1103S),No1114S,No305);
+(((((No0906S,(No1202S,No0910S)),(No0908S,No1206S)),((No0913S,No304),No306)),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No1114S,No305);
+(No1114S,((((No1206S,((No1202S,No0910S),No0906S)),(No0908S,((No0913S,No304),No306))),(No1208S,(No1007S,No0909S))),(No0912S,No1103S)),No305);
+(No1114S,(((No0912S,No1103S),(((No0913S,No304),No306),(No0908S,(No1206S,((No1202S,No0906S),No0910S))))),(No1007S,(No0909S,No1208S))),No305);
+(((((No0906S,(No1202S,No0910S)),(No0908S,No1206S)),((No0912S,No1103S),((No1208S,No1007S),No0909S))),(No306,(No0913S,No304))),No1114S,No305);
+((No0912S,(No1103S,(No1007S,(No0909S,No1208S)))),((No306,(No1114S,(No0913S,No304))),((No0906S,(No1202S,No0910S)),(No0908S,No1206S))),No305);
+(((No1007S,(No0909S,No1208S)),(((No0913S,No306),No304),((No0912S,(No0906S,(No1202S,No0910S))),(No1103S,(No0908S,No1206S))))),No1114S,No305);
+(No1114S,((No0912S,No1103S),((No1007S,(No0909S,No1208S)),(((No0908S,No1206S),(No0906S,(No1202S,No0910S))),((No0913S,No304),No306)))),No305);
+(No1114S,((No304,No306),((((No0912S,No1103S),(No0909S,(No1208S,No1007S))),No0908S),(No1206S,(No0906S,(No0913S,(No1202S,No0910S)))))),No305);
+(No1114S,(No304,(No306,((((No0912S,No1103S),(No1007S,(No0909S,No1208S))),No0908S),(No1206S,(No0906S,(No0913S,(No1202S,No0910S))))))),No305);
+((((No0912S,No1103S),(No0909S,(No1208S,No1007S))),(((No0913S,No304),No306),(No0908S,(No0906S,((No1202S,No0910S),No1206S))))),No1114S,No305);
+((((No0912S,No1103S),(No1007S,(No0909S,No1208S))),(No0908S,(((No1206S,No0906S),(No0910S,No1202S)),((No0913S,No304),No306)))),No1114S,No305);
+((((No0912S,No1103S),(No0909S,(No1208S,No1007S))),(((No0906S,(No0910S,No1202S)),((No0913S,No304),No306)),(No0908S,No1206S))),No1114S,No305);
+((((No0912S,No1103S),(No0909S,(No1208S,No1007S))),(((No0913S,No304),No306),(No0908S,(No1206S,(No0906S,(No0910S,No1202S)))))),No1114S,No305);
+(((((No0909S,No1208S),No1007S),(No0912S,No1103S)),((No306,(No0913S,No304)),((No0906S,(No1202S,No0910S)),(No0908S,No1206S)))),No1114S,No305);
+(((No306,(No0913S,No304)),(((No1202S,No0910S),((((No0909S,No1208S),No1007S),(No0912S,No1103S)),(No0908S,No1206S))),No0906S)),No1114S,No305);
+(((No0909S,(No1208S,No1007S)),(((No306,(No0913S,No304)),((No1206S,(No0906S,(No1202S,No0910S))),No0908S)),(No0912S,No1103S))),No1114S,No305);
+((No1114S,(No306,(No0913S,No304))),(((No1206S,(No0906S,(No1202S,No0910S))),No0908S),((No0912S,No1103S),(No1007S,(No0909S,No1208S)))),No305);
+((((No0912S,No1103S),(No1007S,(No0909S,No1208S))),((No0908S,(No1206S,(No0906S,(No1202S,No0910S)))),(No306,(No0913S,No304)))),No1114S,No305);
+((((No0912S,No1103S),(No1007S,(No0909S,No1208S))),((No0908S,(No1206S,(No0906S,(No1202S,No0910S)))),(No306,(No0913S,No304)))),No1114S,No305);
+((((No0912S,No1103S),(No1007S,(No0909S,No1208S))),((No0908S,(No1206S,(No0906S,(No1202S,No0910S)))),(No306,(No0913S,No304)))),No1114S,No305);
+((((No0912S,No1103S),(No1208S,(No1007S,No0909S))),((No0906S,(No1202S,No0910S)),((No1206S,No0908S),(No304,(No306,No0913S))))),No1114S,No305);
+((No304,((((No0906S,((No0912S,No1103S),((No1007S,No0909S),No1208S))),(No1206S,No0908S)),No306),((No1202S,No0910S),No0913S))),No1114S,No305);
+(((((No0909S,No1208S),No1007S),((((No0906S,(No1202S,No0910S)),No1206S),No0908S),(No306,(No304,No0913S)))),(No0912S,No1103S)),No1114S,No305);
+(((((No0913S,No304),No306),(No0908S,((No0906S,(No0910S,No1202S)),No1206S))),(((No1007S,No1208S),No0909S),(No0912S,No1103S))),No1114S,No305);
+(((((No0913S,No304),No306),(No0908S,(No1206S,(No1202S,(No0906S,No0910S))))),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No1114S,No305);
+(((((No0913S,No304),No306),(No0908S,(No1206S,(No1202S,(No0906S,No0910S))))),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No1114S,No305);
+(((((No1206S,No0908S),(No0906S,(No1202S,No0910S))),((No0913S,No304),No306)),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No1114S,No305);
+(((((No1206S,No0908S),(No0906S,(No1202S,No0910S))),((No0913S,No304),No306)),((No0909S,(No1007S,No1208S)),(No0912S,No1103S))),No1114S,No305);
+(((((No0913S,No304),No306),((No1206S,(No0906S,(No1202S,No0910S))),No0908S)),((No0909S,(No1007S,No1208S)),(No0912S,No1103S))),No1114S,No305);
+(((No1208S,(No0909S,No1007S)),((No0912S,No1103S),(((No0913S,No304),No306),((No0906S,(No1202S,No0910S)),(No0908S,No1206S))))),No1114S,No305);
+(((No1007S,(No1208S,No0909S)),((No0912S,No1103S),((No0913S,No304),(No306,(No0908S,(No1206S,(No0906S,(No1202S,No0910S)))))))),No1114S,No305);
+(((No1208S,(No0909S,No1007S)),((No0912S,No1103S),(((No0906S,(No1202S,No0910S)),(No0908S,No1206S)),((No0913S,No304),No306)))),No1114S,No305);
+((No1114S,((No0912S,No1103S),(No0908S,(((No0913S,No304),No306),(No1206S,(No0906S,(No1202S,No0910S))))))),(No1007S,(No0909S,No1208S)),No305);
+(((((No0913S,No304),No306),(No0908S,((No0906S,(No0910S,No1202S)),No1206S))),(((No1007S,No1208S),No0909S),(No0912S,No1103S))),No1114S,No305);
+((((((No0913S,No304),No306),((No0910S,No1202S),(No1206S,No0908S))),No0906S),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No1114S,No305);
+((((((No0913S,No304),No306),((No0910S,No1202S),(No1206S,No0908S))),No0906S),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No1114S,No305);
+(((((No0906S,(No0910S,No1202S)),No1206S),(No0908S,((No0913S,No304),No306))),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No1114S,No305);
+(((No0913S,(No306,(((No0906S,(No0910S,No1202S)),No1206S),(((No0909S,(No1007S,No1208S)),(No0912S,No1103S)),No0908S)))),No304),No1114S,No305);
+(((No0912S,No1103S),(No1206S,((No0906S,No0908S),((No0910S,No1202S),((No304,No0913S),No306))))),(No1114S,(No1007S,(No1208S,No0909S))),No305);
+(No1114S,(((No0912S,No1103S),(No0909S,(No1007S,No1208S))),(((No304,No0913S),No306),((No1206S,(No0906S,(No0910S,No1202S))),No0908S))),No305);
+(No1114S,(((No0912S,No1103S),(No0909S,(No1007S,No1208S))),(((No304,No0913S),No306),((No1206S,(No0906S,(No0910S,No1202S))),No0908S))),No305);
+(No1114S,(((No0912S,No1103S),(No0909S,(No1007S,No1208S))),(((No304,No0913S),No306),((No1206S,(No0906S,(No0910S,No1202S))),No0908S))),No305);
+(No1114S,((No0909S,(No1007S,No1208S)),((((No304,No0913S),No306),((No0906S,(No0910S,No1202S)),(No0908S,No1206S))),(No0912S,No1103S))),No305);
+(No1114S,((No1103S,(No0912S,(No1007S,(No0909S,No1208S)))),((((No304,No0913S),No306),(No1206S,No0908S)),(No0906S,(No0910S,No1202S)))),No305);
+(No1114S,(No1103S,(No0912S,(((((No304,No0913S),No306),No0908S),(No1206S,(No0906S,(No0910S,No1202S)))),(No0909S,(No1208S,No1007S))))),No305);
+(No1114S,((((No0909S,No1208S),No1007S),(No1103S,No0912S)),(((No304,No0913S),(No306,No0908S)),(No1206S,(No0906S,(No0910S,No1202S))))),No305);
+(No1114S,(((No0909S,(No1208S,No1007S)),(No1103S,No0912S)),((No0906S,(No0910S,No1202S)),(((No304,No0913S),No306),(No0908S,No1206S)))),No305);
+(No1114S,(((No0909S,(No1208S,No1007S)),(No1103S,No0912S)),((No0906S,(No0910S,No1202S)),(((No304,No0913S),No306),(No0908S,No1206S)))),No305);
+(No1114S,(((No1007S,(No0909S,No1208S)),(No1103S,No0912S)),((No0906S,((No0910S,No1202S),(No0908S,No1206S))),((No304,No0913S),No306))),No305);
+(No1114S,(((No0909S,(No1208S,No1007S)),(No1103S,No0912S)),(No306,((((No0910S,No1202S),(No304,No0913S)),No0906S),(No0908S,No1206S)))),No305);
+(No1114S,(((No0909S,(No1208S,No1007S)),(No1103S,No0912S)),(((No0908S,No1206S),((No1202S,No0910S),No0906S)),(No306,(No304,No0913S)))),No305);
+(((No0909S,(No1208S,No1007S)),(No1103S,No0912S)),(No1114S,((No1206S,((No1202S,No0910S),No0906S)),(No306,(No0908S,(No304,No0913S))))),No305);
+(No1114S,((No1007S,(No0909S,No1208S)),((((No1206S,((No1202S,No0910S),No0906S)),(No306,(No304,No0913S))),No0908S),(No0912S,No1103S))),No305);
+(No1114S,((((No1206S,(No0906S,(No0910S,No1202S))),No0908S),((No0913S,No304),No306)),(No1103S,(No0912S,((No1208S,No0909S),No1007S)))),No305);
+(No1114S,((((No1206S,(No0906S,(No0910S,No1202S))),No0908S),((No0913S,No304),No306)),(No1103S,(No0912S,((No1208S,No0909S),No1007S)))),No305);
+(No1114S,((((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),((No0913S,No304),No306)),(No1103S,(No0912S,(No0909S,(No1007S,No1208S))))),No305);
+(No1114S,((((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),((No0913S,No304),No306)),(No1103S,(No0912S,(No0909S,(No1007S,No1208S))))),No305);
+(((No0908S,(No1206S,(No0906S,(No0910S,No1202S)))),(No1114S,(No0913S,(No304,No306)))),(No1103S,(No0912S,(No1208S,(No0909S,No1007S)))),No305);
+(No1114S,((No306,((((No0909S,(No1007S,No1208S)),(No1103S,No0912S)),(No1206S,No0908S)),(No0906S,(No0913S,(No0910S,No1202S))))),No304),No305);
+((((No1007S,(No1208S,No0909S)),No0912S),No1103S),(((No306,((No0913S,No304),No1114S)),No0908S),(No1206S,(No0906S,(No1202S,No0910S)))),No305);
+((((((No0913S,No306),(No0906S,(No1202S,No0910S))),(No0908S,((No1007S,(No1208S,No0909S)),(No0912S,No1103S)))),No1206S),No304),No1114S,No305);
+(((No0908S,(((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),((No0913S,No306),(No1206S,(No0906S,(No1202S,No0910S)))))),No304),No1114S,No305);
+(((((No0906S,(No1202S,No0910S)),(No0908S,No1206S)),((No304,No0913S),No306)),(((No0909S,(No1007S,No1208S)),No0912S),No1103S)),No1114S,No305);
+(No1114S,((((No1206S,(No0906S,(No0910S,No1202S))),No0908S),((No0913S,No304),No306)),(No1103S,(No0912S,(No0909S,(No1007S,No1208S))))),No305);
+(No1114S,(((((No0906S,(No0910S,No1202S)),((No0908S,No1206S),(No0913S,No304))),No306),(No1208S,(No0909S,No1007S))),(No1103S,No0912S)),No305);
+(No1114S,(((No0908S,(((No1206S,No0906S),(No0910S,No1202S)),((No1007S,(No1208S,No0909S)),(No1103S,No0912S)))),No306),(No0913S,No304)),No305);
+(No1114S,(((No0908S,(No1206S,(No0906S,(No0910S,No1202S)))),(No306,(No0913S,No304))),((No1208S,(No0909S,No1007S)),(No1103S,No0912S))),No305);
+(No1114S,((No0906S,((No1206S,No0908S),((No306,(No0913S,No304)),(No0910S,No1202S)))),((No1103S,No0912S),((No1208S,No1007S),No0909S))),No305);
+(No1114S,((No1007S,(No0909S,No1208S)),((((No0906S,(No0910S,No1202S)),No1206S),((No306,(No0913S,No304)),No0908S)),(No0912S,No1103S))),No305);
+(No1114S,((((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),(No306,(No0913S,No304))),((No1007S,(No0909S,No1208S)),(No1103S,No0912S))),No305);
+(No1114S,((((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),(No306,(No0913S,No304))),((No1007S,(No0909S,No1208S)),(No1103S,No0912S))),No305);
+(No1114S,((No306,(No0913S,No304)),((((No0906S,No1206S),(No1202S,No0910S)),No0908S),((No1208S,(No1007S,No0909S)),(No1103S,No0912S)))),No305);
+(No1114S,(((No1007S,(No0909S,No1208S)),(No1103S,No0912S)),(((No306,(No0913S,No304)),((No1202S,No0910S),No0906S)),(No0908S,No1206S))),No305);
+(((((((No304,No0913S),No0908S),(No306,((No1202S,No0910S),(No1206S,No0906S)))),(No0909S,(No1208S,No1007S))),No1103S),No0912S),No1114S,No305);
+(((No1007S,(No0909S,No1208S)),((No1103S,No0912S),((((No0906S,(No1206S,No0910S)),No1202S),((No306,No304),No0913S)),No0908S))),No1114S,No305);
+(((((No0906S,(No0910S,No1202S)),(No306,(No304,No0913S))),(No1206S,No0908S)),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No1114S,No305);
+(((((No0906S,((No0910S,No1202S),No1206S)),(No306,(No304,No0913S))),No0908S),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No1114S,No305);
+(((((No0906S,((No0910S,No1202S),No1206S)),(No306,(No304,No0913S))),No0908S),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No1114S,No305);
+(((No306,(No304,No0913S)),(((No0908S,(No0906S,(No0910S,No1202S))),No1206S),((No1007S,(No0909S,No1208S)),(No0912S,No1103S)))),No1114S,No305);
+(((No1007S,(No0909S,No1208S)),((No0912S,No1103S),((No306,((No0906S,(No0913S,(No0910S,No1202S))),(No304,No0908S))),No1206S))),No1114S,No305);
+(((No304,No306),(((((No1007S,(No0909S,No1208S)),No0912S),No1103S),(No0906S,(No0913S,(No0910S,No1202S)))),(No0908S,No1206S))),No1114S,No305);
+(((No0912S,(No1103S,(No1007S,(No0909S,No1208S)))),((No306,(No0913S,No304)),((No0906S,(No1206S,(No0910S,No1202S))),No0908S))),No1114S,No305);
+(((No0912S,(No1103S,(No1007S,(No0909S,No1208S)))),((No306,(No0913S,No304)),((No1206S,((No0910S,No1202S),No0906S)),No0908S))),No1114S,No305);
+(No0906S,(((No0912S,((No1208S,(No1007S,No0909S)),No1103S)),(No306,(No1114S,(No304,No0913S)))),((No1206S,No0908S),(No1202S,No0910S))),No305);
+((((No0912S,No1103S),((No306,(No304,No0913S)),((No1206S,No0908S),((No1202S,No0910S),No0906S)))),(No1208S,(No1007S,No0909S))),No1114S,No305);
+(((No0912S,No1103S),(((No0908S,((No1202S,No0910S),(No1206S,No0906S))),(No306,(No304,No0913S))),(No0909S,(No1208S,No1007S)))),No1114S,No305);
+(((((No0913S,(No1202S,No0910S)),((((No0909S,(No1208S,No1007S)),(No0912S,No1103S)),(No0908S,No1206S)),No0906S)),No306),No304),No1114S,No305);
+(((No0913S,(No306,(((No1007S,(No0909S,No1208S)),(No0912S,No1103S)),(((No0906S,(No1202S,No0910S)),No1206S),No0908S)))),No304),No1114S,No305);
+(((No0912S,No1103S),((((No0910S,(No0906S,No1202S)),(No0908S,No1206S)),(No306,(No0913S,No304))),(No0909S,(No1208S,No1007S)))),No1114S,No305);
+((((((No1206S,(No1202S,No0910S)),No0906S),No0908S),((No306,No304),No0913S)),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No1114S,No305);
+(((((((((No1202S,No0910S),No1206S),No0906S),No306),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No0908S),No0913S),No304),No1114S,No305);
+(((No0913S,No304),(((((No0909S,(No1208S,No1007S)),(No0912S,No1103S)),(((No1202S,No0910S),No1206S),No0906S)),No0908S),No306)),No1114S,No305);
+((((No0909S,(No1208S,No1007S)),(No0912S,No1103S)),(((No1206S,(No0906S,(No1202S,No0910S))),(No306,(No304,No0913S))),No0908S)),No1114S,No305);
+(No1114S,((No1103S,((No1007S,(No1208S,No0909S)),No0912S)),(((No304,No0913S),No306),((No1206S,(No0906S,(No1202S,No0910S))),No0908S))),No305);
+((No1114S,((No304,No0913S),No306)),(((No1206S,(No0906S,(No1202S,No0910S))),No0908S),(No0912S,(No1103S,(No1007S,(No1208S,No0909S))))),No305);
+(No1114S,(((((No304,No0913S),No306),No0908S),(No1206S,(No0906S,(No1202S,No0910S)))),((No0909S,(No1007S,No1208S)),(No0912S,No1103S))),No305);
+(No1114S,(((((No304,No0913S),No306),No0908S),(No1206S,(No0906S,(No1202S,No0910S)))),((No0909S,(No1007S,No1208S)),(No0912S,No1103S))),No305);
+(No1114S,(((((No304,No0913S),No306),No0908S),(No1206S,(No0906S,(No1202S,No0910S)))),((No0909S,(No1007S,No1208S)),(No0912S,No1103S))),No305);
+(No1114S,((((No306,No0908S),(No1206S,(No0906S,(No0913S,(No0910S,No1202S))))),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No304),No305);
+(No1114S,((((No1007S,(No1208S,No0909S)),No0912S),No1103S),((No306,No304),((No0906S,(No0913S,(No0910S,No1202S))),(No0908S,No1206S)))),No305);
+(No1114S,((((No1208S,(No0909S,No1007S)),No0912S),No1103S),((No306,No304),(No0908S,(No1206S,(No0906S,(No0913S,(No0910S,No1202S))))))),No305);
+(((No0908S,(((No0910S,No1202S),No0906S),No1206S)),(No306,(No0913S,(No1114S,No304)))),((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),No305);
+((((No0908S,(((No0910S,No1202S),No0906S),No1206S)),(No306,(No0913S,No304))),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No1114S,No305);
+((((((No0908S,No1206S),((No0906S,(No0913S,(No1202S,No0910S))),No306)),(No1103S,No0912S)),((No0909S,No1007S),No1208S)),No304),No1114S,No305);
+(((No0906S,((((No1007S,(No1208S,No0909S)),(No1103S,No0912S)),(No0910S,(No0908S,No1206S))),No1202S)),(No306,(No304,No0913S))),No1114S,No305);
+((((((No0906S,No1206S),(No0910S,No1202S)),(No306,(No304,No0913S))),No0908S),((No1208S,(No0909S,No1007S)),(No1103S,No0912S))),No1114S,No305);
+(((No306,(No304,No0913S)),((No1206S,((No0906S,No0908S),(No1103S,((No1202S,(No1007S,(No1208S,No0909S))),No0910S)))),No0912S)),No1114S,No305);
+((((No0909S,(No1007S,No1208S)),(No0912S,No1103S)),(((No1206S,No0908S),(No0906S,(No0910S,No1202S))),(No306,(No304,No0913S)))),No1114S,No305);
+(((No304,No0913S),((((No0909S,(No1007S,No1208S)),(No0912S,No1103S)),(No0908S,(No1206S,(No0906S,(No0910S,No1202S))))),No306)),No1114S,No305);
+((((No0912S,No1103S),((No0909S,No1208S),No1007S)),((No1206S,(No0906S,(No0910S,No1202S))),(No0908S,(No306,(No0913S,No304))))),No1114S,No305);
+((No304,(((No0906S,(((No0910S,No1202S),((No0912S,No1103S),((No0909S,No1208S),No1007S))),(No0908S,No1206S))),No306),No0913S)),No1114S,No305);
+(((No0912S,No1103S),((No0909S,(No1208S,No1007S)),(((No0906S,No1206S),((No0913S,No1202S),No0910S)),(No0908S,(No306,No304))))),No1114S,No305);
+((((No0908S,((No0913S,No304),(No0909S,(No1208S,No1007S)))),(No1206S,(No0906S,(No0910S,No1202S)))),No306),((No1103S,No1114S),No0912S),No305);
+((((No1103S,No0912S),(No1007S,(No1208S,No0909S))),((No306,(No0913S,No304)),(((No1206S,No0906S),(No1202S,No0910S)),No0908S))),No1114S,No305);
+((((No1103S,No0912S),(No1007S,(No1208S,No0909S))),((No306,(No0913S,No304)),(((No1206S,No0906S),(No1202S,No0910S)),No0908S))),No1114S,No305);
+((((No0908S,No1206S),((No1103S,((No1202S,No0910S),No0906S)),(No0912S,(No306,(No0913S,No304))))),(No1007S,(No1208S,No0909S))),No1114S,No305);
+(((No0908S,((((No1202S,No0910S),No0906S),No1206S),(No306,(No0913S,No304)))),((No0912S,No1103S),(No1007S,(No1208S,No0909S)))),No1114S,No305);
+(((No0908S,((((No1202S,No0910S),No0906S),No1206S),(No306,(No0913S,No304)))),((No0912S,No1103S),(No1007S,(No1208S,No0909S)))),No1114S,No305);
+((No304,((No306,((No0908S,No1206S),((No0912S,No1103S),(No1007S,(No1208S,No0909S))))),((No1202S,No0910S),(No0913S,No0906S)))),No1114S,No305);
+((No304,(No306,((((No0908S,No1206S),((No0912S,No1103S),(No0909S,(No1007S,No1208S)))),(No0906S,(No1202S,No0910S))),No0913S))),No1114S,No305);
+((((No0912S,No1103S),(No1007S,(No1208S,No0909S))),((No0908S,No1206S),((((No1202S,No0910S),No0906S),No0913S),(No304,No306)))),No1114S,No305);
+(((No1007S,(No1208S,No0909S)),(((No0906S,(No1202S,No0910S)),((No0912S,No1103S),(No0908S,No1206S))),((No0913S,No304),No306))),No1114S,No305);
+(((No1007S,(No1208S,No0909S)),((No0912S,No1103S),(((No0913S,No304),No306),((No0906S,(No1202S,No0910S)),(No0908S,No1206S))))),No1114S,No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No1208S,No0909S))),(No306,((No0906S,(No1206S,((No304,No0913S),No0908S))),(No0910S,No1202S)))),No305);
+(No1114S,(No304,(((((No0906S,(No0913S,(No1202S,No0910S))),No1206S),((No0912S,No1103S),(No0909S,(No1007S,No1208S)))),No0908S),No306)),No305);
+((((No0912S,No1103S),(No1007S,(No1208S,No0909S))),((No0906S,(No1202S,No0910S)),((No0908S,No1206S),(No306,(No0913S,No304))))),No1114S,No305);
+((((No0912S,No1103S),(No1007S,(No1208S,No0909S))),((No0906S,((No1202S,No0910S),No1206S)),(No0908S,(No306,(No0913S,No304))))),No1114S,No305);
+((((No0912S,No1103S),(No0909S,(No1007S,No1208S))),((No306,(No0913S,No304)),((No0910S,(No0906S,No1202S)),(No1206S,No0908S)))),No1114S,No305);
+((((No0912S,No1103S),(No0909S,(No1007S,No1208S))),((No306,(No0913S,No304)),(No0908S,((No0906S,(No1202S,No0910S)),No1206S)))),No1114S,No305);
+((((No0912S,No1103S),(No0909S,(No1007S,No1208S))),((No306,(No0913S,No304)),(No0908S,((No0906S,(No1202S,No0910S)),No1206S)))),No1114S,No305);
+((No1103S,(((No0909S,(No1007S,No1208S)),((No0908S,(No0906S,((No1202S,No0910S),No1206S))),(No306,(No0913S,No304)))),No0912S)),No1114S,No305);
+((((No0908S,(No1206S,(No0906S,(No1202S,No0910S)))),(No306,(No0913S,No304))),(No1103S,(No0912S,(No1007S,(No1208S,No0909S))))),No1114S,No305);
+(((((No0906S,(No1202S,No0910S)),(No0908S,No1206S)),(No306,(No0913S,No304))),((No0909S,(No1007S,No1208S)),(No1103S,No0912S))),No1114S,No305);
+(No1114S,(((No0912S,No1103S),(No0909S,(No1007S,No1208S))),(((No304,No0913S),No306),(((No0910S,No1202S),(No0908S,No1206S)),No0906S))),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No1208S,No0909S))),(((No304,No0913S),No306),((((No0910S,No1202S),No1206S),No0906S),No0908S))),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No1208S,No0909S))),(((No304,No0913S),No306),((((No0910S,No1202S),No1206S),No0906S),No0908S))),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No1208S,No0909S))),((No0913S,(No306,No304)),((No1206S,(No0906S,(No0910S,No1202S))),No0908S))),No305);
+(No1114S,(((((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),((No0913S,No304),No306)),(No1007S,(No1208S,No0909S))),(No0912S,No1103S)),No305);
+(No1114S,((((No0906S,(No0910S,No1202S)),No1206S),(No0908S,((No0913S,No304),No306))),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No305);
+(No1114S,((No0912S,No1103S),(((No304,(No306,No0913S)),((No0906S,((No0910S,No1202S),No1206S)),No0908S)),(No1007S,(No1208S,No0909S)))),No305);
+(No1114S,((No1007S,(No1208S,No0909S)),((No0912S,No1103S),(No0908S,((No306,(No0913S,No304)),(No0906S,((No0910S,No1202S),No1206S)))))),No305);
+(No1114S,((No0912S,No1103S),(((No0908S,(((No0906S,No0910S),No1202S),No1206S)),((No304,No0913S),No306)),(No0909S,(No1007S,No1208S)))),No305);
+(No1114S,(((No0908S,((No0906S,(No0910S,No1202S)),No1206S)),((No304,No0913S),No306)),((No0909S,(No1007S,No1208S)),(No0912S,No1103S))),No305);
+((No1208S,(No1007S,No0909S)),((((No306,No0913S),(No1114S,No304)),((No0908S,No1206S),((No1202S,No0910S),No0906S))),(No1103S,No0912S)),No305);
+((((No306,(No304,No0913S)),(No0908S,((No1007S,(No0909S,No1208S)),(No1206S,((No1202S,No0910S),No0906S))))),(No1103S,No0912S)),No1114S,No305);
+((((No1206S,((No1202S,No0910S),No0906S)),((No306,(No304,No0913S)),No0908S)),((No1007S,(No0909S,No1208S)),(No1103S,No0912S))),No1114S,No305);
+(((No1103S,No0912S),((((No306,(No304,No0913S)),No0908S),(No1206S,((No1202S,No0910S),No0906S))),(No0909S,(No1208S,No1007S)))),No1114S,No305);
+(((((No306,(No304,No0913S)),No0908S),(No1206S,((No1202S,No0910S),No0906S))),(((No1007S,No1208S),No0909S),(No1103S,No0912S))),No1114S,No305);
+(((((No306,(No304,No0913S)),No0908S),(No1206S,((No1202S,No0910S),No0906S))),((No1007S,(No1208S,No0909S)),(No1103S,No0912S))),No1114S,No305);
+(((((No306,(No304,No0913S)),No0908S),(No1206S,((No1202S,No0910S),No0906S))),((No0909S,(No1007S,No1208S)),(No1103S,No0912S))),No1114S,No305);
+(((((No306,(No304,No0913S)),No0908S),(No1206S,((No1202S,No0910S),No0906S))),((No0909S,(No1007S,No1208S)),(No1103S,No0912S))),No1114S,No305);
+(((((No306,(No304,No0913S)),((No1202S,No0910S),No0906S)),(No0908S,No1206S)),(((No0909S,(No1007S,No1208S)),No0912S),No1103S)),No1114S,No305);
+(((((No306,(No304,No0913S)),((No1202S,No0910S),No0906S)),(No0908S,No1206S)),(((No0909S,(No1007S,No1208S)),No0912S),No1103S)),No1114S,No305);
+(((No0908S,((No306,(No0913S,No304)),((No0906S,(No0910S,No1202S)),No1206S))),((No0909S,(No1208S,No1007S)),(No1103S,No0912S))),No1114S,No305);
+((No304,(No306,((((No1007S,(No0909S,No1208S)),(No1103S,No0912S)),(No0908S,No1206S)),((No0906S,(No0910S,No1202S)),No0913S)))),No1114S,No305);
+(((No1103S,No0912S),(((No0908S,(No1206S,(No0906S,(No0910S,No1202S)))),((No306,No0913S),No304)),(No1208S,(No1007S,No0909S)))),No1114S,No305);
+(((((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),((No0913S,No304),No306)),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No1114S,No305);
+(((No1007S,(No0909S,No1208S)),((No0912S,No1103S),(((No0908S,No1206S),(No0906S,(No0910S,No1202S))),((No304,No0913S),No306)))),No1114S,No305);
+(((((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),((No304,No0913S),No306)),((No0909S,(No1208S,No1007S)),(No0912S,No1103S))),No1114S,No305);
+(((No0912S,No1103S),((((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),((No304,No0913S),No306)),(No0909S,(No1208S,No1007S)))),No1114S,No305);
+(((((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),((No304,No0913S),No306)),((No1208S,(No1007S,No0909S)),(No0912S,No1103S))),No1114S,No305);
+(No1114S,(((((No0906S,(No0910S,No1202S)),(No0908S,((No304,No0913S),No306))),No1206S),(No1007S,(No0909S,No1208S))),(No0912S,No1103S)),No305);
+(No1114S,((((No304,No0913S),No306),((No0908S,No1206S),(No0906S,(No0910S,No1202S)))),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No305);
+((((No306,(No0913S,No304)),((No0906S,(No0910S,No1202S)),(No0908S,No1206S))),((No0909S,(No1208S,No1007S)),(No1103S,No0912S))),No1114S,No305);
+((((No306,(No0913S,No304)),((No0906S,(No0910S,No1202S)),(No0908S,No1206S))),((No0909S,(No1208S,No1007S)),(No1103S,No0912S))),No1114S,No305);
+((((No306,(No0913S,No304)),((No0906S,(No0910S,No1202S)),(No0908S,No1206S))),((No0909S,(No1208S,No1007S)),(No1103S,No0912S))),No1114S,No305);
+(((No1114S,(No306,(No0913S,No304))),(No0908S,((No0906S,(No0910S,No1202S)),No1206S))),((No0909S,(No1208S,No1007S)),(No1103S,No0912S)),No305);
+((((No306,(No0913S,No304)),((No0906S,(No0910S,No1202S)),(No1206S,No0908S))),((No0909S,(No1208S,No1007S)),(No1103S,No0912S))),No1114S,No305);
+(((No1103S,No0912S),(((No306,(No0913S,No304)),((No0906S,(No0910S,No1202S)),(No1206S,No0908S))),(No0909S,(No1208S,No1007S)))),No1114S,No305);
+((((No306,(No0913S,No304)),((No0906S,(No0910S,No1202S)),(No1206S,No0908S))),((No0909S,(No1208S,No1007S)),(No1103S,No0912S))),No1114S,No305);
+((((No0909S,(No1208S,No1007S)),(No1103S,No0912S)),(((No1206S,No0908S),(No306,(No0913S,(No0906S,(No0910S,No1202S))))),No304)),No1114S,No305);
+((((No1103S,((No304,No306),(No0908S,(No1206S,(No0906S,((No0910S,No1202S),No0913S)))))),No0912S),(No1007S,(No0909S,No1208S))),No1114S,No305);
+((((((No0913S,No304),(No0906S,(No0910S,No1202S))),(No306,(No0908S,No1206S))),(No1007S,(No0909S,No1208S))),(No0912S,No1103S)),No1114S,No305);
+(No0912S,(((((No0908S,No1206S),(No0906S,(No0913S,(No0910S,No1202S)))),No304),No306),((No1114S,(No1007S,(No0909S,No1208S))),No1103S)),No305);
+(No1114S,(((No0908S,((No0906S,No1206S),(No0910S,No1202S))),((No0913S,No304),No306)),((No0912S,No1103S),(No1208S,(No1007S,No0909S)))),No305);
+(No1114S,((((No0908S,No1206S),((No0913S,No304),No306)),((No0910S,No1202S),No0906S)),((No0912S,No1103S),(No1007S,(No0909S,No1208S)))),No305);
+(No1114S,((((No0908S,No1206S),((No0913S,No304),No306)),((No0910S,No1202S),No0906S)),((No0912S,No1103S),(No1007S,(No0909S,No1208S)))),No305);
+(No1114S,((((No0908S,No1206S),((No0913S,No304),No306)),((No0910S,No1202S),No0906S)),((No0912S,No1103S),(No0909S,(No1208S,No1007S)))),No305);
+(No1114S,((No0912S,No1103S),((No1208S,(No1007S,No0909S)),((((No0910S,No1202S),No0906S),((No0913S,No304),No306)),(No0908S,No1206S)))),No305);
+(No0908S,(((No1114S,((No0913S,No304),No306)),(No1103S,((No0909S,(No1208S,No1007S)),No0912S))),(((No0910S,No1202S),No0906S),No1206S)),No305);
+(No1114S,((((((No0910S,No1202S),No0906S),No1206S),No0908S),((No0913S,No304),No306)),((No1103S,No0912S),(No0909S,(No1208S,No1007S)))),No305);
+(No1114S,((((No0906S,((No0909S,(No1208S,No1007S)),No0908S)),(No1202S,(No1206S,No0910S))),((No0913S,No304),No306)),(No1103S,No0912S)),No305);
+(No1114S,(No0912S,(((No0909S,(No1208S,No1007S)),((((No0906S,(No0910S,No1202S)),No1206S),No0908S),((No0913S,No304),No306))),No1103S)),No305);
+((((No1007S,(No1208S,No0909S)),No0912S),No1103S),((No306,((No1114S,No304),No0913S)),((No1206S,(No0906S,(No1202S,No0910S))),No0908S)),No305);
+((((No0909S,(No1007S,No1208S)),(No0912S,No1103S)),(No0908S,((No1206S,(No306,(No304,No0913S))),(No0906S,(No1202S,No0910S))))),No1114S,No305);
+(((No0909S,(No1007S,No1208S)),((No0912S,No1103S),(((No0908S,No1206S),(No306,(No304,No0913S))),(No0906S,(No1202S,No0910S))))),No1114S,No305);
+((((No306,No0913S),(((No1206S,No0906S),(No1202S,No0910S)),(No0908S,((No0909S,(No1007S,No1208S)),(No0912S,No1103S))))),No304),No1114S,No305);
+((((No1103S,No0912S),((No0909S,No1007S),No1208S)),((No306,(No304,No0913S)),(No0908S,(No1206S,(No0906S,(No1202S,No0910S)))))),No1114S,No305);
+((((No1103S,No0912S),(No0909S,(No1007S,No1208S))),(((No0910S,(No306,(No304,No0913S))),(No0906S,(No0908S,No1206S))),No1202S)),No1114S,No305);
+(((No1103S,No0912S),((No0909S,(No1007S,No1208S)),(((((No0910S,No1202S),No0906S),No1206S),No0908S),(No306,(No304,No0913S))))),No1114S,No305);
+(((No1114S,(No306,(No304,No0913S))),(((No0910S,No1202S),No0906S),(No0908S,No1206S))),((No1103S,No0912S),(No1208S,(No0909S,No1007S))),No305);
+(((((No0910S,No1202S),No0906S),(No0908S,(No1206S,(No306,(No304,No0913S))))),((No1103S,No0912S),(No0909S,(No1007S,No1208S)))),No1114S,No305);
+((((((No1206S,((No0910S,No1202S),No0906S)),No0908S),(No304,No0913S)),No306),((No1103S,No0912S),(No0909S,(No1007S,No1208S)))),No1114S,No305);
+((((((No0913S,No304),No306),(No1206S,(No0906S,(No1202S,No0910S)))),No0908S),((No1103S,No0912S),(No1007S,(No0909S,No1208S)))),No1114S,No305);
+(((((No1206S,No0908S),((No0913S,No304),No306)),((No1202S,No0910S),No0906S)),((No1103S,No0912S),((No1007S,No1208S),No0909S))),No1114S,No305);
+(((No1007S,No1208S),(No0909S,((No0910S,((No1202S,((No0913S,No304),No306)),(No0906S,(No1206S,No0908S)))),(No1103S,No0912S)))),No1114S,No305);
+(No1114S,((((No1206S,No0908S),((No0906S,(No0913S,(No0910S,No1202S))),No304)),No306),((No0909S,(No1208S,No1007S)),(No1103S,No0912S))),No305);
+(No1114S,(No1103S,(No0912S,(((No0906S,(No0913S,(No0910S,No1202S))),(No304,No306)),((No1206S,No0908S),(No0909S,(No1208S,No1007S)))))),No305);
+(No1114S,((((No0913S,No304),No306),((No1206S,No0908S),(No0906S,(No0910S,No1202S)))),((No1103S,No0912S),(No1007S,(No0909S,No1208S)))),No305);
+(((((((No1206S,No0906S),(No0910S,No1202S)),No1103S),(((No0913S,No304),No306),No0908S)),No0912S),(No0909S,(No1208S,No1007S))),No1114S,No305);
+((((((No1206S,No0906S),(No0910S,No1202S)),((No0913S,No304),No306)),No0908S),((No0912S,No1103S),(No1007S,(No0909S,No1208S)))),No1114S,No305);
+(((((No0908S,No1206S),(No0906S,(No0910S,No1202S))),((No0913S,No304),No306)),((No0912S,No1103S),(No0909S,(No1208S,No1007S)))),No1114S,No305);
+(((((No0908S,No1206S),(No0906S,(No0910S,No1202S))),((No0913S,No304),No306)),((No0912S,No1103S),(No0909S,(No1208S,No1007S)))),No1114S,No305);
+((((No1103S,No0912S),(No1007S,(No0909S,No1208S))),(((No0908S,No1206S),(No304,No306)),(No0906S,((No1202S,No0910S),No0913S)))),No1114S,No305);
+((((No304,No306),((No1103S,No0912S),((No1208S,(No1114S,No1007S)),No0909S))),(No0906S,((No1202S,No0910S),No0913S))),(No0908S,No1206S),No305);
+((No304,((No0908S,((((No1208S,No1007S),No0909S),No0912S),No1103S)),((No1206S,(No0906S,(No1202S,No0910S))),(No306,No0913S)))),No1114S,No305);
+(((No1007S,(No0909S,No1208S)),(No1103S,(((No0908S,((No0906S,(No1202S,No0910S)),No1206S)),(No306,(No304,No0913S))),No0912S))),No1114S,No305);
+((((No1206S,No0908S),(No306,(No304,((No0906S,(No1202S,No0910S)),No0913S)))),((No0912S,No1103S),(No0909S,(No1208S,No1007S)))),No1114S,No305);
+((((((No0906S,(No1202S,No0910S)),No1206S),No0908S),(No306,(No304,No0913S))),((No0912S,No1103S),(No0909S,(No1208S,No1007S)))),No1114S,No305);
+(((No0912S,No1103S),((No1208S,(No1007S,No0909S)),((((No0906S,(No1202S,No0910S)),No1206S),No0908S),(No306,(No304,No0913S))))),No1114S,No305);
+((((((No0906S,(No1202S,No0910S)),No1206S),No0908S),((No0913S,No304),No306)),(No0912S,No1103S)),(No1114S,(No1007S,(No0909S,No1208S))),No305);
+(No1114S,((((No0909S,No1208S),No1007S),(No1103S,No0912S)),((((No0906S,(No1202S,No0910S)),No1206S),No0908S),((No0913S,No304),No306))),No305);
+(No1114S,((No0908S,((No0909S,(No1208S,No1007S)),(No1103S,No0912S))),(((No0906S,(No1202S,No0910S)),No1206S),((No0913S,No304),No306))),No305);
+((No304,(((No0908S,((No0906S,(No1202S,No0910S)),No1206S)),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),(No306,No0913S))),No1114S,No305);
+(((((No0909S,(No1007S,No1208S)),No0912S),No1103S),((No0908S,(No306,(No304,No0913S))),((No0906S,(No1202S,No0910S)),No1206S))),No1114S,No305);
+(((((No1007S,(No1208S,No0909S)),No0912S),No1103S),((No0908S,(No0913S,(No306,No304))),((No0906S,(No1202S,No0910S)),No1206S))),No1114S,No305);
+((No1103S,(((No304,(No306,(No0908S,((No0906S,(No0913S,(No1202S,No0910S))),No1206S)))),(No1007S,(No1208S,No0909S))),No0912S)),No1114S,No305);
+((((No1103S,((No1007S,(No1208S,No0909S)),No0912S)),((No0906S,(No0913S,(No1202S,No0910S))),(No1206S,No0908S))),(No304,No306)),No1114S,No305);
+(((((((No1007S,No1208S),No0909S),No0912S),No1103S),(((No0908S,((No0910S,(No0913S,No1202S)),No0906S)),No306),No1206S)),No1114S),No304,No305);
+(No1114S,(((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),(((No0913S,No304),No306),(No0908S,(No1206S,((No0910S,No1202S),No0906S))))),No305);
+(No1114S,(((No0913S,No304),No306),((((No0909S,(No1007S,No1208S)),(No0912S,No1103S)),(No0908S,No1206S)),(No0910S,(No1202S,No0906S)))),No305);
+(No1114S,(((No1103S,No0912S),(No1007S,(No1208S,No0909S))),((((No0913S,No304),No306),(No0908S,No1206S)),(No0906S,(No0910S,No1202S)))),No305);
+(No1114S,((((No0908S,No1206S),(((No0910S,No1202S),No0913S),No0906S)),(((No1103S,No0912S),(No1007S,(No1208S,No0909S))),No306)),No304),No305);
+(No1114S,((No1103S,No0912S),((No0908S,((No1206S,((No0910S,No1202S),No0906S)),((No304,No0913S),No306))),((No1208S,No0909S),No1007S))),No305);
+(No1114S,((No1103S,No0912S),(((((No0910S,No1202S),No0906S),(No0908S,No1206S)),((No304,No0913S),No306)),((No1208S,No0909S),No1007S))),No305);
+(No1114S,(((((No0906S,No1206S),(No1202S,No0910S)),((No304,No0913S),No306)),No0908S),(((No0909S,No1208S),No1007S),(No1103S,No0912S))),No305);
+(No1114S,((No1103S,No0912S),((((No1206S,((No1202S,No0910S),No0906S)),((No304,No0913S),No306)),No0908S),(No0909S,(No1208S,No1007S)))),No305);
+(No1114S,((((No304,No0913S),No306),(No0908S,(No1206S,((No1202S,No0910S),No0906S)))),((No0909S,(No1208S,No1007S)),(No1103S,No0912S))),No305);
+(No1114S,((((No0908S,No1206S),((((No0913S,No0906S),No0910S),No1202S),No306)),((No0909S,(No1208S,No1007S)),(No1103S,No0912S))),No304),No305);
+(No1114S,((No1103S,No0912S),((((No0913S,No304),No306),(No0908S,(No1206S,((No0910S,No1202S),No0906S)))),(No0909S,(No1208S,No1007S)))),No305);
+(No1114S,((((No0913S,No304),No306),(No0908S,(No1206S,((No0910S,No1202S),No0906S)))),((No1208S,(No1007S,No0909S)),(No1103S,No0912S))),No305);
+(No1114S,((No0909S,(No1208S,No1007S)),((No1103S,No0912S),(((No0913S,No304),No306),(No0908S,(No1206S,((No0910S,No1202S),No0906S)))))),No305);
+(No1114S,((No1103S,No0912S),(((((No0913S,No304),((No0910S,No1202S),No0906S)),(No0908S,No1206S)),No306),(No1007S,(No0909S,No1208S)))),No305);
+(No1114S,((No0908S,((No1206S,((No0910S,No1202S),No0906S)),(No306,(No304,No0913S)))),(No1103S,((No0909S,(No1007S,No1208S)),No0912S))),No305);
+(No1114S,(((((No0910S,No1202S),No0906S),(No0908S,No1206S)),(No306,(No304,No0913S))),(No1103S,((No1007S,(No1208S,No0909S)),No0912S))),No305);
+(((((No0910S,No1202S),No0906S),(No0908S,No1206S)),(No306,(No1114S,(No304,No0913S)))),(No1103S,((No0909S,(No1007S,No1208S)),No0912S)),No305);
+(((No1007S,(No1208S,No0909S)),((No0912S,No1103S),(((No306,No304),No0913S),((No1206S,((No0906S,No0910S),No1202S)),No0908S)))),No1114S,No305);
+(((No1007S,(No1208S,No0909S)),(No0912S,(No1103S,(No0906S,((No1202S,((No306,(No304,No0913S)),No0910S)),(No1206S,No0908S)))))),No1114S,No305);
+(((((((No1206S,No0908S),No0906S),(No306,(No304,No0913S))),(No0910S,No1202S)),(No1007S,(No1208S,No0909S))),(No1103S,No0912S)),No1114S,No305);
+(((No1103S,No0912S),(No0909S,(No1007S,No1208S))),((No0906S,(No1206S,(No0910S,No1202S))),(No0908S,(No1114S,(No306,(No304,No0913S))))),No305);
+((No0909S,((No1114S,No1007S),No1208S)),(No0912S,(No1103S,(No0908S,((No306,(No304,No0913S)),(No0906S,(No1206S,(No0910S,No1202S))))))),No305);
+(No1114S,((No0912S,No1103S),((((No306,(No304,No0913S)),(No1206S,((No0910S,No1202S),No0906S))),No0908S),(No0909S,(No1007S,No1208S)))),No305);
+(No1114S,(((No0909S,(No1007S,No1208S)),(No0912S,No1103S)),(((((No1202S,No0906S),(No0910S,No0913S)),(No304,No0908S)),No1206S),No306)),No305);
+(No1114S,((((No1208S,No1007S),No0909S),(No1103S,No0912S)),((No306,(No304,No0913S)),(((No0910S,No1202S),No0906S),(No0908S,No1206S)))),No305);
+(No1114S,((((No1208S,No1007S),No0909S),(No1103S,No0912S)),((No306,(No304,No0913S)),(No0908S,(No1206S,((No0910S,No1202S),No0906S))))),No305);
+(No1114S,((((No1208S,No1007S),No0909S),(No1103S,No0912S)),(((No306,No304),(No0913S,(No0910S,No1202S))),((No0908S,No1206S),No0906S))),No305);
+(No1114S,(((No306,No304),No0913S),(((No0912S,(No0908S,(No1007S,(No0909S,No1208S)))),(No1206S,(No0906S,(No0910S,No1202S)))),No1103S)),No305);
+(No1114S,((((No0906S,((No0912S,No1103S),(No1208S,(No1007S,No0909S)))),(No0908S,No1206S)),(No0910S,No1202S)),((No0913S,No304),No306)),No305);
+(((No0912S,No1103S),((No1208S,No1007S),No0909S)),((((No0913S,No304),No306),No1114S),((No0908S,No1206S),(No0906S,(No0910S,No1202S)))),No305);
+(No1114S,((((No0906S,((No0913S,No304),(No0910S,No1202S))),(No0908S,No1206S)),((No0912S,No1103S),((No1208S,No1007S),No0909S))),No306),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No0909S,No1208S))),(((No0913S,No304),No306),(No0908S,(No1206S,((No0910S,No1202S),No0906S))))),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No0909S,No1208S))),(((No0913S,No304),No306),(No0908S,(No1206S,((No0910S,No1202S),No0906S))))),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No0909S,No1208S))),(((No0913S,No304),No306),(No0908S,(No1206S,((No0910S,No1202S),No0906S))))),No305);
+(No1114S,((No1103S,No0912S),((No0909S,(No1208S,No1007S)),(No0906S,(((No306,(No0913S,No304)),No0908S),((No1202S,No0910S),No1206S))))),No305);
+(No1114S,((No1007S,(No0909S,No1208S)),((((No306,(No0913S,No304)),No0908S),(No0906S,(No1206S,(No1202S,No0910S)))),(No1103S,No0912S))),No305);
+(No1114S,((No1007S,(No0909S,No1208S)),((((No304,(No0906S,(No0913S,(No1202S,No0910S)))),(No0908S,No1206S)),No306),(No1103S,No0912S))),No305);
+(No1114S,((No1208S,(No1007S,No0909S)),((No1103S,No0912S),(No1206S,((No0906S,(No1202S,No0910S)),(((No304,No0913S),No306),No0908S))))),No305);
+(No1114S,((No1103S,No0912S),((No0909S,(No1208S,No1007S)),(((No304,No0913S),No306),(No0908S,(No1206S,(No0906S,(No1202S,No0910S))))))),No305);
+(No1114S,((No1103S,No0912S),((No0909S,(No1208S,No1007S)),(((No304,No0913S),No306),(No0908S,(No1206S,(No0906S,(No1202S,No0910S))))))),No305);
+(No1114S,((((No304,No0913S),No306),(No0908S,(No1206S,(No0906S,(No1202S,No0910S))))),((No1103S,No0912S),(No1007S,(No0909S,No1208S)))),No305);
+(No1114S,((((No304,No0913S),No306),(No0908S,(No1206S,(No0906S,(No1202S,No0910S))))),((No1103S,No0912S),(No1007S,(No0909S,No1208S)))),No305);
+(No1114S,((((No304,No0913S),No306),(No0908S,(No1206S,(No0906S,(No1202S,No0910S))))),((No1103S,No0912S),(No1007S,(No0909S,No1208S)))),No305);
+(No1114S,(((No0906S,((No304,No0913S),No306)),((No1202S,No0910S),(No0908S,No1206S))),((No1103S,No0912S),(No1208S,(No1007S,No0909S)))),No305);
+(No1114S,(((No1103S,No0912S),(No1007S,(No0909S,No1208S))),((No1206S,(No0906S,(No1202S,No0910S))),((No306,(No0913S,No304)),No0908S))),No305);
+(No1114S,(((No1103S,No0912S),(No1007S,(No0909S,No1208S))),((No1206S,(No0906S,(No1202S,No0910S))),((No306,(No0913S,No304)),No0908S))),No305);
+(No1114S,(((No1103S,No0912S),(No0909S,(No1208S,No1007S))),(No0908S,((No1206S,(No0906S,(No1202S,No0910S))),(No306,(No0913S,No304))))),No305);
+(No1114S,((No1007S,(No0909S,No1208S)),(((No306,(No0913S,No304)),(No0908S,(No1206S,(No0906S,(No1202S,No0910S))))),(No1103S,No0912S))),No305);
+(No1114S,((((No0908S,(No1206S,(No0906S,(No1202S,No0910S)))),(No0913S,No304)),No306),((No1007S,(No0909S,No1208S)),(No1103S,No0912S))),No305);
+(No1114S,(((((No304,No0913S),No306),(No0908S,No1206S)),(No0906S,(No1202S,No0910S))),((No1007S,(No0909S,No1208S)),(No1103S,No0912S))),No305);
+(No1114S,(No304,((((No0906S,(No0913S,(No1202S,No0910S))),(No0908S,No1206S)),No306),((No1208S,(No1007S,No0909S)),(No1103S,No0912S)))),No305);
+(No1114S,(No304,((((No0906S,No1206S),(No0910S,No1202S)),((((No1007S,(No0909S,No1208S)),(No1103S,No0912S)),No0908S),No306)),No0913S)),No305);
+(No1114S,(((No1103S,No0912S),(No1007S,(No0909S,No1208S))),(No0908S,(((No0913S,No304),No306),(No1206S,((No0910S,No1202S),No0906S))))),No305);
+(No1114S,(((No1103S,No0912S),(No0909S,(No1208S,No1007S))),((((No0910S,No1202S),No0906S),(No0908S,No1206S)),((No0913S,No304),No306))),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No1208S,No0909S))),((No306,(No0913S,No304)),(No0908S,(No1206S,(No0906S,(No0910S,No1202S)))))),No305);
+(No1114S,((No0912S,No1103S),((No1208S,(No0909S,No1007S)),((No306,(No0913S,No304)),(No0908S,(No1206S,(No0906S,(No0910S,No1202S))))))),No305);
+(No1114S,((No306,(((No0913S,(No0906S,(No0910S,No1202S))),No304),(No0908S,No1206S))),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No305);
+((No0908S,((No306,(No0913S,(No1114S,No304))),(No1206S,((No0910S,No1202S),No0906S)))),((No0912S,No1103S),(No0909S,(No1007S,No1208S))),No305);
+(((((No306,(No0913S,No304)),(No0908S,((No0910S,No1202S),No0906S))),No1206S),((No0912S,No1103S),(No0909S,(No1007S,No1208S)))),No1114S,No305);
+(((No0908S,((No1206S,((No0910S,No1202S),No0906S)),(No306,(No0913S,No304)))),((No0912S,No1103S),(No1208S,(No0909S,No1007S)))),No1114S,No305);
+((((No1202S,(((No0908S,No1206S),No0906S),No0910S)),(No306,(No0913S,No304))),((No0912S,No1103S),(No0909S,(No1007S,No1208S)))),No1114S,No305);
+(((((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),(No306,(No0913S,No304))),(No0912S,(No1103S,(No0909S,(No1007S,No1208S))))),No1114S,No305);
+(((((No1206S,(No0906S,(No0913S,(No0910S,No1202S)))),No0908S),(No304,No306)),((No1208S,(No0909S,No1007S)),(No0912S,No1103S))),No1114S,No305);
+((((No1103S,(No1007S,(No1208S,No0909S))),No0912S),((((No0910S,No1202S),No0906S),(No0908S,No1206S)),(No0913S,(No304,No306)))),No1114S,No305);
+((((No1208S,No0909S),No1007S),(((No306,(No304,No0913S)),((No1206S,(No0906S,(No0910S,No1202S))),No0908S)),(No1103S,No0912S))),No1114S,No305);
+((((No306,(No304,No0913S)),((No1206S,(No0906S,(No0910S,No1202S))),No0908S)),((No1103S,No0912S),(No1208S,(No0909S,No1007S)))),No1114S,No305);
+(((No306,(((No0909S,(No1007S,No1208S)),(No304,No0913S)),((No0906S,(No0910S,No1202S)),(No0908S,No1206S)))),(No1103S,No0912S)),No1114S,No305);
+(((No306,(No304,No0913S)),(((No0908S,No1206S),(No0906S,(No0910S,No1202S))),((No1208S,(No0909S,No1007S)),(No1103S,No0912S)))),No1114S,No305);
+(((((No1007S,(No1208S,No0909S)),No0912S),No1103S),((No306,(No304,No0913S)),((No0908S,No1206S),(No0906S,(No0910S,No1202S))))),No1114S,No305);
+(((No306,((No1114S,No304),No0913S)),(No0908S,(No1206S,(No1202S,(No0906S,No0910S))))),((No0909S,(No1007S,No1208S)),(No0912S,No1103S)),No305);
+(((((No306,(No304,No0913S)),No0908S),(No1206S,(No0906S,(No0910S,No1202S)))),((No0912S,No1103S),((No0909S,No1208S),No1007S))),No1114S,No305);
+((((No0909S,No1208S),No1007S),(((No0908S,No1206S),(((No0906S,(No0910S,No1202S)),No0913S),(No306,No304))),(No0912S,No1103S))),No1114S,No305);
+((((No0909S,No1208S),No1007S),((No0912S,No1103S),(No0908S,((No306,(No304,No0913S)),(No1206S,((No0910S,No1202S),No0906S)))))),No1114S,No305);
+(((No0912S,No1103S),((No0906S,((((No304,No0913S),No306),(No0908S,No1206S)),(No0910S,No1202S))),((No0909S,No1208S),No1007S))),No1114S,No305);
+((((No1208S,No0909S),No1007S),((((No306,(No304,No0913S)),(No0906S,(No0910S,(No1202S,No1206S)))),No0908S),(No1103S,No0912S))),No1114S,No305);
+(((((No306,(No304,No0913S)),((No0906S,(No0910S,No1202S)),No1206S)),No0908S),((No1208S,(No0909S,No1007S)),(No0912S,No1103S))),No1114S,No305);
+((((No306,(No304,No0913S)),((No0906S,(No0908S,No1206S)),((No1007S,(No1208S,No0909S)),(No0910S,No1202S)))),(No0912S,No1103S)),No1114S,No305);
+(((No1206S,(No0906S,(No0910S,No1202S))),(No0908S,((No0912S,No1103S),(No1007S,(No1208S,No0909S))))),(No306,((No1114S,No304),No0913S)),No305);
+(((No0912S,No1103S),(No1208S,(No0909S,No1007S))),(((No306,((No1114S,No304),No0913S)),(No1206S,(No0906S,(No0910S,No1202S)))),No0908S),No305);
+((No0912S,No1103S),((No0909S,(No1007S,No1208S)),((((No306,(No304,No0913S)),No1114S),(No1202S,(No0906S,(No1206S,No0910S)))),No0908S)),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No1208S,No0909S))),((((No0910S,No1202S),No0906S),(No306,(No304,No0913S))),(No1206S,No0908S))),No305);
+(No1114S,(((No0912S,No1103S),(No1208S,(No0909S,No1007S))),((No0908S,((No0910S,No1202S),(No1206S,No0906S))),(No306,(No304,No0913S)))),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No1208S,No0909S))),((No0908S,((No1206S,No0906S),(No0910S,No1202S))),(No306,(No304,No0913S)))),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No1208S,No0909S))),(((No1206S,(No0906S,(No0910S,No1202S))),No0908S),(No306,(No304,No0913S)))),No305);
+(No1114S,(((No0912S,No1103S),(No0909S,(No1208S,No1007S))),((No1206S,((No0910S,No1202S),No0906S)),((No0908S,(No304,No0913S)),No306))),No305);
+((((No1007S,(No0909S,No1208S)),No0912S),No1103S),(No1114S,((No306,(No0913S,No304)),(No0908S,(No1206S,((No0910S,No1202S),No0906S))))),No305);
+((No0912S,No1103S),(No1114S,((No306,(No0913S,No304)),(((No0909S,(No1208S,No1007S)),No0908S),(No1206S,((No0910S,No1202S),No0906S))))),No305);
+(No1114S,(((No1007S,(No0909S,No1208S)),((No0908S,No1206S),((No306,(No0913S,No304)),((No0910S,No1202S),No0906S)))),(No0912S,No1103S)),No305);
+(No1114S,((No0906S,((No306,(No0913S,No304)),((No0908S,No1206S),(No0910S,No1202S)))),((No0912S,No1103S),(No1007S,(No0909S,No1208S)))),No305);
+(((No0908S,(No0906S,((No0910S,No1202S),No1206S))),(No306,(No0913S,No304))),(((No0912S,No1103S),(No0909S,(No1208S,No1007S))),No1114S),No305);
+(No1114S,(((No0908S,(No1206S,(No0906S,(No0910S,No1202S)))),(No306,(No0913S,No304))),((No0912S,No1103S),(No0909S,(No1208S,No1007S)))),No305);
+(No1114S,((No0913S,((((No0912S,No1103S),(No1007S,(No0909S,No1208S))),(No0908S,(No1206S,(No0906S,(No0910S,No1202S))))),No306)),No304),No305);
+(((No1007S,(No0909S,No1208S)),(((No0908S,(No1206S,(No0906S,(No0910S,No1202S)))),(No306,(No304,No0913S))),(No0912S,No1103S))),No1114S,No305);
+(((No0912S,No1103S),(((No0908S,(No1206S,(No0906S,(No0910S,No1202S)))),(No306,(No304,No0913S))),(No0909S,(No1208S,No1007S)))),No1114S,No305);
+(No0908S,((No0912S,(No1103S,(No0909S,(No1007S,No1208S)))),((No1114S,(No306,(No304,No0913S))),(No1206S,(No0906S,(No0910S,No1202S))))),No305);
+(((((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),No0908S),(No1114S,(No306,(No304,No0913S)))),(No1206S,(No0906S,(No0910S,No1202S))),No305);
+(No1114S,(((No1206S,(No0906S,(No0910S,No1202S))),((No306,(No304,No0913S)),No0908S)),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No305);
+(No1114S,(((No1206S,(No0906S,(No0910S,No1202S))),((No306,(No304,No0913S)),No0908S)),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No305);
+(No1114S,(((No1206S,(No0906S,(No0910S,No1202S))),((No306,(No304,No0913S)),No0908S)),((No0909S,(No1007S,No1208S)),(No0912S,No1103S))),No305);
+(No1114S,(((No1206S,(No0906S,(No0910S,No1202S))),((No306,(No304,No0913S)),No0908S)),((No0909S,(No1007S,No1208S)),(No0912S,No1103S))),No305);
+(No1114S,(((No1206S,(No0906S,(No0910S,No1202S))),((No306,(No304,No0913S)),No0908S)),((No0909S,(No1007S,No1208S)),(No0912S,No1103S))),No305);
+((((No0908S,No1206S),(No0906S,(No0910S,No1202S))),(No1114S,(No306,(No304,No0913S)))),((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),No305);
+(No1114S,((No306,(No304,No0913S)),((No0908S,No1206S),(((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),(No0906S,(No0910S,No1202S))))),No305);
+(((No0912S,No1103S),(No0909S,(No1007S,No1208S))),((No0906S,(No0910S,No1202S)),(((No0913S,(No304,No306)),No1114S),(No0908S,No1206S))),No305);
+(No1114S,(No306,(((No1208S,(No0909S,No1007S)),(No0912S,No1103S)),(((No0906S,(No0910S,No1202S)),(No0908S,No1206S)),(No304,No0913S)))),No305);
+(No1114S,(((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),((No306,(No304,No0913S)),(((No0906S,(No0910S,No1202S)),No1206S),No0908S))),No305);
+(No1114S,(((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),((No306,(No304,No0913S)),(((No0906S,(No0910S,No1202S)),No1206S),No0908S))),No305);
+(No1114S,(((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),((No306,(No304,No0913S)),(((No0906S,(No0910S,No1202S)),No1206S),No0908S))),No305);
+((((No0909S,(No1007S,No1208S)),(No0912S,No1103S)),((((No0906S,No0910S),No1206S),No1202S),((No306,No1114S),(No0913S,No304)))),No0908S,No305);
+(((((No0910S,No1202S),No0906S),No1206S),(No0908S,(No1114S,((No0913S,No304),No306)))),((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),No305);
+(No1114S,(((No0913S,No306),((((No0908S,No1206S),No0906S),((No1208S,(No0909S,No1007S)),(No0912S,No1103S))),(No0910S,No1202S))),No304),No305);
+(No1114S,((No0912S,No1103S),((No0909S,(No1007S,No1208S)),(((No304,No1206S),(No0906S,(No0913S,(No1202S,No0910S)))),(No306,No0908S)))),No305);
+(No1114S,(((No0912S,No1103S),(No1007S,(No1208S,No0909S))),(((No1206S,(No0906S,(No0910S,No1202S))),No0908S),((No0913S,No304),No306))),No305);
+(No1114S,((No0912S,No1103S),((No1007S,(No1208S,No0909S)),((No0908S,(No1206S,(No0906S,(No0910S,No1202S)))),((No0913S,No304),No306)))),No305);
+((((No0912S,(No1103S,(No1007S,(No0909S,No1208S)))),(((No0913S,(No1202S,No0910S)),No0906S),(No0908S,No1206S))),(No304,No306)),No1114S,No305);
+((((No0909S,(No1208S,No1007S)),(No0912S,No1103S)),((No306,((No304,No0913S),((No1202S,No0910S),No0906S))),(No0908S,No1206S))),No1114S,No305);
+(((No0912S,No1103S),(((No306,(No304,No0913S)),(No0908S,(((No1202S,No0910S),No0906S),No1206S))),(No1007S,(No0909S,No1208S)))),No1114S,No305);
+(((((((No1202S,No0910S),No0906S),No1206S),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),(No306,(No304,No0913S))),No0908S),No1114S,No305);
+((((No306,(No0908S,No1206S)),(((No0913S,(No1202S,No0910S)),No0906S),No304)),((No0909S,(No1208S,No1007S)),(No0912S,No1103S))),No1114S,No305);
+(((((((No1202S,No0910S),No0906S),No1206S),No0908S),(No306,(No304,No0913S))),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))),No1114S,No305);
+(((((No1114S,(No1007S,No1208S)),No0909S),((No0906S,(No1206S,(No1202S,No0910S))),No0908S)),(No1103S,No0912S)),(No306,(No304,No0913S)),No305);
+((((No1103S,No0912S),((No1007S,No1208S),No0909S)),((((No306,(No304,No0913S)),No1206S),No0906S),((No1202S,No0910S),No0908S))),No1114S,No305);
+((((No306,(No304,No0913S)),No1114S),(No0908S,(No1206S,(No0906S,(No1202S,No0910S))))),((No0912S,No1103S),(No1007S,(No1208S,No0909S))),No305);
+((((No0913S,(No306,No304)),(No0908S,(No1206S,(No0906S,(No1202S,No0910S))))),((No0912S,No1103S),(No1208S,(No0909S,No1007S)))),No1114S,No305);
+((((No0912S,(No1208S,(No1007S,No0909S))),No1103S),((((No0913S,No304),No306),(((No0910S,No1202S),No0906S),No1206S)),No0908S)),No1114S,No305);
+((((No0912S,(No1208S,(No1007S,No0909S))),No1103S),((((No0913S,No304),No306),(((No0910S,No1202S),No0906S),No1206S)),No0908S)),No1114S,No305);
+((((No0909S,(No1208S,No1007S)),(No1103S,No0912S)),(((No0908S,No304),((((No0913S,No0910S),No1202S),No0906S),No1206S)),No306)),No1114S,No305);
+((((No1007S,(No0909S,No1208S)),(No1103S,No0912S)),((No0908S,(((No1202S,No0910S),No0906S),No1206S)),((No0913S,No304),No306))),No1114S,No305);
+((((No0909S,(No1208S,No1007S)),(No1103S,No0912S)),((No0908S,(((No1202S,No0910S),No0906S),No1206S)),((No0913S,No304),No306))),No1114S,No305);
+((((No0909S,(No1208S,No1007S)),(No1103S,No0912S)),((No0908S,(((No1202S,No0910S),No0906S),No1206S)),((No0913S,No304),No306))),No1114S,No305);
+((((No1007S,(No0909S,No1208S)),(No1103S,No0912S)),((No0908S,(((No1202S,No0910S),No0906S),No1206S)),((No0913S,No304),No306))),No1114S,No305);
+(((No1103S,No0912S),((((No0908S,No1206S),((No0913S,No304),No306)),((No1202S,No0910S),No0906S)),(No1007S,(No0909S,No1208S)))),No1114S,No305);
+(((No1103S,No0912S),(((No0908S,((No0913S,No304),No306)),((No1202S,No0910S),(No1206S,No0906S))),(No0909S,(No1208S,No1007S)))),No1114S,No305);
+((((No0913S,No304),No306),(((No1206S,(No0906S,(No1202S,No0910S))),No0908S),((No0909S,(No1208S,No1007S)),(No1103S,No0912S)))),No1114S,No305);
+(No1114S,(((No0906S,(No0913S,(No1202S,No0910S))),((No0908S,No1206S),(No304,No306))),(No1103S,((No1007S,(No0909S,No1208S)),No0912S))),No305);
+(No1114S,(((No1206S,(No0906S,(No0913S,(No1202S,No0910S)))),(No0908S,(No304,No306))),(No1103S,((No0909S,(No1208S,No1007S)),No0912S))),No305);
+(No1114S,(((No1206S,(No0906S,(No0913S,(No1202S,No0910S)))),(No0908S,(No304,No306))),(No1103S,((No0909S,(No1208S,No1007S)),No0912S))),No305);
+(No1114S,((((No0908S,No1206S),(No0910S,(No1202S,No0906S))),((No0913S,No304),No306)),((No0909S,(No1208S,No1007S)),(No0912S,No1103S))),No305);
+(No1114S,((((No0906S,No0910S),(No1206S,No1202S)),((No0908S,(No0913S,No304)),No306)),((No0909S,(No1208S,No1007S)),(No0912S,No1103S))),No305);
+(No1114S,(((No1206S,(No0906S,(No0910S,No1202S))),(No0908S,((No0913S,No304),No306))),(((No1007S,(No0909S,No1208S)),No0912S),No1103S)),No305);
+(No1114S,(((((No1206S,No0908S),((No0906S,(No0910S,No1202S)),No306)),(No1007S,(No0909S,No1208S))),(No0913S,No304)),(No0912S,No1103S)),No305);
+(No1114S,((No306,(No0913S,No304)),(((((No1007S,(No0909S,No1208S)),No0912S),No1103S),No0908S),((No0906S,(No0910S,No1202S)),No1206S))),No305);
+((((No0912S,(No0909S,(No1208S,No1007S))),No1103S),((No0908S,(No306,(No0913S,No304))),((No0906S,(No0910S,No1202S)),No1206S))),No1114S,No305);
+((No0912S,No1103S),((No0909S,(No1208S,No1007S)),((No1114S,(No306,(No0913S,No304))),(((No0906S,(No0910S,No1202S)),No1206S),No0908S))),No305);
+(No1114S,(((No0909S,(No1007S,No1208S)),(No0912S,No1103S)),((No0906S,(No1202S,No0910S)),((No306,(No304,No0913S)),(No1206S,No0908S)))),No305);
+(No1114S,((No1007S,(No1208S,No0909S)),((No0912S,No1103S),((No306,(No304,No0913S)),(No0908S,(No1206S,(No0906S,(No1202S,No0910S))))))),No305);
+(No1114S,((((No0906S,(No1202S,No0910S)),(No306,(No304,No0913S))),(No0908S,No1206S)),(((No0909S,No1007S),No1208S),(No0912S,No1103S))),No305);
+(No1114S,((((No0906S,(No1202S,No0910S)),(No306,(No304,No0913S))),(No0908S,No1206S)),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No305);
+(No1114S,((((No1206S,(No0906S,(No1202S,No0910S))),(No306,(No304,No0913S))),No0908S),((No0909S,(No1007S,No1208S)),(No0912S,No1103S))),No305);
+(No1114S,((((No1206S,(No0906S,(No1202S,No0910S))),(No306,(No304,No0913S))),No0908S),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No305);
+(No1114S,((No0912S,No1103S),(((No306,(No304,No0913S)),(No0908S,(No1206S,(No0906S,(No1202S,No0910S))))),(No1007S,(No1208S,No0909S)))),No305);
+(No1114S,(((No306,(No304,No0913S)),(No0908S,(No1206S,(No0906S,(No1202S,No0910S))))),((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),No305);
+(No1114S,((No0912S,No1103S),(((No304,No0913S),((No0908S,(No1206S,(No0906S,(No1202S,No0910S)))),No306)),(No0909S,(No1007S,No1208S)))),No305);
+(No1114S,((((No0912S,No1103S),(No1007S,(No1208S,No0909S))),(No306,(No0908S,(No1206S,(No0906S,(No0913S,(No1202S,No0910S))))))),No304),No305);
+(No1114S,(((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),((No306,(No304,No0913S)),((No1206S,No0908S),(No0906S,(No1202S,No0910S))))),No305);
+(No1114S,(((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),((No306,(No304,No0913S)),(No0908S,((No0906S,(No1202S,No0910S)),No1206S)))),No305);
+(((No0908S,((No1007S,(No1208S,No0909S)),(No0912S,No1103S))),((No1114S,(No306,(No304,No0913S))),(No0906S,(No1202S,No0910S)))),No1206S,No305);
+(No1114S,((No306,(No304,No0913S)),(No1206S,(((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),(No0908S,(No0906S,(No1202S,No0910S)))))),No305);
+(No1114S,((((No1007S,(No1208S,No0909S)),No0912S),No1103S),((No306,(No304,No0913S)),((No0908S,No1206S),(No0906S,(No1202S,No0910S))))),No305);
+(No1114S,((((No1007S,(No1208S,No0909S)),No0912S),No1103S),(No306,((No304,No0913S),(No0908S,(No1206S,(No0906S,(No1202S,No0910S))))))),No305);
+(No1114S,(((No1208S,(No0909S,No1007S)),(No0912S,No1103S)),(((No1206S,No0908S),No0906S),((No1202S,No0910S),(No306,(No0913S,No304))))),No305);
+(No1114S,(((No0909S,(No1007S,No1208S)),(No0912S,No1103S)),(No1206S,((No0906S,(No1202S,No0910S)),(No0908S,(No306,(No0913S,No304)))))),No305);
+(No1114S,((No0912S,No1103S),((No0908S,No1206S),((No0906S,(No1202S,No0910S)),((No0909S,(No1007S,No1208S)),(No306,(No0913S,No304)))))),No305);
+(No1114S,((((No1007S,(No1208S,No0909S)),No0912S),No1103S),(((No1206S,(No0906S,(No1202S,No0910S))),No0908S),(No306,(No0913S,No304)))),No305);
+(((No1103S,No0912S),(No1007S,(No0909S,No1208S))),(((No0908S,No1206S),((No0910S,No1202S),No0906S)),(No1114S,(No306,(No304,No0913S)))),No305);
+((((No1103S,No0912S),(No1007S,(No0909S,No1208S))),((No0908S,(No1206S,((No0910S,No1202S),No0906S))),(No306,(No304,No0913S)))),No1114S,No305);
+(((No0909S,(No1208S,No1007S)),((((No0908S,No1206S),(No0906S,(No306,(No304,No0913S)))),(No0910S,No1202S)),(No0912S,No1103S))),No1114S,No305);
+((((No306,(No304,No0913S)),((No1206S,(No0906S,(No0910S,No1202S))),No0908S)),(((No1007S,(No0909S,No1208S)),No0912S),No1103S)),No1114S,No305);
+(((((No306,(No304,No0913S)),((No1206S,(No0906S,(No0910S,No1202S))),No0908S)),(No0909S,(No1208S,No1007S))),(No0912S,No1103S)),No1114S,No305);
+((((No0913S,No306),(((No0906S,((No0910S,No1202S),No1206S)),No0908S),((No1007S,(No0909S,No1208S)),(No0912S,No1103S)))),No304),No1114S,No305);
+((((No0909S,(No1208S,No1007S)),(No0912S,No1103S)),((No1206S,((No304,No0913S),No306)),(No0906S,((No0910S,No1202S),No0908S)))),No1114S,No305);
+((((No0909S,(No1208S,No1007S)),(No0912S,No1103S)),((No0908S,((No304,No0913S),No306)),(((No0910S,No1202S),No0906S),No1206S))),No1114S,No305);
+((((((No1007S,(No0909S,No1208S)),No0912S),No1103S),No0906S),((No0908S,No1206S),(No0910S,No1202S))),(No1114S,((No304,No0913S),No306)),No305);
+(((No0909S,(No1208S,No1007S)),((No0912S,No1103S),(((No0908S,No1206S),(No0906S,(No0910S,No1202S))),((No304,No0913S),No306)))),No1114S,No305);
+(((No1103S,(No0912S,(No1007S,(No1208S,No0909S)))),((No1206S,(No0906S,(No0910S,No1202S))),(((No304,No0913S),No306),No0908S))),No1114S,No305);
+(((No1103S,(No0912S,(No1007S,(No1208S,No0909S)))),(No0906S,(((No0908S,No1206S),((No0910S,No1202S),(No304,No0913S))),No306))),No1114S,No305);
+(((No0909S,(No1007S,No1208S)),(No1103S,No0912S)),((No0908S,(No1206S,(No0906S,(No0910S,No1202S)))),(No1114S,(No306,(No304,No0913S)))),No305);
+(No1114S,(((No306,(No304,No0913S)),(No0908S,(No1206S,(No0906S,(No0910S,No1202S))))),((No1103S,No0912S),(No1007S,(No0909S,No1208S)))),No305);
+(No1114S,(((No306,(No304,No0913S)),((No1206S,No0908S),(No0906S,(No1202S,No0910S)))),((No1103S,No0912S),(No1007S,(No0909S,No1208S)))),No305);
+(No1114S,((No1007S,(No0909S,No1208S)),(((No0906S,((No1202S,No0910S),No1206S)),((No306,(No304,No0913S)),No0908S)),(No1103S,No0912S))),No305);
+(No1114S,(No304,((No0908S,(No1206S,((No0906S,(No0913S,(No1202S,No0910S))),((No1007S,(No0909S,No1208S)),(No0912S,No1103S))))),No306)),No305);
+(((No0909S,(No1208S,No1007S)),(No0912S,No1103S)),(No0908S,(((No306,No304),No1114S),(No1206S,(No0906S,(No0913S,(No1202S,No0910S)))))),No305);
+((No0908S,(((No1007S,(No0909S,No1208S)),(No0912S,No1103S)),((No0906S,(No1202S,No0910S)),No1206S))),((No306,(No0913S,No304)),No1114S),No305);
+(((No0912S,No1103S),((((No0906S,(No1202S,No0910S)),No1206S),((No306,(No0913S,No304)),No0908S)),(No1208S,(No1007S,No0909S)))),No1114S,No305);
+(((No1103S,(No0912S,(No1007S,(No1208S,No0909S)))),(((No0906S,((No1202S,No0913S),No0910S)),((No1206S,No0908S),No306)),No304)),No1114S,No305);
+(((No1103S,(No0912S,(No1208S,(No0909S,No1007S)))),((No0906S,(No0913S,(No0910S,No1202S))),((No1206S,No0908S),(No304,No306)))),No1114S,No305);
+(((No1103S,(No0912S,(No1007S,(No1208S,No0909S)))),((((No0906S,(No0913S,(No0910S,No1202S))),No306),(No1206S,No0908S)),No304)),No1114S,No305);
+(((No1103S,(No0912S,(No1208S,(No0909S,No1007S)))),(((No0913S,((No0910S,No1202S),No0906S)),(No304,No306)),(No1206S,No0908S))),No1114S,No305);
+(((((No1208S,(No0909S,No1007S)),(No1103S,No0912S)),((No1206S,((No0910S,No1202S),No0906S)),No0908S)),(No306,(No304,No0913S))),No1114S,No305);
+((((No0912S,No1103S),(No1007S,(No1208S,No0909S))),((((No306,(No304,No0913S)),No1206S),((No0910S,No1202S),No0906S)),No0908S)),No1114S,No305);
+(((No0912S,No1103S),((No0909S,(No1007S,No1208S)),((No306,(No304,No0913S)),(No0908S,((No1206S,(No0910S,No1202S)),No0906S))))),No1114S,No305);
+((((No0908S,(((No0913S,(No0910S,No1202S)),No0906S),No1206S)),(No306,No304)),((No0912S,No1103S),(No1007S,(No1208S,No0909S)))),No1114S,No305);
+(No1114S,(((No0909S,(No1007S,No1208S)),((No0908S,(((No0910S,No1202S),No0906S),No1206S)),(No306,(No0913S,No304)))),(No0912S,No1103S)),No305);
+(No1114S,((((No1206S,No0908S),No0906S),(No306,(((No0910S,No1202S),No0913S),No304))),((No0912S,No1103S),(No1007S,(No1208S,No0909S)))),No305);
+(No1114S,((((No306,(No304,No0913S)),(No1206S,(No0906S,(No0910S,No1202S)))),(No0912S,(No1103S,(No0909S,(No1208S,No1007S))))),No0908S),No305);
+(No1114S,((((No306,(No304,No0913S)),((No0906S,(No0910S,No1202S)),No1206S)),No0908S),((No0912S,No1103S),(No0909S,(No1208S,No1007S)))),No305);
+(No1114S,(((No0908S,No1206S),((No306,No304),(No0906S,(No0913S,(No0910S,No1202S))))),((No0912S,No1103S),(No1007S,(No0909S,No1208S)))),No305);
+(No1114S,(No0906S,((No306,(No0913S,No304)),(((No0908S,No1206S),(No0910S,No1202S)),((No0912S,No1103S),(No1007S,(No0909S,No1208S)))))),No305);
+(No1114S,(((No0909S,(No1208S,No1007S)),(No0912S,No1103S)),(((No0908S,No1206S),((No0906S,(No0913S,(No0910S,No1202S))),No306)),No304)),No305);
+(((No0912S,No1103S),(No0909S,(No1208S,No1007S))),(No0908S,((No1206S,(No0906S,(No1202S,No0910S))),(No1114S,((No0913S,No304),No306)))),No305);
+((((No0912S,No1103S),(No1007S,(No0909S,No1208S))),((No0908S,(No1206S,(No0906S,(No1202S,No0910S)))),((No0913S,No304),No306))),No1114S,No305);
+(((No1007S,(No0909S,No1208S)),((((No0913S,No304),No306),No0912S),(No1103S,((No1206S,(No0906S,(No1202S,No0910S))),No0908S)))),No1114S,No305);
+(No0908S,((((No1007S,(No0909S,No1208S)),No0912S),No1103S),((No1114S,((No304,No0913S),No306)),(((No1202S,No1206S),No0910S),No0906S))),No305);
+(No1114S,((((No304,No0913S),No306),((((No1202S,No0910S),No0906S),No1206S),No0908S)),(((No0909S,(No1208S,No1007S)),No0912S),No1103S)),No305);
+(No1114S,(((No0912S,(No1007S,(No1208S,No0909S))),No1103S),(((No1206S,No0908S),((No0913S,(No0906S,(No0910S,No1202S))),No304)),No306)),No305);
+(No1114S,((No0912S,No1103S),((No1007S,(No1208S,No0909S)),(No304,(No306,((No1206S,No0908S),(No0906S,((No0910S,No1202S),No0913S))))))),No305);
+(No1114S,(((No1208S,(No0909S,No1007S)),(No0912S,No1103S)),(((No304,No0913S),No306),(No0908S,((No0906S,(No0910S,No1202S)),No1206S)))),No305);
+(No1114S,(((No1208S,(No0909S,No1007S)),(No0912S,No1103S)),(((No304,No0913S),No306),(No0908S,((No0906S,(No0910S,No1202S)),No1206S)))),No305);
+(No1114S,(((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),(((No304,((No0910S,No1202S),No0913S)),No306),((No1206S,No0908S),No0906S))),No305);
+(No1114S,(((No0909S,(No1007S,No1208S)),(No0912S,No1103S)),(((No0913S,No304),No306),((No1206S,(No0906S,(No0910S,No1202S))),No0908S))),No305);
+(No1114S,(((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),(((((No0913S,No304),No306),(No1206S,(No0910S,No1202S))),No0906S),No0908S)),No305);
+(No1114S,(((No1007S,(No1208S,No0909S)),(No0912S,No1103S)),(((No0913S,No304),No306),((No0908S,No1206S),(No0906S,(No0910S,No1202S))))),No305);
+(No1114S,((No1208S,(No0909S,No1007S)),((No0912S,No1103S),(((No0913S,No304),No306),((No0908S,No1206S),(No0906S,(No0910S,No1202S)))))),No305);
+(No1114S,((((((No0913S,No304),No306),(No0908S,(No0906S,((No0910S,No1202S),No1206S)))),(No0909S,(No1007S,No1208S))),No0912S),No1103S),No305);
+(No1114S,((No0912S,(No1103S,(No0909S,(No1007S,No1208S)))),((No304,No306),((No1206S,No0908S),(No0906S,(No0913S,(No0910S,No1202S)))))),No305);
+(No1114S,((No0909S,(No1007S,No1208S)),((No0912S,(No1103S,(No0908S,((No1206S,(No0906S,(No1202S,No0910S))),(No304,No0913S))))),No306)),No305);
+(No1114S,((((No0908S,No1206S),(No0906S,(No1202S,No0910S))),(No306,(No304,No0913S))),((No1208S,(No0909S,No1007S)),(No0912S,No1103S))),No305);
+(No1114S,((No306,((((No1007S,(No1208S,No0909S)),No0912S),No1103S),((No0906S,((No1202S,No0910S),No1206S)),No0908S))),(No0913S,No304)),No305);
+(No1114S,((((No0909S,(No1007S,No1208S)),No0912S),No1103S),((No1206S,No0908S),(No0906S,(((No1202S,No0910S),No0913S),(No304,No306))))),No305);
+(No1114S,(No304,((No306,((((No1206S,No0906S),(No1202S,No0910S)),No0908S),(((No0909S,(No1007S,No1208S)),No0912S),No1103S))),No0913S)),No305);
+(No1114S,((No1007S,(No1208S,No0909S)),((No0912S,No1103S),(No0908S,((No1206S,(No0906S,(No1202S,No0910S))),((No0913S,No304),No306))))),No305);
+(No1114S,((No0909S,(No1007S,No1208S)),((No0912S,No1103S),(No0908S,((No1206S,(No0906S,(No1202S,No0910S))),((No0913S,No304),No306))))),No305);
+(No1114S,((No0912S,No1103S),((No0908S,((No0909S,(No1007S,No1208S)),((No0913S,No304),No306))),(No1206S,(No0906S,(No1202S,No0910S))))),No305);
+(No1114S,((No1007S,(No1208S,No0909S)),((No0912S,No1103S),(((No1206S,(No0906S,(No1202S,No0910S))),((No0913S,No304),No306)),No0908S))),No305);
+(No1114S,(((No306,(No0913S,No304)),((No1206S,No0908S),(No0906S,(No1202S,No0910S)))),(((No1208S,No0909S),No1007S),(No0912S,No1103S))),No305);
+(((((No1206S,No0906S),(No1202S,No0910S)),No0908S),(No1114S,(No306,(No0913S,No304)))),((No0909S,(No1007S,No1208S)),(No0912S,No1103S)),No305);
+(No1114S,(((No306,(No0913S,No304)),((No1206S,(No0906S,(No1202S,No0910S))),No0908S)),((No0912S,No1103S),(No1007S,(No1208S,No0909S)))),No305);
+(No1114S,((No0906S,(((No1206S,No0908S),((No0913S,No304),(No1202S,No0910S))),((No0912S,No1103S),(No0909S,(No1007S,No1208S))))),No306),No305);
+(No1114S,(((No0906S,((No0913S,(No306,No304)),(No1202S,No0910S))),(No1206S,No0908S)),((No0912S,No1103S),(No0909S,(No1007S,No1208S)))),No305);
+(No1114S,(((No306,(No304,No0913S)),((((No1202S,No0910S),No0906S),No1206S),No0908S)),((No0912S,No1103S),(No1007S,(No1208S,No0909S)))),No305);
+(((No306,((No1114S,No304),No0913S)),((((No1202S,No0910S),No0906S),No1206S),No0908S)),((No0912S,No1103S),(No0909S,(No1007S,No1208S))),No305);
+(No1114S,(((No1007S,(No1208S,No0909S)),(((((No1202S,No0910S),No0906S),No1206S),No0908S),(No306,(No304,No0913S)))),(No0912S,No1103S)),No305);
+(((No306,(No304,No0913S)),No1114S),((((No1202S,No0910S),No0906S),(No1206S,No0908S)),(No0912S,(No1103S,(No1007S,(No1208S,No0909S))))),No305);
+(No1114S,((No0912S,No1103S),((((No1202S,No0910S),(No1007S,(No1208S,No0909S))),(No0906S,No1206S)),((No306,(No304,No0913S)),No0908S))),No305);
+(No1114S,((((No0908S,((No306,(No304,No0913S)),(No1206S,(No0906S,(No1202S,No0910S))))),(No1007S,(No1208S,No0909S))),No1103S),No0912S),No305);
+(No1114S,(((No306,(No304,No0913S)),((No1206S,(No0906S,(No1202S,No0910S))),No0908S)),((No1007S,(No1208S,No0909S)),(No1103S,No0912S))),No305);
+(No1114S,(((No306,(No304,No0913S)),((No1206S,(No0906S,(No1202S,No0910S))),No0908S)),((No1007S,(No1208S,No0909S)),(No1103S,No0912S))),No305);
+(No1114S,((((No1202S,No0910S),(No306,(No304,No0913S))),((No0908S,No1206S),No0906S)),(No0912S,((No1007S,(No1208S,No0909S)),No1103S))),No305);
+(No1114S,((No0908S,((No306,(No304,No0913S)),(No1206S,(No0906S,(No1202S,No0910S))))),((No1007S,(No1208S,No0909S)),(No1103S,No0912S))),No305);
+((((No1202S,No0910S),(No0908S,No1206S)),((No306,((No1114S,No304),No0913S)),No0906S)),((No1208S,(No0909S,No1007S)),(No1103S,No0912S)),No305);
+(((No0906S,No1206S),(No1202S,No0910S)),(((No306,(No304,No0913S)),No1114S),(No0908S,(((No0909S,(No1007S,No1208S)),No1103S),No0912S))),No305);
+(((No0912S,No1103S),(No1007S,(No1208S,No0909S))),(((No306,(No304,No0913S)),((No1206S,((No1202S,No0910S),No0906S)),No0908S)),No1114S),No305);
+(No1114S,(((No306,(No304,No0913S)),((No0912S,No1103S),(No0909S,(No1007S,No1208S)))),((No1206S,((No1202S,No0910S),No0906S)),No0908S)),No305);
+(((No1103S,No0912S),(No0909S,(No1007S,No1208S))),(((No1206S,No0906S),((No306,((No1114S,No304),No0913S)),No0908S)),(No1202S,No0910S)),No305);
diff --git a/inst/extdata/trees/woodmouse.fasta b/inst/extdata/trees/woodmouse.fasta
new file mode 100644
index 0000000..8c3d4e5
--- /dev/null
+++ b/inst/extdata/trees/woodmouse.fasta
@@ -0,0 +1,30 @@
+>No305
+nttcgaaaaacacacccactactaaaanttatcagtcactccttcatcgacttaccagctccatctaacatttcatcatgatgaaacttcggctcattactaggagtctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgtcgagacgtaaattatggctgactaattcgatacatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatgtattacgggtcatacattttcatagaaacatgaaacatcggtgtggtccttttattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaanttactatcagcaattccatacatcggaactaccctagtagagtgaatctgaggagga [...]
+>No304
+attcgaaaaacacacccactactaaaaattatcaaccactccttcatcgacttaccagctccatctaacatttcatcatgatgaaacttcggctcattactaggaatctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgtcgagacgtaaattatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatgtattacgggtcatacatttttatagaaacatgaaacatcggtgtagtccttttattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattncaaatttactntcagcaattccatacatcggaactaccctagtagaatgaatctgaggagga [...]
+>No306
+attcgaaaaacacacccactactaaaaattatcaatcactccttcatcgacttaccagctccatctaacatttcatcatgatgaaacttcggctcattactaggaatctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgtcgagacgtaaattatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatgtattacgggtcatacatttttatagaaacatgaaacatcggtgtgatccttttattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaatttactatcagcaattccatacatcggaactaccctagtagaatgaatctgaggagga [...]
+>No0906S
+attcgaaaaacacacccactactaaaaatcatcaatcactccttcatcgatttaccagctccatctaacatttcatcatgatgaaacttcggctcattactaggaatctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgtcgagacgtaaattatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatgtattacggatcatacatttttatagaaacatgaaacatcggtatgatccttttattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaatttactatcagcaattccatacatcggaactaccctagtagagtgaatctgaggagga [...]
+>No0908S
+attcgaaaaacacacccactactaaaaattatcaatcactccttcatcgacttaccagccccatctaacatttcatcatgatgaaacttcggctcattactaggaatctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgtcgagacgtaaattatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttctccatgtaggacgaggaatgtattacgggtcatacatttttatagaaacatgaaacatcggtgtgatccttttattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggggctacagtaattacaaatttactatcagcaattccatatatcggaactaccctagtagagtgaatctgaggagga [...]
+>No0909S
+attcgaaaaacacacccactactaaaaattatcaatcactccttcatcgacttaccagctccatctaacatctcatcatgatgaaacttcggctccttactaggaatctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgtcgagacgtaaactatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatgtattacgggtcatacactttcatagaaacatgaaacatcggtgtgatccttctattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaatttactatcagcaattccatacatcgggactaccctagtagagtgaatctgaggagga [...]
+>No0910S
+attcgaaaaacacacccactactaaaaattatcaatcactctttcatcgatttaccagctccatctaacatttcatcatgatgaaacttcggctcattactaggaatctgcctaataatccagatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgtcgagacgtaaattatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatgtattacggatcatacatttttatagaaacatgaaacatcggtgtgatccttttattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaatttactatcagcaattccatacatcggaactaccctagtagagtgaatctgaggagga [...]
+>No0912S
+attcgaaaaacacacccactactaaaaattatcaatcactccttcatcgacttaccagctccatctaacatctcatcatgatgaaacttcggctccttactaggaatctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgtcgagacgtaaattatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacggggaatgtattacgggtcatacattttcatagaaacatgaaacatcggtgtgatccttttattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaatttactatcagcaattccatacatcggaactaccctagtagagtgaatctgaggagga [...]
+>No0913S
+attcgaaaaacacacccactactaaaaattatcaaccactccttcatcgacttaccagctccatctaacatttcatcatgatgaaacttcggctcattactaggaatctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgtcgagacgtaaattatggctgactaattcgatatatgcatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatgtattacggatcatacatttttatagaaacatgaaacatcggtgtgatccttttattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaatttactatcagcaattccatacatcggaactaccctagtagaatgaatctgaggagga [...]
+>No1103S
+attcgaaaaacacacccactactaaaaattattaatcactccttcatcgacttaccagctccatctaacatctcatcatgatgaaacttcggctccttactaggaatctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgtcgagacgtaaattatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatgtattacgggtcatacattttcatagaaacatgaaacatcggtgtgatccttttattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaatttactatcagcaattccatacatcggaactaccctagtagagtgaatctgaggagga [...]
+>No1007S
+attcgaaaaacacacccactactaaaaattatcaatcactccttcatcgacttaccagctccatctaacatctcatcatgatgaaacttcggctccttactaggaatctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgccgagacgtaaattatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatgtattacgggtcatacactttcatagaaacatgaaacatcggtgtgatccttctattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaatttactatcagcaattccatacatcgggactaccctagtagagtgaatctgaggagga [...]
+>No1114S
+nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnatcgacttaccagctccatctaacatttcatcatgatgaaacttcggctcattactaggagtctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagnaacccatatttgccgagacgtaaattatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatatattacggctcatacattctcatagaaacatgaaacatcggtgtggtccttttattcgcagtaatagtcacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaatttcctatcagcaattccatacatcggaactaccctagtagagtgaatctgaggagga [...]
+>No1202S
+attcgaaaaacacacccactactaaaaattatcaatcactccttcatcgatttaccagctccatctaacatttcatcatgatgaaacttcggctcattactaggaatctgcctaataatccagatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgccgagacgtaaattatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatgtattacggatcatacatttttatagaaacatgaaacatcggtgtgatccttttattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaatttactatcagcaattccatacatcggaactaccctagtagagtgaatctgaggagga [...]
+>No1206S
+attcgaaaaacacacccactactaaaaattatcaatcactccttcatcgatttgccagctccatctaacatttcatcatgatgaaacttcggctcattactaggaatctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgtcgagacgtaaattatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttctccatgtaggacgaggaatgtattacgggtcatacatttttatagaaacatgaaacatcggtgtgatccttttattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaatttactatcagcaattccatacatcggaactaccctagtagagtgaatctgaggagga [...]
+>No1208S
+nnncgaaaaacacacccactactaaaaattatcaatcactccttcatcgacttaccagctccatctaacatctcatcatgatgaaacttcggctccttactaggaatctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgccgagacgtaaactatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatgtattacgggtcatacactttcatagaaacatgaaacatcggtgtgatccttctattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccctctgaggagctacagtaattacaaatttactatcagcaattccatacatcgggactaccctagtagagtgaatctgaggagga [...]
diff --git a/inst/extdata/trees/woodmouse.mrbayes.nex.con b/inst/extdata/trees/woodmouse.mrbayes.nex.con
new file mode 100644
index 0000000..cefb77f
--- /dev/null
+++ b/inst/extdata/trees/woodmouse.mrbayes.nex.con
@@ -0,0 +1,9 @@
+#NEXUS
+
+[ID: 2542150086]
+begin trees;
+   [Note: This tree contains information on the topology, 
+          branch lengths (if present), and the probability
+          of the partition indicated by the branch.]
+   tree con_50_majrule = (No305,No1114S,((((No304,No0913S)0.98,No306)0.90,(No0906S,(No0910S,No1202S)0.92)0.54,No0908S,No1206S)0.80,((No0909S,No1007S,No1208S)1.00,(No0912S,No1103S)0.50)0.94)0.80);
+end;
diff --git a/inst/extdata/trees/woodmouse.mrbayes.nex.run1.t b/inst/extdata/trees/woodmouse.mrbayes.nex.run1.t
new file mode 100644
index 0000000..8f560bf
--- /dev/null
+++ b/inst/extdata/trees/woodmouse.mrbayes.nex.run1.t
@@ -0,0 +1,1021 @@
+#NEXUS
+[ID: 2542150086]
+begin trees;
+   translate
+       1 No305,
+       2 No304,
+       3 No306,
+       4 No0906S,
+       5 No0908S,
+       6 No0909S,
+       7 No0910S,
+       8 No0912S,
+       9 No0913S,
+      10 No1103S,
+      11 No1007S,
+      12 No1114S,
+      13 No1202S,
+      14 No1206S,
+      15 No1208S;
+   tree rep.1 = ((((((3,((((((13,6),15),(5,9)),12),2),11)),7),8),4),10),14,1);
+   tree rep.10000 = (12,((8,(10,(11,(15,6)))),(((14,((7,13),4)),(3,(9,2))),5)),1);
+   tree rep.20000 = (((8,(10,((6,15),11))),(((2,9),((14,5),3)),(4,(7,13)))),12,1);
+   tree rep.30000 = (((4,(((7,(9,13)),(3,2)),(14,5))),((10,8),((15,6),11))),12,1);
+   tree rep.40000 = (((((6,11),15),(10,8)),(((3,(2,9)),(4,(14,(13,7)))),5)),12,1);
+   tree rep.50000 = (((((7,13),4),((11,(6,15)),(10,8))),((3,(2,9)),(14,5))),12,1);
+   tree rep.60000 = (12,(((8,10),((15,6),11)),(((4,(7,13)),(5,(3,(9,2)))),14)),1);
+   tree rep.70000 = (((4,(13,7)),(((((9,2),3),12),5),14)),((8,10),(11,(6,15))),1);
+   tree rep.80000 = (12,(((5,(14,((7,13),4))),(3,(2,9))),((8,((11,6),15)),10)),1);
+   tree rep.90000 = (12,((((2,9),3),(14,(5,(4,(7,13))))),(((11,(15,6)),8),10)),1);
+   tree rep.100000 = (((((9,2),3),(5,((14,(13,7)),4))),(8,(((15,6),11),10))),12,1);
+   tree rep.110000 = (((((6,15),11),(8,10)),(5,(((4,14),(7,13)),((2,9),3)))),12,1);
+   tree rep.120000 = (12,(((5,(14,(3,(9,2)))),((7,4),13)),(10,(((6,11),15),8))),1);
+   tree rep.130000 = (12,(((10,8),(11,(6,15))),((3,(2,9)),(5,((4,(13,7)),14)))),1);
+   tree rep.140000 = (12,(((3,(9,2)),((15,(11,6)),(10,8))),((5,(13,7)),(14,4))),1);
+   tree rep.150000 = (((4,(((9,2),3),(5,(14,(7,13))))),12),(((11,(6,15)),10),8),1);
+   tree rep.160000 = (((5,((14,((3,(9,2)),4)),(7,13))),(((15,11),6),(10,8))),12,1);
+   tree rep.170000 = (12,((((15,6),11),(8,10)),((14,(((13,7),4),5)),((2,9),3))),1);
+   tree rep.180000 = (((((7,13),4),5),((10,(8,(11,(6,15)))),(((9,2),3),14))),12,1);
+   tree rep.190000 = (12,((3,(9,2)),(((8,10),((15,6),11)),(5,(14,((13,7),4))))),1);
+   tree rep.200000 = ((((6,(11,15)),(10,8)),(((4,(13,7)),((2,9),3)),(14,5))),12,1);
+   tree rep.210000 = (((8,(10,(11,(15,6)))),(((13,7),4),(5,((3,(2,9)),14)))),12,1);
+   tree rep.220000 = ((((4,(7,13)),(((3,(9,2)),5),14)),(10,((11,(15,6)),8))),12,1);
+   tree rep.230000 = (12,((14,((((8,(11,(15,6))),10),(((13,7),5),4)),3)),(2,9)),1);
+   tree rep.240000 = ((((14,((2,9),3)),((((6,(15,11)),8),10),5)),(4,(13,7))),12,1);
+   tree rep.250000 = (12,(((6,(11,15)),(10,8)),((3,(9,2)),(5,((14,(13,7)),4)))),1);
+   tree rep.260000 = (((((11,(15,6)),10),8),((((3,(2,9)),14),(4,(13,7))),5)),12,1);
+   tree rep.270000 = (12,((5,14),((((8,10),((6,15),11)),((9,2),(4,(7,13)))),3)),1);
+   tree rep.280000 = ((((((7,13),((2,9),3)),(5,14)),((11,(15,6)),(10,8))),4),12,1);
+   tree rep.290000 = (((8,(((11,6),15),10)),((5,((2,9),3)),((4,14),(7,13)))),12,1);
+   tree rep.300000 = (12,((((3,(5,((7,13),4))),(2,9)),14),(8,(((11,15),6),10))),1);
+   tree rep.310000 = (((11,(6,15)),((5,((14,((13,7),4)),(3,(2,9)))),(10,8))),12,1);
+   tree rep.320000 = (12,((((15,6),11),(10,8)),(((3,(2,9)),(4,(14,(7,13)))),5)),1);
+   tree rep.330000 = ((((((11,(6,15)),(10,8)),(5,((7,13),(4,14)))),3),(2,9)),12,1);
+   tree rep.340000 = ((((10,8),(11,(15,6))),(((((2,9),3),(4,14)),(7,13)),5)),12,1);
+   tree rep.350000 = (12,((5,(((6,15),11),(10,8))),(((2,9),3),(4,(14,(7,13))))),1);
+   tree rep.360000 = (12,(((((6,15),11),8),10),((5,((2,9),3)),((14,(7,13)),4))),1);
+   tree rep.370000 = (12,((4,(14,((7,13),(5,(3,(9,2)))))),((11,(15,6)),(10,8))),1);
+   tree rep.380000 = (((((14,5),(4,(13,7))),((2,9),3)),(8,((6,(15,11)),10))),12,1);
+   tree rep.390000 = ((((((7,13),4),5),((2,9),3)),((((11,(15,6)),10),8),14)),12,1);
+   tree rep.400000 = (12,(((9,2),3),((((6,11),15),(8,10)),((14,5),(4,(7,13))))),1);
+   tree rep.410000 = ((5,((((4,(13,7)),14),((10,8),((11,15),6))),(3,(9,2)))),12,1);
+   tree rep.420000 = ((((8,(11,(15,6))),10),(5,((14,((13,7),4)),(3,(9,2))))),12,1);
+   tree rep.430000 = (12,((((9,2),((7,13),4)),(14,(3,5))),((8,(11,(6,15))),10)),1);
+   tree rep.440000 = (12,((5,((4,((3,(9,2)),(13,7))),14)),((8,((11,15),6)),10)),1);
+   tree rep.450000 = ((((8,10),((6,15),11)),(5,(((2,9),3),(14,((13,7),4))))),12,1);
+   tree rep.460000 = (((14,((5,((2,9),3)),(4,(13,7)))),((8,10),((15,11),6))),12,1);
+   tree rep.470000 = (((4,(13,7)),(14,(5,(3,(2,9))))),((10,((11,(15,6)),8)),12),1);
+   tree rep.480000 = (12,((((15,6),11),(8,10)),((((2,9),3),((4,(13,7)),14)),5)),1);
+   tree rep.490000 = ((((10,8),(11,(6,15))),(((9,2),3),(((4,(13,7)),14),5))),12,1);
+   tree rep.500000 = (12,(((10,(6,(15,11))),8),(((2,9),3),(5,(((7,13),4),14)))),1);
+   tree rep.510000 = (12,((8,(((11,6),15),10)),((4,(((2,9),3),5)),((13,7),14))),1);
+   tree rep.520000 = ((((11,(6,15)),(8,10)),12),((4,(13,7)),((5,14),(3,(9,2)))),1);
+   tree rep.530000 = (12,((((13,7),4),(14,5)),(((9,2),3),((15,(11,6)),(8,10)))),1);
+   tree rep.540000 = (12,((14,((4,((13,7),9)),(2,(3,5)))),((((15,11),6),8),10)),1);
+   tree rep.550000 = ((((3,((9,2),(14,((7,13),4)))),5),12),(10,(((11,15),6),8)),1);
+   tree rep.560000 = (12,((5,(3,((14,(4,(13,7))),(2,9)))),((10,8),((15,6),11))),1);
+   tree rep.570000 = (((((6,(15,11)),10),8),(((3,(2,9)),(((7,13),4),14)),5)),12,1);
+   tree rep.580000 = ((((5,(14,(7,(4,13)))),(3,(9,2))),(8,(10,(6,(11,15))))),12,1);
+   tree rep.590000 = (12,((5,(((4,(7,13)),14),((2,9),3))),(8,(10,(11,(6,15))))),1);
+   tree rep.600000 = ((10,(((((7,13),4),(5,(3,(2,9)))),14),8)),(12,((11,6),15)),1);
+   tree rep.610000 = (((((3,(2,9)),(14,((4,13),7))),5),(10,(8,(6,(15,11))))),12,1);
+   tree rep.620000 = (((3,(9,2)),(((((7,13),4),14),(((15,11),6),(8,10))),5)),12,1);
+   tree rep.630000 = (12,((((15,6),11),(8,10)),((((13,7),(14,4)),((2,9),3)),5)),1);
+   tree rep.640000 = (((((14,(7,13)),4),(3,(9,2))),(5,12)),(8,(((15,6),11),10)),1);
+   tree rep.650000 = (12,(((((11,15),6),10),8),(((5,3),4),(14,((13,7),(9,2))))),1);
+   tree rep.660000 = ((((6,(15,11)),(8,10)),(14,(((9,2),3),(((7,13),4),5)))),12,1);
+   tree rep.670000 = (((((11,(6,15)),8),10),(14,((7,13),(((3,(2,9)),5),4)))),12,1);
+   tree rep.680000 = (12,(((((2,9),3),5),(4,(14,(13,7)))),(8,(10,(11,(6,15))))),1);
+   tree rep.690000 = (((((13,7),((14,5),4)),(3,(9,2))),((10,8),((15,11),6))),12,1);
+   tree rep.700000 = (((5,((4,(3,(2,9))),(7,(13,14)))),(((6,11),15),(10,8))),12,1);
+   tree rep.710000 = (((5,14),((7,13),(4,((2,9),3)))),(12,(8,(((15,6),11),10))),1);
+   tree rep.720000 = (((2,9),3),((7,13),(5,(4,(14,((10,(8,(6,(11,15)))),12))))),1);
+   tree rep.730000 = (((((11,15),6),(10,8)),((4,(14,(7,13))),(5,(3,(2,9))))),12,1);
+   tree rep.740000 = ((12,((11,(15,6)),(10,8))),((14,4),(((7,13),5),((2,9),3))),1);
+   tree rep.750000 = (12,(((((9,2),3),(14,((13,7),4))),5),((10,8),((15,11),6))),1);
+   tree rep.760000 = ((((10,8),((11,6),15)),(5,((4,(14,(13,7))),(3,(2,9))))),12,1);
+   tree rep.770000 = (12,(((3,(2,9)),((10,((6,(11,15)),8)),(5,14))),((13,7),4)),1);
+   tree rep.780000 = (((3,(2,9)),(5,(14,(((8,10),((11,15),6)),12)))),(4,(13,7)),1);
+   tree rep.790000 = (12,(((14,(((3,(2,9)),(7,13)),4)),5),(8,(10,((15,6),11)))),1);
+   tree rep.800000 = (12,(((((9,2),3),5),(14,(4,(7,13)))),((8,((15,6),11)),10)),1);
+   tree rep.810000 = (12,((((15,11),6),(10,8)),(((9,2),3),((14,5),(4,(7,13))))),1);
+   tree rep.820000 = ((((14,(4,((7,13),(3,(9,2))))),5),(10,(8,(11,(15,6))))),12,1);
+   tree rep.830000 = (12,((((3,(2,9)),5),(14,(4,(7,13)))),(8,(10,(6,(15,11))))),1);
+   tree rep.840000 = ((((8,10),(11,(15,6))),(((14,(13,7)),4),(5,((2,9),3)))),12,1);
+   tree rep.850000 = (12,(((10,((15,11),6)),8),(((5,((7,13),4)),14),(3,(9,2)))),1);
+   tree rep.860000 = ((((((3,(9,2)),(14,(13,7))),4),5),((((6,15),11),10),8)),12,1);
+   tree rep.870000 = (12,(((((9,2),3),(5,14)),((8,(11,(15,6))),10)),((4,13),7)),1);
+   tree rep.880000 = ((((14,4),(13,7)),((((2,9),3),(10,((15,(6,11)),8))),5)),12,1);
+   tree rep.890000 = ((((4,(13,7)),(14,(5,(3,(2,9))))),(10,(((15,6),11),8))),12,1);
+   tree rep.900000 = (12,(((8,10),((6,15),11)),((5,14),((3,(2,9)),(4,(7,13))))),1);
+   tree rep.910000 = (((((14,(7,13)),((2,9),3)),(4,5)),(10,(8,(6,(11,15))))),12,1);
+   tree rep.920000 = ((12,(((9,2),3),(5,(((13,7),4),14)))),((8,(11,(6,15))),10),1);
+   tree rep.930000 = (((((3,(9,2)),5),(14,((13,7),4))),((8,((6,15),11)),10)),12,1);
+   tree rep.940000 = (12,(((8,10),(11,(15,6))),((((3,(2,9)),(7,13)),(5,14)),4)),1);
+   tree rep.950000 = (((((6,(15,11)),8),10),(((13,7),(14,4)),(5,(3,(2,9))))),12,1);
+   tree rep.960000 = ((((8,10),((6,15),11)),((((7,13),14),4),(((2,9),3),5))),12,1);
+   tree rep.970000 = ((((((4,14),5),(3,(9,2))),(7,13)),(8,((11,(15,6)),10))),12,1);
+   tree rep.980000 = (12,(((((14,4),(8,(10,(11,(15,6))))),5),(7,13)),((9,2),3)),1);
+   tree rep.990000 = (((5,((3,(9,2)),((7,(14,13)),4))),(10,(((6,11),15),8))),12,1);
+   tree rep.1000000 = (12,(((5,(((13,7),14),4)),((2,9),3)),((11,(15,6)),(10,8))),1);
+   tree rep.1010000 = (12,((((14,5),(((15,6),11),(10,8))),(4,(13,7))),(3,(2,9))),1);
+   tree rep.1020000 = (12,(((6,15),11),((4,(5,(((2,9),3),(14,(13,7))))),(8,10))),1);
+   tree rep.1030000 = (((5,3),((4,(7,13)),((2,9),14))),(((((15,11),6),8),10),12),1);
+   tree rep.1040000 = (12,(3,(((((14,4),((8,10),(6,(11,15)))),5),(13,7)),(2,9))),1);
+   tree rep.1050000 = (12,(((5,((4,(13,7)),14)),(3,(2,9))),(10,(8,(6,(15,11))))),1);
+   tree rep.1060000 = ((((4,((13,7),14)),(5,((8,10),(6,(15,11))))),(3,(2,9))),12,1);
+   tree rep.1070000 = (12,((((8,(10,((15,11),6))),14),((((9,2),3),5),(13,7))),4),1);
+   tree rep.1080000 = ((((10,8),((15,11),6)),12),((5,(14,(3,(9,2)))),(4,(7,13))),1);
+   tree rep.1090000 = (12,((10,8),(((6,11),15),((((7,13),(3,(2,9))),(5,14)),4))),1);
+   tree rep.1100000 = (12,((((13,(7,14)),(5,4)),(3,(2,9))),((8,((15,11),6)),10)),1);
+   tree rep.1110000 = ((((10,8),(6,(15,11))),((4,(((13,7),14),(3,(9,2)))),5)),12,1);
+   tree rep.1120000 = (((10,((6,(11,15)),8)),(((7,13),14),((4,5),((2,9),3)))),12,1);
+   tree rep.1130000 = ((((((9,2),(14,((13,7),4))),5),3),(8,(((15,11),6),10))),12,1);
+   tree rep.1140000 = ((((5,((10,8),((6,15),11))),((9,2),3)),(((13,7),14),4)),12,1);
+   tree rep.1150000 = ((10,8),((12,((5,3),((2,9),((4,(7,13)),14)))),((11,15),6)),1);
+   tree rep.1160000 = (12,(5,(((2,9),3),(((6,(15,11)),(10,8)),((13,7),(14,4))))),1);
+   tree rep.1170000 = (((14,(((7,13),4),(5,((9,2),3)))),(8,((6,(15,11)),10))),12,1);
+   tree rep.1180000 = ((((10,(11,(15,6))),8),(((7,(4,13)),14),(5,((2,9),3)))),12,1);
+   tree rep.1190000 = (12,((5,(((4,(7,13)),14),((9,2),3))),(8,(10,((6,15),11)))),1);
+   tree rep.1200000 = ((((14,(4,(7,13))),5),(3,(9,2))),(((10,8),((15,6),11)),12),1);
+   tree rep.1210000 = (12,(((8,10),((11,15),6)),((((13,7),4),5),(((9,3),2),14))),1);
+   tree rep.1220000 = ((((9,2),3),((14,((6,(15,11)),(8,10))),(((13,7),4),5))),12,1);
+   tree rep.1230000 = (((((9,2),3),((4,14),(13,7))),5),(12,((8,10),(11,(15,6)))),1);
+   tree rep.1240000 = ((((8,10),((15,11),6)),((5,((13,7),14)),((3,(9,2)),4))),12,1);
+   tree rep.1250000 = (12,((10,8),(((15,11),6),(14,((4,(13,7)),(5,((9,2),3)))))),1);
+   tree rep.1260000 = ((((((6,15),11),10),8),((14,((7,13),4)),((3,(9,2)),5))),12,1);
+   tree rep.1270000 = (12,(((7,13),(((2,9),3),((5,14),4))),((((6,11),15),10),8)),1);
+   tree rep.1280000 = ((14,((((10,8),((6,15),11)),5),(((3,(9,2)),(7,13)),4))),12,1);
+   tree rep.1290000 = (12,((8,(10,(11,(15,6)))),(((4,7),13),(14,(5,(3,(9,2)))))),1);
+   tree rep.1300000 = (((((13,7),((14,5),((9,2),3))),4),(10,(((6,15),11),8))),12,1);
+   tree rep.1310000 = ((((8,((6,15),11)),10),((3,(2,9)),((14,5),(4,(13,7))))),12,1);
+   tree rep.1320000 = (12,((((2,9),3),(5,((4,(7,13)),14))),((10,((15,11),6)),8)),1);
+   tree rep.1330000 = (12,(((3,(2,9)),(14,((5,4),(13,7)))),((((15,6),11),8),10)),1);
+   tree rep.1340000 = ((8,((((15,11),6),(5,(((4,14),(13,7)),((2,9),3)))),10)),12,1);
+   tree rep.1350000 = (((((5,14),((4,7),13)),((2,9),3)),(((11,(6,15)),10),8)),12,1);
+   tree rep.1360000 = ((12,((((15,11),6),8),10)),(5,((14,((7,13),4)),((9,2),3))),1);
+   tree rep.1370000 = ((((8,(6,(11,15))),10),(((5,14),((7,13),4)),(3,(9,2)))),12,1);
+   tree rep.1380000 = (((((13,7),14),(5,4)),((12,(2,9)),3)),((8,10),(6,(11,15))),1);
+   tree rep.1390000 = (12,(((4,(7,13)),((5,14),((2,9),3))),(10,(8,((15,11),6)))),1);
+   tree rep.1400000 = ((12,(8,(((15,6),11),10))),(((3,(9,2)),5),(14,((13,7),4))),1);
+   tree rep.1410000 = (((3,((5,(9,2)),12)),((4,(7,13)),14)),((10,((15,6),11)),8),1);
+   tree rep.1420000 = ((((10,(11,(15,6))),8),((14,5),(((9,2),3),(4,(7,13))))),12,1);
+   tree rep.1430000 = (12,(((11,(6,15)),(8,10)),((3,((13,7),4)),(((9,2),5),14))),1);
+   tree rep.1440000 = ((((5,((14,(4,(7,13))),((2,9),3))),(8,10)),(6,(11,15))),12,1);
+   tree rep.1450000 = (((((14,(5,(2,3))),4),((10,8),((11,15),6))),(9,(7,13))),12,1);
+   tree rep.1460000 = ((((((4,(13,7)),((5,14),(3,(9,2)))),10),8),(6,(11,15))),12,1);
+   tree rep.1470000 = (12,((8,(10,(11,(15,6)))),((((4,(7,13)),14),((2,9),3)),5)),1);
+   tree rep.1480000 = (((((7,(4,13)),(5,((9,2),3))),14),(((6,(15,11)),8),10)),12,1);
+   tree rep.1490000 = ((12,((3,(9,2)),((((7,4),13),14),5))),(((6,15),11),(8,10)),1);
+   tree rep.1500000 = ((7,((5,(14,((3,(2,9)),(4,((10,8),((15,6),11)))))),13)),12,1);
+   tree rep.1510000 = (((((6,11),15),(10,8)),((((13,7),14),4),(((2,9),3),5))),12,1);
+   tree rep.1520000 = ((((14,5),(((7,13),4),((2,9),3))),((8,10),((15,11),6))),12,1);
+   tree rep.1530000 = ((5,((4,(7,13)),(14,(3,(2,9))))),(12,(8,(10,(11,(15,6))))),1);
+   tree rep.1540000 = (12,(((3,(2,9)),((4,((14,13),7)),5)),(10,(8,((6,15),11)))),1);
+   tree rep.1550000 = (12,(((11,(15,6)),(10,8)),(5,(((9,2),3),(14,((7,13),4))))),1);
+   tree rep.1560000 = ((((3,(9,2)),((4,(13,7)),(5,14))),((11,(15,6)),(8,10))),12,1);
+   tree rep.1570000 = (((15,11),6),(5,((2,9),(((14,((4,3),12)),(13,7)),(10,8)))),1);
+   tree rep.1580000 = ((((11,(15,6)),(10,8)),(((4,(7,13)),14),(((2,9),3),5))),12,1);
+   tree rep.1590000 = (((((2,9),3),(4,((7,13),(14,5)))),((8,(6,(15,11))),10)),12,1);
+   tree rep.1600000 = ((((11,(15,6)),(10,8)),12),((((14,4),(13,7)),((2,9),3)),5),1);
+   tree rep.1610000 = ((((10,8),((11,15),6)),((((2,9),3),5),(14,(4,(7,13))))),12,1);
+   tree rep.1620000 = (((((2,9),3),((14,5),(4,(7,13)))),(10,(8,((6,15),11)))),12,1);
+   tree rep.1630000 = (((((7,13),((5,4),14)),((9,2),3)),(10,(8,(6,(11,15))))),12,1);
+   tree rep.1640000 = (((((14,5),((2,9),3)),(4,(13,7))),((11,(6,15)),(8,10))),12,1);
+   tree rep.1650000 = (((((3,(9,2)),(((13,7),14),4)),5),(((6,15),11),(8,10))),12,1);
+   tree rep.1660000 = ((((10,((15,11),6)),8),(4,(((14,(7,13)),5),(3,(2,9))))),12,1);
+   tree rep.1670000 = (((14,(((13,7),4),(5,((9,2),3)))),(8,(10,((15,11),6)))),12,1);
+   tree rep.1680000 = (12,(((8,10),(11,(6,15))),(((7,13),(4,14)),(((9,2),3),5))),1);
+   tree rep.1690000 = (((8,((6,(15,11)),10)),(5,((14,((13,4),7)),((9,2),3)))),12,1);
+   tree rep.1700000 = (12,(((4,(5,(13,7))),(((9,2),3),14)),((8,(15,(6,11))),10)),1);
+   tree rep.1710000 = (((((((9,2),3),(4,(7,13))),((8,10),(6,(11,15)))),5),14),12,1);
+   tree rep.1720000 = (((8,((6,(11,15)),10)),(((14,4),(13,7)),((3,(2,9)),5))),12,1);
+   tree rep.1730000 = (((5,((4,14),(13,7))),((2,9),3)),((((11,15),6),(10,8)),12),1);
+   tree rep.1740000 = (12,(((((2,9),3),5),(((13,7),4),14)),((8,((15,6),11)),10)),1);
+   tree rep.1750000 = (12,((((4,(5,14)),(7,13)),((9,2),3)),(10,(8,(11,(15,6))))),1);
+   tree rep.1760000 = ((((5,(14,((7,13),4))),(3,(9,2))),((11,(15,6)),(10,8))),12,1);
+   tree rep.1770000 = ((10,(8,(6,(11,15)))),((((14,4),(13,7)),(5,(3,(2,9)))),12),1);
+   tree rep.1780000 = (12,((((((7,13),4),14),5),((2,9),3)),((10,8),(6,(11,15)))),1);
+   tree rep.1790000 = ((((8,10),(11,(15,6))),((3,(2,9)),(((7,13),(4,14)),5))),12,1);
+   tree rep.1800000 = (((10,8),(11,(6,15))),((((((4,(7,13)),9),3),2),(14,5)),12),1);
+   tree rep.1810000 = (((10,(8,(11,(15,6)))),(((((9,2),3),(7,13)),5),(14,4))),12,1);
+   tree rep.1820000 = (12,((4,((3,(9,2)),(5,((7,13),14)))),((10,8),(11,(6,15)))),1);
+   tree rep.1830000 = (12,((((11,(6,15)),8),10),((14,5),((4,(13,7)),(3,(9,2))))),1);
+   tree rep.1840000 = (12,(((4,(14,((13,7),(3,(9,2))))),5),(((11,(15,6)),10),8)),1);
+   tree rep.1850000 = ((((14,(9,2)),(7,13)),5),(4,(3,(12,((10,8),((15,11),6))))),1);
+   tree rep.1860000 = ((((8,10),(6,(15,11))),((14,5),(((7,13),((9,2),3)),4))),12,1);
+   tree rep.1870000 = (12,(((8,10),(11,(6,15))),(((3,(9,2)),5),((4,(7,13)),14))),1);
+   tree rep.1880000 = ((((((14,((13,7),4)),5),(3,(2,9))),(10,8)),(6,(15,11))),12,1);
+   tree rep.1890000 = ((((10,(11,(6,15))),8),(((7,13),4),(((9,2),3),(14,5)))),12,1);
+   tree rep.1900000 = (12,(((14,5),((3,(2,9)),((13,7),4))),((((6,15),11),8),10)),1);
+   tree rep.1910000 = (((((11,15),6),(10,8)),(5,(14,((7,(13,4)),((2,9),3))))),12,1);
+   tree rep.1920000 = (((((9,2),(5,(7,(4,(14,13))))),3),(10,((6,(15,11)),8))),12,1);
+   tree rep.1930000 = ((((9,2),3),(5,(((13,7),4),14))),(12,(((6,(15,11)),10),8)),1);
+   tree rep.1940000 = (12,((((9,2),3),(5,(((13,7),4),14))),(10,((6,(11,15)),8))),1);
+   tree rep.1950000 = ((((((13,7),(5,4)),((2,9),3)),14),(10,(8,((11,15),6)))),12,1);
+   tree rep.1960000 = (12,(((3,(2,9)),((14,4),((13,7),5))),(((11,(6,15)),10),8)),1);
+   tree rep.1970000 = (12,(((((7,13),(14,5)),4),(3,(2,9))),((10,8),((15,6),11))),1);
+   tree rep.1980000 = ((((6,11),15),(8,10)),(((3,(2,9)),(5,(4,(14,(13,7))))),12),1);
+   tree rep.1990000 = (((8,(10,((15,6),11))),((3,(2,9)),((5,14),((13,7),4)))),12,1);
+   tree rep.2000000 = ((((6,(11,15)),(8,10)),(5,(((((2,9),3),4),14),(7,13)))),12,1);
+   tree rep.2010000 = ((((10,8),(11,(15,6))),((((4,(13,7)),5),14),((2,9),3))),12,1);
+   tree rep.2020000 = (12,(5,(((6,(11,15)),(10,8)),((3,(9,2)),(((13,7),14),4)))),1);
+   tree rep.2030000 = (12,(((((15,11),6),8),10),((((4,(13,7)),14),5),(3,(2,9)))),1);
+   tree rep.2040000 = (8,(((15,11),6),(((((3,(2,9)),((4,14),(13,7))),5),12),10)),1);
+   tree rep.2050000 = (((((15,11),6),(((((7,13),4),14),((2,9),3)),5)),(10,8)),12,1);
+   tree rep.2060000 = ((((8,(11,(15,6))),10),((3,(2,9)),((14,((7,13),4)),5))),12,1);
+   tree rep.2070000 = (12,(((5,((3,(2,9)),14)),(4,(13,7))),((8,((11,15),6)),10)),1);
+   tree rep.2080000 = (12,(((15,6),11),((10,8),((4,(13,7)),((9,2),((14,5),3))))),1);
+   tree rep.2090000 = (12,((((((7,13),4),((9,2),3)),5),14),(((15,11),6),(10,8))),1);
+   tree rep.2100000 = (((9,2),(((((8,10),(6,(15,11))),(((13,7),4),14)),5),3)),12,1);
+   tree rep.2110000 = ((((14,(7,(13,4))),(((2,9),3),5)),((10,8),((11,15),6))),12,1);
+   tree rep.2120000 = (12,((((8,10),(6,(11,15))),(((7,13),4),(5,14))),(3,(9,2))),1);
+   tree rep.2130000 = (12,(((5,(3,(((7,13),4),14))),(9,2)),(((15,(6,11)),8),10)),1);
+   tree rep.2140000 = (12,(((10,8),(6,(11,15))),((7,13),(4,((((2,9),3),5),14)))),1);
+   tree rep.2150000 = (12,((((6,15),11),(10,8)),(((14,(4,(7,13))),(3,(2,9))),5)),1);
+   tree rep.2160000 = ((((((4,14),5),(7,13)),((2,9),3)),((8,10),(11,(15,6)))),12,1);
+   tree rep.2170000 = ((((((13,7),4),14),5),(3,(2,9))),(12,((11,(15,6)),(10,8))),1);
+   tree rep.2180000 = ((12,(((3,(9,2)),((4,(13,7)),14)),5)),((10,(6,(15,11))),8),1);
+   tree rep.2190000 = ((((8,((3,(2,9)),(5,((4,(13,7)),14)))),10),(11,(15,6))),12,1);
+   tree rep.2200000 = (12,(((9,2),3),((((8,10),((15,11),6)),(14,((13,4),7))),5)),1);
+   tree rep.2210000 = ((12,((((15,6),11),8),10)),(((2,9),3),(5,(14,(4,(13,7))))),1);
+   tree rep.2220000 = (((5,(12,((2,9),3))),((4,(13,7)),14)),(((15,11),6),(10,8)),1);
+   tree rep.2230000 = (((5,((4,(14,(13,7))),((9,2),3))),((((15,6),11),8),10)),12,1);
+   tree rep.2240000 = (12,((((11,(6,15)),10),8),((5,(3,(9,2))),(((13,7),4),14))),1);
+   tree rep.2250000 = ((((((3,2),9),(14,((13,7),4))),5),12),((8,10),((6,15),11)),1);
+   tree rep.2260000 = ((((8,10),(11,(15,6))),(((3,(9,2)),4),(5,((14,7),13)))),12,1);
+   tree rep.2270000 = (((8,10),(11,(6,15))),(((((14,4),(13,7)),5),(3,(2,9))),12),1);
+   tree rep.2280000 = (((((6,(11,15)),8),10),(((2,9),((14,5),((13,7),4))),3)),12,1);
+   tree rep.2290000 = (12,(((14,(4,(7,13))),((9,2),3)),(((10,8),(11,(6,15))),5)),1);
+   tree rep.2300000 = (12,((((4,(14,(13,7))),(3,(2,9))),5),((11,(15,6)),(10,8))),1);
+   tree rep.2310000 = (12,(((4,((13,7),(5,14))),((2,9),3)),((6,(11,15)),(10,8))),1);
+   tree rep.2320000 = ((((4,(7,13)),(((3,(9,2)),((10,8),(11,(15,6)))),14)),5),12,1);
+   tree rep.2330000 = (12,((4,(13,7)),(((5,((9,2),3)),14),(((6,(11,15)),8),10))),1);
+   tree rep.2340000 = (12,((((3,(9,2)),5),(14,((7,13),4))),((8,10),(15,(6,11)))),1);
+   tree rep.2350000 = (12,(((4,((13,7),14)),(5,((2,9),3))),((10,8),((11,6),15))),1);
+   tree rep.2360000 = (((((6,15),11),(10,8)),(5,(14,((4,(13,7)),((2,9),3))))),12,1);
+   tree rep.2370000 = (12,(((13,7),(5,((14,4),((10,8),((15,11),6))))),(3,(9,2))),1);
+   tree rep.2380000 = (((6,(15,11)),(8,10)),(12,((5,(14,(7,(4,13)))),(3,(2,9)))),1);
+   tree rep.2390000 = ((((10,8),((6,15),11)),(((14,5),((7,13),4)),(3,(2,9)))),12,1);
+   tree rep.2400000 = ((((10,8),((11,15),6)),((5,14),((4,(7,13)),((9,2),3)))),12,1);
+   tree rep.2410000 = (((8,((11,(15,6)),10)),12),(((5,14),((9,2),3)),((7,13),4)),1);
+   tree rep.2420000 = (12,((((13,7),(4,14)),((((15,6),11),(8,10)),5)),(3,(9,2))),1);
+   tree rep.2430000 = (((((5,14),(4,(13,7))),((9,2),3)),(8,(10,((11,15),6)))),12,1);
+   tree rep.2440000 = ((((13,((14,7),4)),(((9,2),3),5)),12),((10,8),(11,(6,15))),1);
+   tree rep.2450000 = ((((((6,15),11),8),10),((3,(9,2)),(((5,14),4),(7,13)))),12,1);
+   tree rep.2460000 = ((((5,(((7,14),4),13)),((9,2),3)),((10,(15,(11,6))),8)),12,1);
+   tree rep.2470000 = ((((5,14),(7,13)),(((9,2),3),4)),((((6,(15,11)),8),10),12),1);
+   tree rep.2480000 = (((14,((3,(9,2)),(5,(4,(7,13))))),(((15,11),6),(8,10))),12,1);
+   tree rep.2490000 = (12,((((8,((15,(11,6)),10)),(((7,13),4),14)),5),((9,2),3)),1);
+   tree rep.2500000 = (12,(((((9,2),3),5),(14,((13,7),4))),((15,(11,6)),(10,8))),1);
+   tree rep.2510000 = ((6,(15,11)),(8,(10,(12,((5,(14,(4,(7,13)))),(3,(2,9)))))),1);
+   tree rep.2520000 = ((((10,((11,15),6)),8),(((2,9),3),(5,(14,(4,(7,13)))))),12,1);
+   tree rep.2530000 = (14,(((4,(12,(3,(9,2)))),((13,7),5)),((8,10),((11,6),15))),1);
+   tree rep.2540000 = ((((8,(11,(6,15))),10),((4,(13,7)),((3,(2,9)),(14,5)))),12,1);
+   tree rep.2550000 = ((((5,14),(((13,7),4),((9,2),3))),(((15,6),11),(10,8))),12,1);
+   tree rep.2560000 = (12,(((11,15),6),(8,(10,((((7,13),5),(14,4)),((9,2),3))))),1);
+   tree rep.2570000 = (((14,(((13,7),4),5)),((9,2),3)),(12,((11,(6,15)),(10,8))),1);
+   tree rep.2580000 = ((((8,10),((6,15),11)),(3,((9,2),(((14,4),(7,13)),5)))),12,1);
+   tree rep.2590000 = (12,(((10,(11,(15,6))),8),((14,((3,(9,2)),5)),((13,7),4))),1);
+   tree rep.2600000 = ((((10,8),(6,(15,11))),(5,(((13,7),(14,4)),(3,(9,2))))),12,1);
+   tree rep.2610000 = (((8,(((14,(4,(7,13))),(5,(3,(9,2)))),10)),(6,(11,15))),12,1);
+   tree rep.2620000 = (12,(((10,8),(11,(6,15))),((5,(7,13)),(((2,9),3),(4,14)))),1);
+   tree rep.2630000 = ((((2,9),3),((5,14),(4,(13,7)))),((10,(8,((11,15),6))),12),1);
+   tree rep.2640000 = (((10,8),((11,15),6)),(((((7,13),14),4),(((9,2),3),5)),12),1);
+   tree rep.2650000 = (12,(((5,((13,7),4)),(((2,9),3),14)),((8,(11,(6,15))),10)),1);
+   tree rep.2660000 = (12,(((14,((7,13),4)),(5,(3,(2,9)))),(8,((15,(6,11)),10))),1);
+   tree rep.2670000 = ((((8,10),((6,15),11)),(((4,(7,13)),((3,(2,9)),5)),14)),12,1);
+   tree rep.2680000 = (((8,10),((15,6),11)),((((((2,9),3),5),14),(4,(7,13))),12),1);
+   tree rep.2690000 = ((((((14,4),(7,13)),5),(3,(9,2))),(8,((6,(15,11)),10))),12,1);
+   tree rep.2700000 = (((5,(((7,13),4),14)),(3,(9,2))),(12,(((11,(15,6)),10),8)),1);
+   tree rep.2710000 = ((((6,(11,15)),8),10),(((14,5),(((9,2),3),((13,7),4))),12),1);
+   tree rep.2720000 = (((((10,8),(11,(15,6))),((2,9),3)),(4,(5,((7,13),14)))),12,1);
+   tree rep.2730000 = (((10,((15,6),11)),8),(12,(5,((((4,14),7),13),(3,(2,9))))),1);
+   tree rep.2740000 = (12,((((11,15),6),(10,8)),((5,4),((13,7),(14,(3,(2,9)))))),1);
+   tree rep.2750000 = ((((8,10),((15,11),6)),12),(((2,9),3),(((7,13),4),(5,14))),1);
+   tree rep.2760000 = (((((5,14),(3,(2,9))),((13,7),4)),((8,(11,(15,6))),10)),12,1);
+   tree rep.2770000 = (12,((4,((5,(14,((9,2),3))),(7,13))),((8,(11,(6,15))),10)),1);
+   tree rep.2780000 = (12,((3,(9,2)),((7,(4,13)),(((8,((15,6),11)),10),(5,14)))),1);
+   tree rep.2790000 = (12,((10,((11,(15,6)),8)),((4,((14,5),(7,13))),(3,(9,2)))),1);
+   tree rep.2800000 = (((((11,(15,6)),8),10),((4,((14,5),(13,7))),(3,(2,9)))),12,1);
+   tree rep.2810000 = (((12,((9,2),3)),(5,((11,(15,6)),(10,8)))),((4,14),(7,13)),1);
+   tree rep.2820000 = ((((6,(11,15)),(10,8)),((5,((2,9),3)),((13,7),(4,14)))),12,1);
+   tree rep.2830000 = ((((10,8),(11,(15,6))),((4,((13,7),((9,2),3))),(14,5))),12,1);
+   tree rep.2840000 = (((5,((((2,9),3),14),(4,(13,7)))),(10,(8,(6,(15,11))))),12,1);
+   tree rep.2850000 = ((((((13,7),(3,(2,9))),(14,5)),4),(((11,15),6),(10,8))),12,1);
+   tree rep.2860000 = (12,((5,(((14,(13,7)),4),(3,(2,9)))),((6,(15,11)),(10,8))),1);
+   tree rep.2870000 = (((5,((((13,7),4),((2,9),3)),14)),((10,((15,6),11)),8)),12,1);
+   tree rep.2880000 = ((((10,8),((11,15),6)),((14,(((9,2),3),(4,5))),(7,13))),12,1);
+   tree rep.2890000 = (12,((((3,(2,9)),(14,((13,7),4))),5),((11,(6,15)),(8,10))),1);
+   tree rep.2900000 = ((((((7,13),4),(5,14)),(3,(2,9))),((((6,15),11),10),8)),12,1);
+   tree rep.2910000 = (12,(5,(((7,13),4),((14,((9,2),3)),((11,(6,15)),(10,8))))),1);
+   tree rep.2920000 = (12,(((((3,(9,2)),(13,7)),4),(5,14)),((8,(11,(6,15))),10)),1);
+   tree rep.2930000 = ((((10,8),(11,(6,15))),((((4,(13,7)),14),5),((2,9),3))),12,1);
+   tree rep.2940000 = (((((2,3),9),(((5,14),(13,7)),4)),(((6,(11,15)),10),8)),12,1);
+   tree rep.2950000 = ((((5,((7,13),(((2,9),3),4))),14),(((11,(6,15)),10),8)),12,1);
+   tree rep.2960000 = ((((10,((11,15),6)),8),(((9,2),3),(((4,(13,7)),14),5))),12,1);
+   tree rep.2970000 = (12,(((3,(9,2)),((5,14),(4,(13,7)))),(8,(10,((15,11),6)))),1);
+   tree rep.2980000 = (12,((((11,(6,15)),10),8),(5,(14,((3,(2,9)),((7,13),4))))),1);
+   tree rep.2990000 = (((5,14),((((2,9),3),4),(7,13))),(((11,(6,15)),(8,10)),12),1);
+   tree rep.3000000 = ((((14,5),(3,(9,2))),(((10,8),(6,(15,11))),(4,(7,13)))),12,1);
+   tree rep.3010000 = (12,((((3,(2,9)),5),((13,7),(14,4))),((8,10),((15,11),6))),1);
+   tree rep.3020000 = ((((6,11),15),(10,8)),(((3,(2,9)),12),(5,((4,(13,7)),14))),1);
+   tree rep.3030000 = (12,(((8,10),(6,(11,15))),((5,((2,9),3)),(((7,13),4),14))),1);
+   tree rep.3040000 = (((((4,(7,13)),14),(5,(3,(9,2)))),((10,8),(15,(6,11)))),12,1);
+   tree rep.3050000 = ((((13,7),4),(5,((((11,15),6),(8,10)),(((2,9),3),14)))),12,1);
+   tree rep.3060000 = (12,(((10,((11,15),6)),8),(4,(((7,13),14),(5,(3,(2,9)))))),1);
+   tree rep.3070000 = ((((6,(15,11)),(8,10)),(((5,(14,4)),(7,13)),((2,9),3))),12,1);
+   tree rep.3080000 = (12,((14,(((5,7),(13,4)),(3,(9,2)))),((10,(6,(15,11))),8)),1);
+   tree rep.3090000 = ((((4,(7,((14,(3,(9,2))),13))),5),(10,((6,(11,15)),8))),12,1);
+   tree rep.3100000 = ((((((7,13),4),(5,14)),((2,9),3)),((((15,6),11),10),8)),12,1);
+   tree rep.3110000 = (((((7,13),((((15,11),6),(10,8)),4)),14),(((9,2),3),5)),12,1);
+   tree rep.3120000 = (((8,(10,(15,(11,6)))),((((2,9),3),5),(4,(14,(7,13))))),12,1);
+   tree rep.3130000 = (((((((13,7),14),4),(3,(9,2))),5),(((11,(6,15)),10),8)),12,1);
+   tree rep.3140000 = (((((9,2),3),((7,13),4)),((((15,11),6),(8,10)),12)),(5,14),1);
+   tree rep.3150000 = ((((14,(7,13)),4),(3,(9,2))),((8,(10,(11,(15,6)))),(5,12)),1);
+   tree rep.3160000 = ((14,(5,(((3,(9,2)),(7,(4,13))),((10,8),((11,15),6))))),12,1);
+   tree rep.3170000 = (12,(((8,10),(6,(11,15))),((5,(14,((13,7),4))),((9,2),3))),1);
+   tree rep.3180000 = ((((9,2),3),(((4,14),(7,13)),5)),(((11,(6,15)),(10,8)),12),1);
+   tree rep.3190000 = (12,((((9,2),3),((4,14),((13,7),5))),((6,(11,15)),(10,8))),1);
+   tree rep.3200000 = ((((3,(9,2)),(((6,15),11),(8,10))),((4,(7,13)),(14,5))),12,1);
+   tree rep.3210000 = (12,((((3,(9,2)),(((7,13),14),4)),5),((8,10),(11,(6,15)))),1);
+   tree rep.3220000 = (((10,8),((11,15),6)),((((3,(9,2)),((4,(13,7)),14)),5),12),1);
+   tree rep.3230000 = (((((15,6),11),(10,8)),(((2,9),(((13,7),4),14)),(5,3))),12,1);
+   tree rep.3240000 = (((5,(8,(10,((6,15),11)))),((3,(9,2)),(14,((13,7),4)))),12,1);
+   tree rep.3250000 = ((12,(((14,((13,7),4)),5),(3,(9,2)))),((10,8),(11,(15,6))),1);
+   tree rep.3260000 = ((((((((9,2),3),5),(4,(13,7))),14),(11,(15,6))),(8,10)),12,1);
+   tree rep.3270000 = (12,((((4,(13,7)),((9,2),3)),(5,14)),((11,(6,15)),(8,10))),1);
+   tree rep.3280000 = (((8,10),((11,15),6)),(((3,(9,2)),((5,14),((13,7),4))),12),1);
+   tree rep.3290000 = ((((14,((13,7),4)),5),((2,9),3)),(12,((11,(6,15)),(10,8))),1);
+   tree rep.3300000 = (((((9,2),3),(5,((4,(13,7)),14))),((6,(11,15)),(8,10))),12,1);
+   tree rep.3310000 = (12,((10,8),(((((4,5),14),(7,13)),(3,(9,2))),((15,11),6))),1);
+   tree rep.3320000 = (((14,((13,7),4)),((((10,8),(6,(11,15))),(3,(9,2))),5)),12,1);
+   tree rep.3330000 = (12,(((((5,((((13,7),4),14),(9,2))),3),10),8),((15,11),6)),1);
+   tree rep.3340000 = ((((14,5),((7,13),4)),(3,((9,2),12))),(((6,15),11),(10,8)),1);
+   tree rep.3350000 = (12,((((9,2),3),((5,14),((13,7),4))),(((6,(15,11)),10),8)),1);
+   tree rep.3360000 = (12,((((((6,15),11),((7,13),(4,14))),(3,(2,9))),5),(10,8)),1);
+   tree rep.3370000 = (((3,(9,2)),(14,(((13,7),5),(4,(((15,11),6),(8,10)))))),12,1);
+   tree rep.3380000 = ((((14,5),((3,(9,2)),((7,13),4))),(10,(8,((6,15),11)))),12,1);
+   tree rep.3390000 = (12,(((10,((15,11),6)),8),((3,((9,2),5)),(14,(4,(13,7))))),1);
+   tree rep.3400000 = (((((4,(13,7)),5),14),((10,(((11,15),6),8)),((2,9),3))),12,1);
+   tree rep.3410000 = (((5,(((2,9),3),(((13,7),4),14))),((11,(6,15)),(8,10))),12,1);
+   tree rep.3420000 = (12,(((14,(5,((13,7),4))),((9,2),3)),(((11,(15,6)),8),10)),1);
+   tree rep.3430000 = (12,((((6,(15,11)),8),10),(((3,(9,2)),5),((4,14),(13,7)))),1);
+   tree rep.3440000 = ((((10,8),(11,(15,6))),(((7,13),4),(14,((3,(9,2)),5)))),12,1);
+   tree rep.3450000 = (12,(((5,(3,(2,9))),(((4,13),7),14)),((8,10),((15,11),6))),1);
+   tree rep.3460000 = ((((6,(11,15)),(8,10)),(((((13,4),7),14),(3,(2,9))),5)),12,1);
+   tree rep.3470000 = ((((10,(6,(11,15))),8),((((13,7),(14,4)),((2,9),3)),5)),12,1);
+   tree rep.3480000 = (((3,(2,9)),12),(((4,((13,7),14)),5),((10,(6,(11,15))),8)),1);
+   tree rep.3490000 = (12,((((9,2),3),(5,(4,(14,(7,13))))),(10,(8,((11,15),6)))),1);
+   tree rep.3500000 = (12,(((8,10),((6,15),11)),((3,(9,2)),((5,(4,(7,13))),14))),1);
+   tree rep.3510000 = (12,((5,(3,(2,9))),((4,(14,(7,13))),(8,(10,((11,15),6))))),1);
+   tree rep.3520000 = (((5,((3,(9,2)),(14,((7,4),13)))),(10,(((11,15),6),8))),12,1);
+   tree rep.3530000 = ((((8,10),((15,11),6)),12),((5,(4,((7,13),14))),(3,(9,2))),1);
+   tree rep.3540000 = (12,(((((2,9),3),5),(14,((7,13),4))),(10,(8,(11,(15,6))))),1);
+   tree rep.3550000 = (((((5,14),(4,(13,7))),((9,2),3)),((8,((6,15),11)),10)),12,1);
+   tree rep.3560000 = ((((10,(11,(15,6))),8),(4,(((13,7),(3,(2,9))),(14,5)))),12,1);
+   tree rep.3570000 = (((3,(2,9)),(5,(14,(13,(4,7))))),((((15,(6,11)),8),10),12),1);
+   tree rep.3580000 = (((((9,2),3),(((4,(7,13)),((8,((15,11),6)),10)),5)),14),12,1);
+   tree rep.3590000 = (12,(((5,((4,(13,7)),14)),((2,9),3)),(10,(((6,15),11),8))),1);
+   tree rep.3600000 = (12,((((14,5),(4,(13,7))),((2,9),3)),((((6,15),11),8),10)),1);
+   tree rep.3610000 = ((((((11,15),6),10),8),((5,(3,(2,9))),((4,(13,7)),14))),12,1);
+   tree rep.3620000 = (12,(((10,8),(6,(11,15))),(((7,13),14),(((9,2),3),(5,4)))),1);
+   tree rep.3630000 = (12,(((((13,7),(4,14)),5),(8,(10,((6,15),11)))),(3,(2,9))),1);
+   tree rep.3640000 = ((((6,(15,11)),(10,8)),(4,(((13,7),(5,14)),(3,(2,9))))),12,1);
+   tree rep.3650000 = (12,((14,(((10,8),(11,(15,6))),((7,13),5))),((3,(2,9)),4)),1);
+   tree rep.3660000 = ((((((6,15),11),10),8),((5,(((13,7),4),14)),(3,(9,2)))),12,1);
+   tree rep.3670000 = ((((15,6),11),(10,(8,(5,((((7,13),14),4),(3,(9,2))))))),12,1);
+   tree rep.3680000 = ((8,10),((5,((((9,2),3),12),(14,((13,7),4)))),((15,6),11)),1);
+   tree rep.3690000 = (((5,((((13,7),4),(3,(9,2))),14)),((10,8),((6,15),11))),12,1);
+   tree rep.3700000 = (((((3,(9,2)),((5,14),(7,13))),4),((10,8),(6,(15,11)))),12,1);
+   tree rep.3710000 = (12,((((11,(6,15)),8),10),(5,((((7,13),4),14),((9,2),3)))),1);
+   tree rep.3720000 = ((((13,4),((7,((2,9),3)),(14,5))),((10,8),(11,(15,6)))),12,1);
+   tree rep.3730000 = (12,((((15,11),6),(10,8)),((14,(5,(13,(7,4)))),(3,(2,9)))),1);
+   tree rep.3740000 = (((5,((14,((13,7),4)),(3,(9,2)))),((10,8),(11,(6,15)))),12,1);
+   tree rep.3750000 = (12,((((13,7),(5,((9,2),3))),(14,4)),((11,(6,15)),(10,8))),1);
+   tree rep.3760000 = (((((4,(7,13)),14),((3,(9,2)),5)),((8,10),(11,(6,15)))),12,1);
+   tree rep.3770000 = (13,(7,((3,(2,9)),(14,(((12,((10,8),((15,6),11))),4),5)))),1);
+   tree rep.3780000 = (((((2,9),3),(13,(4,7))),(14,5)),(12,(((11,(15,6)),10),8)),1);
+   tree rep.3790000 = (12,(((((4,(13,7)),14),(5,(3,(2,9)))),(11,(15,6))),(10,8)),1);
+   tree rep.3800000 = ((((3,(2,9)),(((4,13),7),(5,14))),12),(10,((6,(11,15)),8)),1);
+   tree rep.3810000 = (12,((8,(10,(6,(11,15)))),(((2,9),3),((4,((13,7),14)),5))),1);
+   tree rep.3820000 = (((5,(((14,(13,7)),4),((9,2),3))),((8,10),(11,(15,6)))),12,1);
+   tree rep.3830000 = ((((10,8),((6,15),11)),((4,(13,7)),(((2,9),3),(14,5)))),12,1);
+   tree rep.3840000 = (12,(((((9,2),(14,5)),(((11,(15,6)),10),8)),(4,(7,13))),3),1);
+   tree rep.3850000 = (12,(((14,5),(3,((9,2),(4,(7,13))))),(((15,11),6),(10,8))),1);
+   tree rep.3860000 = (12,(((10,8),((15,11),6)),(((14,(4,(7,13))),5),((2,9),3))),1);
+   tree rep.3870000 = (12,(((14,((13,7),4)),(5,((2,9),3))),(((11,(15,6)),8),10)),1);
+   tree rep.3880000 = ((((((8,10),(11,(15,6))),5),(14,(4,(13,7)))),((2,9),3)),12,1);
+   tree rep.3890000 = (((((11,(15,6)),(8,10)),((9,2),3)),((14,4),((13,7),5))),12,1);
+   tree rep.3900000 = (((((6,11),15),(10,8)),((5,((4,(13,7)),14)),(3,(9,2)))),12,1);
+   tree rep.3910000 = (((5,(((8,10),(11,(15,6))),(((2,9),3),((7,4),13)))),14),12,1);
+   tree rep.3920000 = (12,(((((15,6),11),10),8),((((7,13),4),(5,14)),((9,2),3))),1);
+   tree rep.3930000 = (12,((9,2),((((10,8),(11,(15,6))),(3,5)),((14,(13,7)),4))),1);
+   tree rep.3940000 = (12,(((3,((2,9),5)),(4,((7,14),13))),(((11,(15,6)),8),10)),1);
+   tree rep.3950000 = (12,(((10,(11,(15,6))),8),(((13,(7,(14,4))),(3,(2,9))),5)),1);
+   tree rep.3960000 = (12,((((((13,7),4),(5,14)),3),(9,2)),((8,10),((11,15),6))),1);
+   tree rep.3970000 = ((((14,(4,(13,7))),((3,(9,2)),5)),((((6,15),11),8),10)),12,1);
+   tree rep.3980000 = (((((14,5),((7,13),4)),(3,(2,9))),((10,8),((11,15),6))),12,1);
+   tree rep.3990000 = (((5,(14,((13,7),4))),(((2,9),3),12)),(10,(8,(11,(6,15)))),1);
+   tree rep.4000000 = (12,((4,(((7,13),((2,9),3)),(14,5))),(((11,(6,15)),10),8)),1);
+   tree rep.4010000 = ((12,(14,(5,((3,(2,9)),((7,13),4))))),(((15,11),6),(8,10)),1);
+   tree rep.4020000 = (12,(((14,((5,(3,(9,2))),(7,13))),4),(((6,(15,11)),8),10)),1);
+   tree rep.4030000 = (12,((((10,8),(6,(15,11))),5),(((9,2),3),(14,(4,(7,13))))),1);
+   tree rep.4040000 = (((((14,5),((9,2),3)),((13,7),4)),12),((10,8),(6,(11,15))),1);
+   tree rep.4050000 = (12,(((14,(((11,15),6),(10,8))),(7,13)),((5,(3,(2,9))),4)),1);
+   tree rep.4060000 = ((((4,(((14,13),7),5)),(3,(9,2))),(((11,(15,6)),8),10)),12,1);
+   tree rep.4070000 = (12,(((5,((7,(4,13)),14)),((9,2),3)),((6,(11,15)),(8,10))),1);
+   tree rep.4080000 = (12,((((((15,11),6),(8,10)),((3,(9,2)),((13,7),4))),5),14),1);
+   tree rep.4090000 = ((((((13,7),5),4),((3,14),(9,2))),(8,(10,(11,(6,15))))),12,1);
+   tree rep.4100000 = (12,(((((4,((3,(9,2)),5)),((7,13),14)),10),8),((11,15),6)),1);
+   tree rep.4110000 = (((((15,11),6),10),8),(((5,(14,(4,(7,13)))),(3,(9,2))),12),1);
+   tree rep.4120000 = (12,((((11,(6,15)),10),8),((((9,2),3),(14,((7,13),4))),5)),1);
+   tree rep.4130000 = (12,((((2,9),3),(8,(((6,15),11),10))),(5,((4,14),(13,7)))),1);
+   tree rep.4140000 = ((((13,7),4),((12,(3,(2,9))),(5,14))),(10,((6,(15,11)),8)),1);
+   tree rep.4150000 = ((((14,((13,7),4)),((9,2),3)),5),(8,((6,(15,11)),(10,12))),1);
+   tree rep.4160000 = (((13,7),4),(((14,5),((2,9),(12,3))),((11,(15,6)),(10,8))),1);
+   tree rep.4170000 = ((5,((3,(2,9)),((14,(13,7)),4))),(12,((6,(15,11)),(10,8))),1);
+   tree rep.4180000 = ((((2,9),3),(((4,(13,7)),14),((10,(8,((15,11),6))),5))),12,1);
+   tree rep.4190000 = ((((14,5),((7,13),4)),(3,(9,2))),((((15,6),11),(8,10)),12),1);
+   tree rep.4200000 = (12,((((8,10),(6,(11,15))),(3,(2,9))),((((13,7),14),4),5)),1);
+   tree rep.4210000 = (12,((((10,8),(6,(15,11))),(14,(4,((7,13),(3,(2,9)))))),5),1);
+   tree rep.4220000 = (((8,(((15,11),6),10)),((5,((7,13),4)),(14,((9,2),3)))),12,1);
+   tree rep.4230000 = (12,(((5,((2,9),3)),(14,((13,7),4))),((8,(11,(15,6))),10)),1);
+   tree rep.4240000 = (((((4,(7,13)),((9,2),3)),(14,5)),((10,8),(11,(6,15)))),12,1);
+   tree rep.4250000 = (12,((((3,(9,2)),5),(14,(4,(7,13)))),(((15,6),11),(8,10))),1);
+   tree rep.4260000 = (((8,(6,(11,15))),10),(12,(4,((7,13),((5,14),(3,(2,9)))))),1);
+   tree rep.4270000 = (12,((((3,(9,2)),5),((13,7),(14,4))),(((15,6),11),(10,8))),1);
+   tree rep.4280000 = ((((((15,6),11),10),8),(((7,13),((2,9),3)),(4,(14,5)))),12,1);
+   tree rep.4290000 = ((((((2,9),3),14),(5,((13,7),4))),(8,((6,(15,11)),10))),12,1);
+   tree rep.4300000 = (12,(((8,10),(11,(6,15))),(((((2,9),(3,(13,7))),5),14),4)),1);
+   tree rep.4310000 = (12,(((5,((4,(7,13)),14)),(3,(9,2))),((10,(11,(15,6))),8)),1);
+   tree rep.4320000 = (((8,(10,(6,(11,15)))),((((9,2),3),(4,(5,(7,13)))),14)),12,1);
+   tree rep.4330000 = ((((8,10),((6,15),11)),(((5,(3,(9,2))),((4,7),13)),14)),12,1);
+   tree rep.4340000 = (12,(((3,(2,9)),(((13,7),5),(4,14))),(8,(10,(11,(15,6))))),1);
+   tree rep.4350000 = ((((5,(3,(2,9))),(14,(4,(13,7)))),12),((8,((6,15),11)),10),1);
+   tree rep.4360000 = ((((10,8),((15,6),11)),((((14,4),(13,7)),5),(3,(2,9)))),12,1);
+   tree rep.4370000 = (12,(((5,(3,(2,9))),(4,((13,7),14))),(((15,6),11),(8,10))),1);
+   tree rep.4380000 = (((((13,(7,4)),14),(((2,9),3),5)),12),((((15,6),11),10),8),1);
+   tree rep.4390000 = (12,((((15,11),6),(10,8)),((((9,2),3),((4,14),(7,13))),5)),1);
+   tree rep.4400000 = (12,(((4,(14,5)),(((9,2),3),(7,13))),(10,(8,(6,(15,11))))),1);
+   tree rep.4410000 = ((((((5,14),(13,7)),((9,2),3)),4),(8,(10,(11,(15,6))))),12,1);
+   tree rep.4420000 = (12,(((8,10),(6,(11,15))),((4,((7,13),14)),(5,(3,(2,9))))),1);
+   tree rep.4430000 = (((((15,6),11),(10,8)),(((5,((9,2),3)),(4,(7,13))),14)),12,1);
+   tree rep.4440000 = (((((2,9),3),(5,(14,(13,(7,4))))),(10,(8,(11,(15,6))))),12,1);
+   tree rep.4450000 = (((((6,(11,15)),10),8),(((3,(2,9)),((5,4),14)),(13,7))),12,1);
+   tree rep.4460000 = ((12,((8,10),((11,6),15))),((5,(14,(4,(7,13)))),((9,2),3)),1);
+   tree rep.4470000 = (12,((((11,15),6),(10,8)),(((3,(2,9)),((4,14),(7,13))),5)),1);
+   tree rep.4480000 = ((((((10,((6,15),11)),8),((13,7),4)),5),((3,(9,2)),14)),12,1);
+   tree rep.4490000 = (((6,(11,15)),(8,10)),(12,((4,(13,7)),((14,5),((9,2),3)))),1);
+   tree rep.4500000 = ((((((15,11),6),10),8),(((4,(7,13)),14),(((2,9),3),5))),12,1);
+   tree rep.4510000 = (((3,(2,9)),((5,14),((7,13),4))),(12,((8,((11,15),6)),10)),1);
+   tree rep.4520000 = (12,((10,((11,(6,15)),8)),(((14,(13,7)),4),((3,(9,2)),5))),1);
+   tree rep.4530000 = (12,(((8,((6,15),11)),10),((4,(5,(14,(3,(2,9))))),(7,13))),1);
+   tree rep.4540000 = ((((8,10),((15,6),11)),((14,((7,13),4)),(5,(3,(2,9))))),12,1);
+   tree rep.4550000 = (12,((((14,(4,(13,7))),(3,(9,2))),5),((((11,6),15),10),8)),1);
+   tree rep.4560000 = (12,((((6,15),11),(10,8)),((((2,9),3),((7,13),4)),(5,14))),1);
+   tree rep.4570000 = (12,((((7,13),((2,9),3)),((4,14),5)),(((15,11),6),(10,8))),1);
+   tree rep.4580000 = ((12,(((4,((9,2),3)),5),(14,(7,13)))),((8,10),((11,15),6)),1);
+   tree rep.4590000 = (((5,((14,(4,(7,13))),(3,(9,2)))),12),((10,8),(11,(6,15))),1);
+   tree rep.4600000 = (12,((8,10),(((14,5),(4,(13,7))),((2,9),((11,(6,15)),3)))),1);
+   tree rep.4610000 = (12,((((4,14),(13,7)),(5,((9,2),3))),((8,10),(6,(11,15)))),1);
+   tree rep.4620000 = (((((4,(7,13)),(14,5)),((9,2),3)),(((11,(15,6)),10),8)),12,1);
+   tree rep.4630000 = (12,((((11,15),6),(10,8)),((((4,(13,7)),14),5),((9,2),3))),1);
+   tree rep.4640000 = (12,((((3,(9,2)),5),((14,4),(7,13))),(((15,11),6),(10,8))),1);
+   tree rep.4650000 = (12,(((2,9),3),((13,7),((14,4),(((10,8),(11,(15,6))),5)))),1);
+   tree rep.4660000 = ((((14,(4,(7,13))),((5,(9,2)),3)),12),((10,8),((15,6),11)),1);
+   tree rep.4670000 = (12,((((3,9),2),(5,(((7,13),4),14))),((10,8),((6,15),11))),1);
+   tree rep.4680000 = ((7,(4,13)),(14,((((10,(11,(6,15))),8),12),(5,((2,9),3)))),1);
+   tree rep.4690000 = (12,(((15,11),6),((((3,(9,2)),(5,((4,(13,7)),14))),10),8)),1);
+   tree rep.4700000 = (12,((10,(((11,15),6),8)),(5,((3,(2,9)),((4,(13,7)),14)))),1);
+   tree rep.4710000 = (12,((4,(7,13)),(((((10,(11,(6,15))),8),14),5),((9,2),3))),1);
+   tree rep.4720000 = (((((3,(2,9)),5),(14,(4,(13,7)))),(8,((15,(11,6)),10))),12,1);
+   tree rep.4730000 = (12,(((((3,(9,2)),(14,(7,13))),5),(10,(8,(6,(15,11))))),4),1);
+   tree rep.4740000 = ((((4,((7,13),14)),5),(((9,2),3),12)),(8,((11,(6,15)),10)),1);
+   tree rep.4750000 = (((((15,11),6),(10,8)),((5,((((9,2),3),14),(13,7))),4)),12,1);
+   tree rep.4760000 = ((((8,(6,(15,11))),10),((14,(5,(3,(9,2)))),(4,(13,7)))),12,1);
+   tree rep.4770000 = (12,((8,((6,(15,11)),10)),((((13,7),14),4),(5,(3,(2,9))))),1);
+   tree rep.4780000 = ((5,(((4,(13,7)),((((15,6),11),(8,10)),12)),14)),(3,(9,2)),1);
+   tree rep.4790000 = (((((4,14),(13,7)),(5,(3,(2,9)))),((8,10),(11,(6,15)))),12,1);
+   tree rep.4800000 = (12,((5,(((((6,(11,15)),10),8),(3,(9,2))),(4,(13,7)))),14),1);
+   tree rep.4810000 = (((10,((6,(11,15)),8)),(((5,4),(((2,9),(7,13)),3)),14)),12,1);
+   tree rep.4820000 = ((((6,11),15),(10,8)),((((4,(14,(13,7))),5),((2,9),3)),12),1);
+   tree rep.4830000 = ((((14,((13,7),((3,(9,2)),5))),4),12),(10,((6,(11,15)),8)),1);
+   tree rep.4840000 = ((((((4,(7,13)),14),(3,(9,2))),5),12),(10,(((6,15),11),8)),1);
+   tree rep.4850000 = (12,(((6,(11,15)),(10,8)),(((2,9),3),(5,((4,(13,7)),14)))),1);
+   tree rep.4860000 = (5,((((9,2),3),(14,(4,(13,7)))),(12,((((6,15),11),10),8))),1);
+   tree rep.4870000 = ((((10,8),(11,(6,15))),(5,(((2,9),3),(4,((7,13),14))))),12,1);
+   tree rep.4880000 = (12,((((3,(2,9)),(((7,13),4),5)),14),((10,(11,(6,15))),8)),1);
+   tree rep.4890000 = (12,(((8,10),((11,15),6)),((4,((13,14),7)),(((2,9),3),5))),1);
+   tree rep.4900000 = ((((5,((4,(13,7)),14)),((9,2),3)),((8,10),((15,11),6))),12,1);
+   tree rep.4910000 = (12,(((2,9),(3,(((4,14),5),(13,7)))),((10,((15,6),11)),8)),1);
+   tree rep.4920000 = (12,(((10,((11,15),6)),8),((((9,2),(13,7)),((5,14),4)),3)),1);
+   tree rep.4930000 = (12,(((((15,11),6),10),8),(((4,((9,2),3)),((7,13),14)),5)),1);
+   tree rep.4940000 = (((((4,5),((9,2),3)),((13,7),14)),((8,10),(6,(15,11)))),12,1);
+   tree rep.4950000 = ((((3,((9,2),(14,5))),(4,(7,13))),(((11,15),6),(10,8))),12,1);
+   tree rep.4960000 = ((8,(10,((6,15),11))),(12,(4,((5,(14,(7,13))),(3,(9,2))))),1);
+   tree rep.4970000 = (12,(5,((((4,(13,7)),14),((9,2),3)),(((15,6),11),(10,8)))),1);
+   tree rep.4980000 = (12,((((6,(15,11)),8),10),((((13,7),(4,14)),5),((9,2),3))),1);
+   tree rep.4990000 = ((((4,((9,2),3)),((7,13),(5,14))),(8,((15,(11,6)),10))),12,1);
+   tree rep.5000000 = (12,(((10,8),((11,6),15)),(((7,13),4),(((9,2),3),(14,5)))),1);
+   tree rep.5010000 = ((((3,(9,2)),(4,((7,13),(5,14)))),((10,8),(11,(15,6)))),12,1);
+   tree rep.5020000 = (12,(((5,((3,(2,9)),((7,13),4))),14),((8,((6,15),11)),10)),1);
+   tree rep.5030000 = (((((4,(7,13)),(5,14)),((2,9),3)),(8,((11,(6,15)),10))),12,1);
+   tree rep.5040000 = (((8,10),(11,(6,15))),(12,((((7,13),(14,4)),(3,(9,2))),5)),1);
+   tree rep.5050000 = (12,(((11,(15,6)),(10,8)),((7,13),(4,((14,5),(3,(9,2)))))),1);
+   tree rep.5060000 = (12,((((5,14),((4,(13,7)),(2,9))),3),(((11,(15,6)),8),10)),1);
+   tree rep.5070000 = (((5,((7,13),((14,4),((9,2),3)))),(10,(8,(6,(15,11))))),12,1);
+   tree rep.5080000 = (12,(((14,(((7,13),5),4)),((2,9),3)),((10,8),((15,11),6))),1);
+   tree rep.5090000 = (12,(((8,(6,(15,11))),10),((3,(2,9)),((13,((7,14),4)),5))),1);
+   tree rep.5100000 = (((8,(((15,11),6),10)),(5,(((2,9),3),(14,(4,(7,13)))))),12,1);
+   tree rep.5110000 = ((((9,3),2),((((7,13),4),14),(((8,10),((6,11),15)),5))),12,1);
+   tree rep.5120000 = (12,(((((8,10),((15,6),11)),((2,9),3)),(4,(7,13))),(14,5)),1);
+   tree rep.5130000 = (12,(((((8,10),((6,15),11)),5),14),(((13,7),4),((2,9),3))),1);
+   tree rep.5140000 = ((9,2),((12,((14,((4,(7,13)),(8,(10,(11,(6,15)))))),5)),3),1);
+   tree rep.5150000 = ((((6,(15,11)),(10,8)),((3,(9,2)),(5,(14,((7,4),13))))),12,1);
+   tree rep.5160000 = ((((5,(3,(2,9))),(((13,7),4),14)),(((11,(15,6)),8),10)),12,1);
+   tree rep.5170000 = (((5,((3,(9,2)),(((15,6),11),(10,8)))),(((7,13),14),4)),12,1);
+   tree rep.5180000 = (5,((((8,((15,6),11)),10),12),((3,(2,9)),(14,((7,13),4)))),1);
+   tree rep.5190000 = ((((11,(6,15)),(8,10)),((3,(9,2)),(5,((4,14),(13,7))))),12,1);
+   tree rep.5200000 = ((((((15,6),11),10),8),((3,((13,(7,4)),(5,14))),(2,9))),12,1);
+   tree rep.5210000 = (((((7,13),((14,5),(3,(9,2)))),4),(8,((11,(15,6)),10))),12,1);
+   tree rep.5220000 = (12,(((((15,6),11),8),10),((((9,2),3),14),(((13,7),4),5))),1);
+   tree rep.5230000 = (12,((((6,(11,15)),8),10),((9,2),((3,5),((7,13),(4,14))))),1);
+   tree rep.5240000 = ((((4,(7,13)),(((9,2),3),5)),14),((6,(11,15)),(12,(10,8))),1);
+   tree rep.5250000 = (12,(((8,10),((6,15),11)),((14,((13,7),(5,4))),(9,(3,2)))),1);
+   tree rep.5260000 = (12,(((((7,13),4),14),((3,(2,9)),5)),((15,(11,6)),(8,10))),1);
+   tree rep.5270000 = ((12,(((14,4),(13,7)),(5,(3,(2,9))))),((10,8),(6,(15,11))),1);
+   tree rep.5280000 = ((((10,((15,6),11)),8),(((5,(14,4)),(13,7)),((9,2),3))),12,1);
+   tree rep.5290000 = ((12,((((2,9),3),5),(14,((13,4),7)))),((10,(11,(6,15))),8),1);
+   tree rep.5300000 = (((((11,(15,6)),8),10),(5,((4,((2,9),3)),((13,7),14)))),12,1);
+   tree rep.5310000 = (((((15,6),11),(8,10)),(5,((((3,(9,2)),14),4),(13,7)))),12,1);
+   tree rep.5320000 = ((((7,13),(14,((5,4),((10,8),((15,11),6))))),(3,(2,9))),12,1);
+   tree rep.5330000 = (((10,(8,(11,(15,6)))),(((7,13),(9,2)),(3,(14,(4,5))))),12,1);
+   tree rep.5340000 = (12,((10,(8,((6,15),11))),(5,((4,(13,7)),(((9,2),3),14)))),1);
+   tree rep.5350000 = (12,((((14,(4,(13,7))),(3,(2,9))),5),(((11,15),6),(10,8))),1);
+   tree rep.5360000 = ((((((((15,11),6),(10,8)),((7,13),4)),(3,(9,2))),14),5),12,1);
+   tree rep.5370000 = (4,(((5,(7,13)),((10,(((11,15),6),8)),(12,(3,(2,9))))),14),1);
+   tree rep.5380000 = (((5,(((9,2),3),(((7,13),4),14))),((6,(15,11)),(10,8))),12,1);
+   tree rep.5390000 = (12,((((4,(7,13)),14),((3,(2,9)),5)),(10,((11,(6,15)),8))),1);
+   tree rep.5400000 = ((((((14,(7,13)),4),(3,(9,2))),5),((10,(6,(11,15))),8)),12,1);
+   tree rep.5410000 = (12,(((10,8),((15,6),11)),(5,(((4,(7,13)),14),((2,9),3)))),1);
+   tree rep.5420000 = ((((3,(2,9)),(14,(4,((7,13),5)))),((8,10),((11,15),6))),12,1);
+   tree rep.5430000 = ((((6,(11,15)),(((((13,7),4),14),5),(3,(9,2)))),(8,10)),12,1);
+   tree rep.5440000 = ((((10,(11,(15,6))),8),((((9,2),(4,(13,7))),3),(14,5))),12,1);
+   tree rep.5450000 = (((5,4),(((13,7),(((10,8),(11,(6,15))),(3,(9,2)))),14)),12,1);
+   tree rep.5460000 = ((8,(((6,15),11),10)),((((14,4),(7,13)),5),(12,(3,(2,9)))),1);
+   tree rep.5470000 = (12,((((15,11),6),(10,8)),((14,(4,(5,(7,13)))),((9,2),3))),1);
+   tree rep.5480000 = (((6,(15,11)),(10,8)),(12,((5,(14,4)),(((2,9),3),(7,13)))),1);
+   tree rep.5490000 = (((10,(8,((11,15),6))),(((4,14),(13,7)),(((2,9),5),3))),12,1);
+   tree rep.5500000 = ((((((7,13),(4,14)),5),((2,9),3)),((8,10),(15,(11,6)))),12,1);
+   tree rep.5510000 = (12,((((((3,(2,9)),14),(7,13)),4),5),((10,8),(6,(11,15)))),1);
+   tree rep.5520000 = (12,((((6,(15,11)),10),8),((14,5),((3,(2,9)),((13,4),7)))),1);
+   tree rep.5530000 = (((((13,7),4),((5,(3,(2,9))),14)),(8,((6,(11,15)),10))),12,1);
+   tree rep.5540000 = (12,((((10,(15,(6,11))),8),(4,(((9,2),3),(14,(7,13))))),5),1);
+   tree rep.5550000 = (((((7,13),4),(((2,9),3),(5,14))),(10,(((15,11),6),8))),12,1);
+   tree rep.5560000 = (12,((10,(8,((15,11),6))),(((3,(2,9)),(5,14)),((13,7),4))),1);
+   tree rep.5570000 = (((((10,8),(6,(15,11))),3),(5,(((7,13),4),((9,2),14)))),12,1);
+   tree rep.5580000 = (((((2,9),3),((((8,((6,15),11)),10),(14,(13,7))),4)),5),12,1);
+   tree rep.5590000 = (12,(((3,(2,9)),(((14,4),(7,13)),5)),(((11,(6,15)),10),8)),1);
+   tree rep.5600000 = (12,((((11,15),6),(10,8)),(5,(((7,13),(14,4)),(3,(2,9))))),1);
+   tree rep.5610000 = ((((14,((13,7),4)),(5,(3,(2,9)))),(10,(8,(6,(11,15))))),12,1);
+   tree rep.5620000 = ((((10,8),((6,15),11)),(((5,(4,(7,13))),14),((2,9),3))),12,1);
+   tree rep.5630000 = (12,((((11,(15,6)),10),8),(((13,7),4),((3,(9,2)),(5,14)))),1);
+   tree rep.5640000 = ((((6,(15,11)),(8,10)),(5,(((13,7),(14,4)),((9,2),3)))),12,1);
+   tree rep.5650000 = (12,(((3,(2,9)),((7,13),((14,4),5))),((10,8),((11,15),6))),1);
+   tree rep.5660000 = (((((4,(7,13)),14),(((2,9),3),5)),(8,(((6,15),11),10))),12,1);
+   tree rep.5670000 = ((12,(5,(((9,2),3),((4,14),(7,13))))),(10,(8,((11,15),6))),1);
+   tree rep.5680000 = ((((6,(11,15)),(10,8)),(5,((((13,7),4),14),(3,(9,2))))),12,1);
+   tree rep.5690000 = (12,(((((7,13),4),14),(((2,9),3),5)),(((6,(15,11)),8),10)),1);
+   tree rep.5700000 = ((14,(((5,((13,7),4)),12),((9,2),3))),(10,(8,(6,(15,11)))),1);
+   tree rep.5710000 = (12,((5,(((7,(14,13)),4),((9,2),3))),((10,8),((15,6),11))),1);
+   tree rep.5720000 = ((((13,7),4),14),(((9,2),3),(((((15,11),6),(8,10)),12),5)),1);
+   tree rep.5730000 = (12,((((5,14),((13,7),4)),(3,(2,9))),(((11,(6,15)),10),8)),1);
+   tree rep.5740000 = (((((7,13),14),((4,(3,(2,9))),5)),((8,10),((15,6),11))),12,1);
+   tree rep.5750000 = (((((2,9),(5,3)),(4,(14,(7,13)))),(10,(((15,11),6),8))),12,1);
+   tree rep.5760000 = ((((8,(11,(15,6))),10),((5,14),((3,(9,2)),(4,(7,13))))),12,1);
+   tree rep.5770000 = (12,((((11,(15,6)),8),10),((((2,9),3),(((4,7),13),14)),5)),1);
+   tree rep.5780000 = (((10,(8,((11,15),6))),((4,((7,13),(14,5))),(3,(9,2)))),12,1);
+   tree rep.5790000 = ((((4,(7,13)),(14,((3,(2,9)),5))),((10,((15,11),6)),8)),12,1);
+   tree rep.5800000 = ((((3,((4,(13,7)),14)),(5,(2,9))),(8,(10,((15,6),11)))),12,1);
+   tree rep.5810000 = (12,(((8,((11,15),6)),10),(((7,13),4),((((2,9),3),14),5))),1);
+   tree rep.5820000 = ((((3,(2,9)),12),((10,8),(6,(15,11)))),(((14,5),4),(7,13)),1);
+   tree rep.5830000 = (((10,8),(11,(6,15))),(12,(((14,5),((4,13),7)),(3,(2,9)))),1);
+   tree rep.5840000 = ((((13,7),(5,(4,(14,(3,(2,9)))))),(10,(((11,15),6),8))),12,1);
+   tree rep.5850000 = (((((3,(9,2)),5),((6,(15,11)),(8,10))),((14,(13,7)),4)),12,1);
+   tree rep.5860000 = (12,((5,(((4,(7,13)),14),((2,9),3))),(10,(((6,11),15),8))),1);
+   tree rep.5870000 = ((5,(((9,2),3),(((7,13),4),14))),(12,((6,(15,11)),(10,8))),1);
+   tree rep.5880000 = (((((2,9),3),(((7,14),(13,4)),5)),(8,(10,(11,(15,6))))),12,1);
+   tree rep.5890000 = (((((6,15),11),10),8),(((14,5),(3,((9,2),12))),((13,7),4)),1);
+   tree rep.5900000 = ((((11,6),15),((5,(((9,2),3),(14,((13,7),4)))),(8,10))),12,1);
+   tree rep.5910000 = ((((8,10),((6,15),11)),(((5,(4,(7,13))),14),((9,2),3))),12,1);
+   tree rep.5920000 = ((((11,(6,15)),(10,8)),((5,((14,(13,7)),4)),(3,(2,9)))),12,1);
+   tree rep.5930000 = ((((4,(3,(2,9))),(((7,13),14),5)),((10,8),((11,15),6))),12,1);
+   tree rep.5940000 = (12,(3,(((5,(9,2)),((13,7),(14,4))),((((15,6),11),10),8))),1);
+   tree rep.5950000 = (((5,14),(((13,7),4),((2,9),3))),(12,((6,(15,11)),(8,10))),1);
+   tree rep.5960000 = (12,(((10,((11,15),6)),8),(((14,5),(4,(13,7))),((9,2),3))),1);
+   tree rep.5970000 = (12,((((9,2),3),((4,(13,7)),(5,14))),((11,(15,6)),(8,10))),1);
+   tree rep.5980000 = (12,(((10,((11,15),6)),8),((7,13),(4,((14,5),(3,(9,2)))))),1);
+   tree rep.5990000 = ((((2,9),3),((5,(14,((10,8),(11,(6,15))))),(4,(13,7)))),12,1);
+   tree rep.6000000 = (12,(((8,10),((15,11),6)),(((2,9),3),((14,((13,7),4)),5))),1);
+   tree rep.6010000 = (12,((10,(8,(15,(6,11)))),((((9,2),3),((13,14),(7,4))),5)),1);
+   tree rep.6020000 = (12,((((5,(2,3)),14),(4,(9,(13,7)))),(8,(((6,15),11),10))),1);
+   tree rep.6030000 = (((((14,(7,13)),4),(5,(3,(2,9)))),((((6,15),11),8),10)),12,1);
+   tree rep.6040000 = ((((4,14),(7,13)),(5,((2,9),3))),((10,((6,(11,15)),8)),12),1);
+   tree rep.6050000 = ((((2,9),(((14,5),(4,(7,13))),3)),(10,((11,(15,6)),8))),12,1);
+   tree rep.6060000 = (12,(((5,((3,(2,9)),(4,(7,13)))),14),((((6,15),11),8),10)),1);
+   tree rep.6070000 = (12,(((3,(9,2)),(((7,13),(4,14)),5)),((15,(11,6)),(10,8))),1);
+   tree rep.6080000 = (((5,(((13,7),(((9,2),3),14)),4)),((8,10),(11,(15,6)))),12,1);
+   tree rep.6090000 = (((8,10),(11,(15,6))),((((9,2),3),(5,((4,(13,7)),14))),12),1);
+   tree rep.6100000 = (12,(((3,(9,2)),((14,5),(4,(7,13)))),(8,(10,(6,(11,15))))),1);
+   tree rep.6110000 = (12,((((9,2),3),(5,(4,((13,7),14)))),((10,8),((11,15),6))),1);
+   tree rep.6120000 = ((((6,(11,15)),10),8),(12,(5,(((2,9),3),(4,(7,(13,14)))))),1);
+   tree rep.6130000 = ((((((13,7),4),((14,5),(3,(2,9)))),8),((6,(15,11)),10)),12,1);
+   tree rep.6140000 = (((8,(((11,15),6),10)),12),((((2,9),3),(14,(4,(13,7)))),5),1);
+   tree rep.6150000 = (12,((((6,15),11),(8,10)),(5,((3,(2,9)),(((13,7),4),14)))),1);
+   tree rep.6160000 = ((10,(((15,11),6),8)),(12,((3,(9,2)),((((13,7),4),5),14))),1);
+   tree rep.6170000 = (((((10,8),(11,(6,15))),(14,((7,13),4))),(((2,9),5),3)),12,1);
+   tree rep.6180000 = (12,((5,(14,(4,(13,7)))),(((6,(15,11)),(10,8)),((9,2),3))),1);
+   tree rep.6190000 = (12,((5,((3,(2,9)),((4,(13,7)),14))),((15,(6,11)),(10,8))),1);
+   tree rep.6200000 = (12,(((8,10),(11,(6,15))),(((3,(9,2)),5),(4,(14,(7,13))))),1);
+   tree rep.6210000 = ((((3,(9,2)),((5,7),((14,4),13))),((8,(11,(15,6))),10)),12,1);
+   tree rep.6220000 = ((((((2,9),3),(14,((13,7),4))),5),((10,8),(11,(6,15)))),12,1);
+   tree rep.6230000 = (((((4,(14,(13,7))),((3,(2,9)),5)),(10,8)),(6,(11,15))),12,1);
+   tree rep.6240000 = ((((11,(6,15)),(8,10)),((((2,9),3),14),(5,(4,(7,13))))),12,1);
+   tree rep.6250000 = ((((6,(15,11)),(10,8)),(14,((((13,7),5),(3,(9,2))),4))),12,1);
+   tree rep.6260000 = (((((15,11),6),(10,8)),((4,((13,7),14)),(5,(3,(9,2))))),12,1);
+   tree rep.6270000 = (12,(((((4,(13,7)),14),5),((9,2),3)),((11,(15,6)),(8,10))),1);
+   tree rep.6280000 = (((10,(((15,11),6),8)),((((2,9),3),((7,13),5)),(14,4))),12,1);
+   tree rep.6290000 = ((((10,8),((11,15),6)),((((13,7),(3,(2,9))),14),(4,5))),12,1);
+   tree rep.6300000 = ((12,((8,10),((6,11),15))),(((3,9),2),(5,(((13,7),4),14))),1);
+   tree rep.6310000 = (((10,(8,((15,6),11))),(4,((((7,13),14),5),(3,(9,2))))),12,1);
+   tree rep.6320000 = (12,(((2,9),3),(5,(4,(((7,13),14),((8,10),((11,6),15)))))),1);
+   tree rep.6330000 = (12,((10,((11,(15,6)),8)),(((7,13),(((9,2),3),(5,14))),4)),1);
+   tree rep.6340000 = (12,(((15,(11,6)),(8,10)),(((14,(13,(4,7))),((2,9),3)),5)),1);
+   tree rep.6350000 = (((((9,2),3),(5,((14,4),(7,13)))),(8,(10,(6,(11,15))))),12,1);
+   tree rep.6360000 = ((((((7,(13,4)),14),((10,8),(6,(15,11)))),5),(3,(9,2))),12,1);
+   tree rep.6370000 = (((10,8),((15,6),11)),(12,(14,((5,4),((3,(9,2)),(7,13))))),1);
+   tree rep.6380000 = ((((((2,9),3),((4,(13,7)),12)),5),14),((8,10),(6,(11,15))),1);
+   tree rep.6390000 = (12,((((11,15),6),(8,10)),((((2,9),3),((4,(7,13)),14)),5)),1);
+   tree rep.6400000 = (12,(((8,(15,(6,11))),10),((((13,7),4),14),(5,(3,(2,9))))),1);
+   tree rep.6410000 = ((((8,10),((6,15),11)),((((9,2),3),((14,5),4)),(7,13))),12,1);
+   tree rep.6420000 = (((10,(8,((11,15),6))),(5,((3,(9,2)),(14,(4,(13,7)))))),12,1);
+   tree rep.6430000 = ((((((4,(7,13)),14),5),(3,(2,9))),((6,(15,11)),(8,10))),12,1);
+   tree rep.6440000 = (12,((((14,((7,13),4)),(3,(2,9))),5),(8,(10,(11,(6,15))))),1);
+   tree rep.6450000 = (12,(((11,(6,15)),(8,10)),(((3,(2,9)),(5,14)),((13,7),4))),1);
+   tree rep.6460000 = (12,((3,(9,2)),(((((6,15),11),8),10),(((4,(13,7)),14),5))),1);
+   tree rep.6470000 = (12,((((((2,9),(4,3)),(7,13)),5),14),(10,(8,((15,11),6)))),1);
+   tree rep.6480000 = ((10,(((6,15),11),8)),(12,(((9,2),3),((14,((7,13),4)),5))),1);
+   tree rep.6490000 = ((((10,8),(6,(11,15))),(((3,(2,9)),5),(14,(4,(13,7))))),12,1);
+   tree rep.6500000 = (12,((10,((11,(15,6)),8)),((14,(4,(13,7))),(5,((2,9),3)))),1);
+   tree rep.6510000 = (12,(((5,(3,(2,9))),((14,(7,13)),4)),((8,(6,(11,15))),10)),1);
+   tree rep.6520000 = (12,((((((9,2),3),14),(4,(7,13))),5),(((6,11),15),(10,8))),1);
+   tree rep.6530000 = ((12,((((2,9),3),((5,14),4)),(13,7))),((6,(11,15)),(10,8)),1);
+   tree rep.6540000 = ((((((4,(13,7)),14),5),((2,9),3)),(8,((6,(11,15)),10))),12,1);
+   tree rep.6550000 = (12,(((2,9),3),(((4,(7,13)),(5,14)),((11,(6,15)),(10,8)))),1);
+   tree rep.6560000 = (12,(((3,(2,9)),(((13,7),4),(5,14))),(8,(10,(6,(15,11))))),1);
+   tree rep.6570000 = (12,(((5,(4,14)),(((11,(15,6)),(8,10)),((2,9),3))),(13,7)),1);
+   tree rep.6580000 = ((((8,((15,6),11)),10),((3,(2,9)),((5,(4,(7,13))),14))),12,1);
+   tree rep.6590000 = (((4,(3,(2,9))),((7,13),((14,(10,(8,((15,6),11)))),5))),12,1);
+   tree rep.6600000 = (12,((((14,(4,(13,7))),5),((2,9),3)),(((6,(15,11)),8),10)),1);
+   tree rep.6610000 = (12,((((7,13),4),(((2,9),3),(14,5))),((8,((11,15),6)),10)),1);
+   tree rep.6620000 = ((((6,15),11),(8,10)),(((3,(9,2)),(5,(((7,13),14),4))),12),1);
+   tree rep.6630000 = (((8,((11,(6,15)),((5,(((13,7),14),4)),(3,(2,9))))),10),12,1);
+   tree rep.6640000 = ((((3,(2,9)),((14,5),4)),(12,(13,7))),((10,8),((6,15),11)),1);
+   tree rep.6650000 = ((5,((((8,(10,((6,11),15))),((2,9),3)),4),(13,(14,7)))),12,1);
+   tree rep.6660000 = ((((10,8),((11,15),6)),(((3,5),((14,(7,13)),4)),(2,9))),12,1);
+   tree rep.6670000 = ((((4,(13,7)),(14,5)),((2,9),3)),((((15,6),11),(8,10)),12),1);
+   tree rep.6680000 = (((((((9,2),3),(((13,7),14),4)),5),(8,10)),(6,(11,15))),12,1);
+   tree rep.6690000 = ((((3,(9,2)),((4,14),(5,(7,13)))),(8,(10,(11,(15,6))))),12,1);
+   tree rep.6700000 = (12,((11,(6,15)),(((3,(((13,7),(14,4)),(9,2))),5),(10,8))),1);
+   tree rep.6710000 = (12,(((8,(6,(15,11))),10),((4,((14,5),(((2,9),3),7))),13)),1);
+   tree rep.6720000 = (12,((((3,(2,9)),((13,7),(14,4))),5),((8,10),((15,6),11))),1);
+   tree rep.6730000 = (12,(((4,(3,(2,9))),((14,5),(7,13))),(10,(((11,15),6),8))),1);
+   tree rep.6740000 = (12,(((8,(6,(11,15))),10),(((4,(13,7)),(((2,9),3),14)),5)),1);
+   tree rep.6750000 = (12,(((((6,15),11),8),10),((14,(5,(4,(7,13)))),((2,9),3))),1);
+   tree rep.6760000 = (12,(((((4,(7,13)),14),5),(3,(2,9))),(10,((11,(15,6)),8))),1);
+   tree rep.6770000 = (((((9,2),3),(((13,7),(5,4)),14)),((8,((15,11),6)),10)),12,1);
+   tree rep.6780000 = (12,(((((13,7),4),(14,5)),(10,(8,(11,(6,15))))),(3,(2,9))),1);
+   tree rep.6790000 = (((((11,(15,6)),10),8),((((14,(13,7)),5),(3,(2,9))),4)),12,1);
+   tree rep.6800000 = (((10,(8,((11,6),15))),((3,(2,9)),(5,(14,(4,(13,7)))))),12,1);
+   tree rep.6810000 = ((((((11,15),6),8),10),(((((13,7),4),14),5),(3,(2,9)))),12,1);
+   tree rep.6820000 = ((((8,(15,(11,6))),10),(((5,((2,9),3)),(4,(7,13))),14)),12,1);
+   tree rep.6830000 = (12,(((6,(11,15)),(8,10)),((((7,13),(4,14)),5),((2,9),3))),1);
+   tree rep.6840000 = (12,(((((6,15),11),8),10),((((7,4),13),(5,((9,2),3))),14)),1);
+   tree rep.6850000 = (((5,(((4,(7,13)),14),(3,(2,9)))),((10,((15,11),6)),8)),12,1);
+   tree rep.6860000 = (12,((((3,(9,2)),(((7,13),14),4)),5),((10,8),((11,15),6))),1);
+   tree rep.6870000 = (((((14,(4,(7,13))),5),((9,2),3)),((((6,15),11),8),10)),12,1);
+   tree rep.6880000 = (12,((((((9,2),3),4),(5,14)),(13,7)),((10,8),((15,11),6))),1);
+   tree rep.6890000 = ((((14,(13,7)),((5,((2,9),3)),4)),((10,8),(15,(11,6)))),12,1);
+   tree rep.6900000 = (12,(((14,(4,(7,13))),((3,(2,9)),5)),(10,(((11,15),6),8))),1);
+   tree rep.6910000 = ((((3,(2,9)),(((4,13),(7,14)),5)),(((11,15),6),(10,8))),12,1);
+   tree rep.6920000 = (((((7,13),4),14),((3,(9,2)),(((((6,11),15),8),10),5))),12,1);
+   tree rep.6930000 = (12,((((2,9),3),(5,(14,((7,13),4)))),((6,(15,11)),(10,8))),1);
+   tree rep.6940000 = (12,((5,(((6,11),15),(10,8))),((3,(9,2)),(14,((13,7),4)))),1);
+   tree rep.6950000 = ((((9,2),3),(((7,13),14),(((8,(((15,11),6),10)),4),5))),12,1);
+   tree rep.6960000 = ((((10,8),((15,6),11)),(5,((((7,13),4),14),((9,2),3)))),12,1);
+   tree rep.6970000 = ((((14,((3,(9,2)),5)),((13,7),4)),(8,(10,(15,(6,11))))),12,1);
+   tree rep.6980000 = ((((5,((9,2),3)),14),(4,(7,13))),(12,(((11,(6,15)),10),8)),1);
+   tree rep.6990000 = ((((8,10),(11,(15,6))),(5,(((2,9),3),(((7,13),4),14)))),12,1);
+   tree rep.7000000 = (12,(((10,8),((11,15),6)),(5,(14,(3,((2,9),((13,7),4)))))),1);
+   tree rep.7010000 = ((4,((5,((6,(15,11)),((8,12),10))),14)),(((9,2),3),(7,13)),1);
+   tree rep.7020000 = (12,((8,(10,(11,(15,6)))),(((4,(13,7)),5),(14,(3,(9,2))))),1);
+   tree rep.7030000 = ((((10,8),((6,15),11)),((4,(7,13)),((14,5),(3,(9,2))))),12,1);
+   tree rep.7040000 = (((10,((6,(11,15)),8)),(((3,(9,2)),(14,(4,(7,13)))),5)),12,1);
+   tree rep.7050000 = (12,((10,(((6,15),11),8)),((5,((9,3),2)),(((4,14),13),7))),1);
+   tree rep.7060000 = (12,(((3,(9,2)),((14,(4,(13,7))),5)),((11,(6,15)),(8,10))),1);
+   tree rep.7070000 = (((((14,4),((7,13),((10,8),((11,15),6)))),5),(3,(9,2))),12,1);
+   tree rep.7080000 = (((5,14),((13,7),((12,((6,(11,15)),(8,10))),(3,(2,9))))),4,1);
+   tree rep.7090000 = (12,((8,(10,(11,(15,6)))),((5,(((13,7),4),14)),(3,(2,9)))),1);
+   tree rep.7100000 = (12,((5,(3,((2,9),((7,13),(14,4))))),((8,10),(11,(6,15)))),1);
+   tree rep.7110000 = ((((10,8),((15,11),6)),((13,7),((5,(3,(9,2))),(4,14)))),12,1);
+   tree rep.7120000 = (((8,(10,((6,15),11))),((14,((13,7),4)),((3,(9,2)),5))),12,1);
+   tree rep.7130000 = (12,(((10,8),(6,(11,15))),((((14,(7,13)),4),5),((9,2),3))),1);
+   tree rep.7140000 = (12,((10,(((11,15),6),8)),(((14,((13,7),4)),5),(3,(2,9)))),1);
+   tree rep.7150000 = (12,(((8,(11,(15,6))),10),(5,(((2,9),3),((4,(13,7)),14)))),1);
+   tree rep.7160000 = (12,(5,(((2,9),3),(((((6,15),11),(10,8)),14),(4,(13,7))))),1);
+   tree rep.7170000 = (((4,(7,13)),((14,5),(3,(2,9)))),((8,10),(((15,11),6),12)),1);
+   tree rep.7180000 = ((5,((((2,9),3),14),((4,(13,7)),(10,(8,((15,6),11)))))),12,1);
+   tree rep.7190000 = (12,((10,(8,((11,15),6))),(((3,(9,2)),5),(14,((7,13),4)))),1);
+   tree rep.7200000 = ((((11,(6,15)),(10,8)),(((3,(2,9)),5),((4,14),(13,7)))),12,1);
+   tree rep.7210000 = (((14,(7,13)),(((10,8),((6,11),15)),(4,((3,(2,9)),5)))),12,1);
+   tree rep.7220000 = (12,(((7,13),4),(((5,14),(8,(((15,6),11),10))),(3,(9,2)))),1);
+   tree rep.7230000 = (12,(((6,(11,15)),(8,10)),((5,14),(((9,2),3),(7,(4,13))))),1);
+   tree rep.7240000 = (12,((4,((5,((7,13),14)),((9,2),3))),((11,(15,6)),(8,10))),1);
+   tree rep.7250000 = (12,((10,(8,(11,(15,6)))),(((2,9),3),((5,14),(4,(13,7))))),1);
+   tree rep.7260000 = (12,((((5,((9,2),3)),(4,(13,7))),14),(10,(8,((11,15),6)))),1);
+   tree rep.7270000 = ((((((((6,15),11),(8,10)),14),(5,4)),(3,(2,9))),(7,13)),12,1);
+   tree rep.7280000 = ((((14,((7,13),(5,4))),((2,9),3)),12),(8,(10,(11,(15,6)))),1);
+   tree rep.7290000 = (12,((((11,(6,15)),8),10),((5,(14,(3,(2,9)))),(4,(7,13)))),1);
+   tree rep.7300000 = (((5,(12,(3,(2,9)))),(14,(4,(13,7)))),(((15,6),11),(10,8)),1);
+   tree rep.7310000 = (((((5,((9,2),3)),((7,13),4)),14),((8,10),(6,(15,11)))),12,1);
+   tree rep.7320000 = (12,((14,(((9,2),3),(5,((4,7),13)))),((8,10),(6,(15,11)))),1);
+   tree rep.7330000 = (((10,((6,(15,11)),8)),((5,(14,((7,13),4))),(3,(9,2)))),12,1);
+   tree rep.7340000 = (12,((((9,2),3),(5,(((13,7),4),14))),((8,((6,11),15)),10)),1);
+   tree rep.7350000 = ((((5,((2,9),3)),((4,(13,7)),14)),((8,10),((15,6),11))),12,1);
+   tree rep.7360000 = (((3,(2,9)),(((6,(11,15)),(8,10)),(((7,13),(4,14)),5))),12,1);
+   tree rep.7370000 = ((((((13,7),(4,14)),(3,(9,2))),5),(((15,11),6),(8,10))),12,1);
+   tree rep.7380000 = (((3,(2,9)),((14,(7,13)),4)),((12,((8,10),(6,(11,15)))),5),1);
+   tree rep.7390000 = (((10,((6,(15,11)),8)),(((13,7),4),((14,5),(3,(2,9))))),12,1);
+   tree rep.7400000 = (12,(((3,((9,2),5)),(4,((7,13),14))),(((6,(11,15)),10),8)),1);
+   tree rep.7410000 = (12,((5,(((4,14),(13,7)),((9,2),3))),((8,((11,15),6)),10)),1);
+   tree rep.7420000 = (((6,(15,11)),(((3,(2,9)),12),(5,(((13,7),14),4)))),(8,10),1);
+   tree rep.7430000 = (12,(((2,9),(8,(10,((11,15),6)))),((14,(4,(13,7))),(5,3))),1);
+   tree rep.7440000 = (12,(((((2,9),3),(14,(4,(13,7)))),5),((10,8),((15,6),11))),1);
+   tree rep.7450000 = (((((11,(6,15)),10),8),((14,((4,((9,2),3)),(13,7))),5)),12,1);
+   tree rep.7460000 = (((((2,9),3),(((14,(13,7)),4),5)),(8,((11,(6,15)),10))),12,1);
+   tree rep.7470000 = (((((13,(4,7)),14),(3,(2,9))),5),((8,(10,(11,(6,15)))),12),1);
+   tree rep.7480000 = ((((10,(6,(11,15))),8),((5,((2,9),3)),((13,7),(14,4)))),12,1);
+   tree rep.7490000 = (12,((((15,11),6),(8,10)),(3,((((7,13),4),14),((9,2),5)))),1);
+   tree rep.7500000 = ((4,(((7,13),(3,(9,2))),((14,5),(10,((6,(15,11)),8))))),12,1);
+   tree rep.7510000 = (((5,(((7,(4,14)),(3,(2,9))),13)),(8,(10,(11,(15,6))))),12,1);
+   tree rep.7520000 = (12,((((13,7),(4,14)),(3,((9,2),5))),(((15,11),6),(10,8))),1);
+   tree rep.7530000 = (((((5,14),((9,2),3)),((13,7),((8,10),(15,(6,11))))),4),12,1);
+   tree rep.7540000 = (12,(((10,((11,15),6)),8),(14,(5,(((7,13),4),(3,(9,2)))))),1);
+   tree rep.7550000 = (((((6,15),11),(8,10)),(5,(3,((2,9),(4,((7,13),14)))))),12,1);
+   tree rep.7560000 = ((((5,((4,(7,13)),14)),(3,(2,9))),((10,8),((15,6),11))),12,1);
+   tree rep.7570000 = (12,((((10,8),(11,(15,6))),(14,(4,(13,7)))),(5,((2,9),3))),1);
+   tree rep.7580000 = (12,(((((5,14),4),(7,13)),((2,9),3)),(10,(8,((15,6),11)))),1);
+   tree rep.7590000 = (12,((((11,(6,15)),10),8),(((((4,(7,13)),14),3),(2,9)),5)),1);
+   tree rep.7600000 = (((10,8),(11,(6,15))),(12,(((13,7),(4,14)),(((2,9),3),5))),1);
+   tree rep.7610000 = (12,(((7,13),(((3,4),(14,5)),(9,2))),(10,(8,((11,15),6)))),1);
+   tree rep.7620000 = (12,((5,14),(((10,(8,((6,11),15))),((2,9),3)),((13,7),4))),1);
+   tree rep.7630000 = (((((6,(15,11)),10),8),((14,5),((3,(2,9)),(4,(7,13))))),12,1);
+   tree rep.7640000 = (((((2,9),3),((13,7),((14,4),5))),((((15,11),6),8),10)),12,1);
+   tree rep.7650000 = (12,((10,(8,((6,11),15))),(5,(((2,9),3),((4,(7,13)),14)))),1);
+   tree rep.7660000 = (12,((((14,(3,(9,2))),5),((4,7),13)),((8,((11,15),6)),10)),1);
+   tree rep.7670000 = (12,(((((13,7),4),(14,5)),((9,2),3)),((8,(11,(15,6))),10)),1);
+   tree rep.7680000 = ((((3,(9,2)),((14,5),(4,(7,13)))),(((6,(15,11)),8),10)),12,1);
+   tree rep.7690000 = ((12,(((4,(7,13)),(14,5)),(3,(2,9)))),(8,(((15,11),6),10)),1);
+   tree rep.7700000 = (((((11,(15,6)),8),10),(((14,5),((2,9),3)),((7,13),4))),12,1);
+   tree rep.7710000 = (((5,(((4,14),(13,7)),((2,9),3))),((8,10),((15,6),11))),12,1);
+   tree rep.7720000 = (12,(((5,((9,2),((13,7),(4,14)))),3),(8,(10,((15,6),11)))),1);
+   tree rep.7730000 = (12,((((3,(9,2)),(14,5)),(4,(7,13))),(((15,6),11),(8,10))),1);
+   tree rep.7740000 = ((((3,(9,2)),(5,(14,((13,7),4)))),(10,((6,(11,15)),8))),12,1);
+   tree rep.7750000 = (((((15,11),6),(8,10)),((((13,7),4),14),(5,((9,2),3)))),12,1);
+   tree rep.7760000 = (((11,(6,15)),(8,10)),(((2,9),3),(12,(5,((13,7),(14,4))))),1);
+   tree rep.7770000 = (12,((((6,(11,15)),8),10),((14,(((9,2),3),(5,4))),(7,13))),1);
+   tree rep.7780000 = (12,((((3,(9,2)),(14,5)),((7,13),4)),(((15,11),6),(10,8))),1);
+   tree rep.7790000 = (((5,(((9,2),3),(14,((13,7),4)))),((8,(11,(15,6))),10)),12,1);
+   tree rep.7800000 = (((((6,(11,15)),8),10),(((14,(7,13)),4),((5,(2,9)),3))),12,1);
+   tree rep.7810000 = ((((8,10),(11,(6,15))),((5,((4,14),(13,7))),((2,9),3))),12,1);
+   tree rep.7820000 = ((5,((4,(13,7)),((3,((12,2),9)),14))),(8,(((6,15),11),10)),1);
+   tree rep.7830000 = (12,(((8,10),(11,(15,6))),((13,7),((14,5),(((9,2),3),4)))),1);
+   tree rep.7840000 = (12,((5,((((2,9),3),14),(4,(13,7)))),(((6,(15,11)),10),8)),1);
+   tree rep.7850000 = (((((3,(2,9)),((4,(13,7)),14)),5),(((15,11),6),(10,8))),12,1);
+   tree rep.7860000 = (12,(((((6,11),15),8),10),((((2,9),3),(((14,13),4),7)),5)),1);
+   tree rep.7870000 = (12,((3,(9,2)),(((((6,15),11),(10,8)),5),(14,((7,13),4)))),1);
+   tree rep.7880000 = (12,(((8,10),(14,(5,(((13,7),4),(3,(9,2)))))),((11,15),6)),1);
+   tree rep.7890000 = (12,(((15,(6,11)),(10,8)),(((9,2),3),(4,(((7,13),14),5)))),1);
+   tree rep.7900000 = (12,((((5,((13,7),(14,4))),(2,9)),3),(((11,15),6),(8,10))),1);
+   tree rep.7910000 = (((((14,4),(2,((7,13),5))),9),3),(((10,((11,15),6)),8),12),1);
+   tree rep.7920000 = (((((3,(2,9)),5),((14,4),(7,13))),(8,((6,(15,11)),10))),12,1);
+   tree rep.7930000 = ((3,(2,((((4,(14,(13,7))),((11,(15,6)),(10,8))),5),9))),12,1);
+   tree rep.7940000 = ((((((13,7),(4,14)),5),(3,(2,9))),(((11,6),15),(8,10))),12,1);
+   tree rep.7950000 = ((((10,8),((15,11),6)),((5,12),(3,(9,2)))),((4,14),(13,7)),1);
+   tree rep.7960000 = (12,((((11,(6,15)),10),8),(5,((13,7),((14,4),(3,(9,2)))))),1);
+   tree rep.7970000 = (((10,(8,(11,(15,6)))),((((2,9),3),((7,13),5)),(14,4))),12,1);
+   tree rep.7980000 = (12,(((3,(2,9)),(((8,10),((15,6),11)),(4,5))),(14,(13,7))),1);
+   tree rep.7990000 = (12,((((((14,(4,(13,7))),5),(3,(2,9))),10),8),(6,(15,11))),1);
+   tree rep.8000000 = (12,(5,(((2,9),3),(14,((13,7),(4,((15,(6,11)),(10,8))))))),1);
+   tree rep.8010000 = (((((2,9),3),(((13,7),(5,14)),4)),((11,(6,15)),(8,10))),12,1);
+   tree rep.8020000 = ((((8,10),(6,(15,11))),(((2,9),3),(((4,13),7),(14,5)))),12,1);
+   tree rep.8030000 = (((3,(9,2)),(14,(((7,13),4),5))),(((10,((6,15),11)),8),12),1);
+   tree rep.8040000 = (((((11,(15,6)),10),8),((((9,2),3),5),(((7,13),14),4))),12,1);
+   tree rep.8050000 = ((((((11,15),6),10),8),(((7,13),(5,(3,(9,2)))),(14,4))),12,1);
+   tree rep.8060000 = (((((15,11),6),(10,8)),((5,(4,(13,7))),((3,(2,9)),14))),12,1);
+   tree rep.8070000 = (((8,10),(5,(((((7,13),4),14),((2,9),3)),((15,11),6)))),12,1);
+   tree rep.8080000 = (12,(5,((((14,4),(7,13)),(3,(9,2))),(((11,15),6),(10,8)))),1);
+   tree rep.8090000 = (12,(((10,((15,6),11)),8),(((7,13),4),((14,5),(3,(9,2))))),1);
+   tree rep.8100000 = ((((15,6),11),(10,8)),(((((9,2),3),5),(((13,7),4),14)),12),1);
+   tree rep.8110000 = (12,((5,((3,(2,9)),(14,(4,(13,7))))),(8,(10,((15,11),6)))),1);
+   tree rep.8120000 = (((5,(4,((3,(9,2)),(14,(7,13))))),((6,(11,15)),(10,8))),12,1);
+   tree rep.8130000 = (12,((14,(5,(((9,2),3),((8,10),(15,(11,6)))))),(7,(4,13))),1);
+   tree rep.8140000 = (((((3,(9,2)),((14,4),(7,13))),5),(8,(10,(11,(6,15))))),12,1);
+   tree rep.8150000 = ((((10,8),((15,6),11)),((4,(13,7)),((14,5),(3,(9,2))))),12,1);
+   tree rep.8160000 = ((((4,(13,7)),(((14,5),(2,9)),3)),((6,(15,11)),(10,8))),12,1);
+   tree rep.8170000 = ((((15,6),11),(((5,((9,2),3)),(14,(4,(13,7)))),(8,10))),12,1);
+   tree rep.8180000 = (12,(((((8,10),(6,(15,11))),5),(14,((7,13),4))),(3,(2,9))),1);
+   tree rep.8190000 = (12,((5,((14,(13,7)),((3,(2,9)),4))),((((11,15),6),10),8)),1);
+   tree rep.8200000 = ((((((6,15),11),10),8),(14,((7,13),4))),(12,(5,((2,9),3))),1);
+   tree rep.8210000 = (12,((5,(((14,(13,7)),4),((9,2),3))),((10,8),((15,11),6))),1);
+   tree rep.8220000 = ((((14,5),(((9,2),12),3)),((7,13),4)),((15,(11,6)),(10,8)),1);
+   tree rep.8230000 = (12,((((15,11),6),(8,10)),((((7,13),(5,14)),4),((2,9),3))),1);
+   tree rep.8240000 = (12,(((3,(2,9)),((4,(7,13)),(5,14))),((8,10),((11,6),15))),1);
+   tree rep.8250000 = (12,((((6,15),11),(8,10)),((14,(4,(13,7))),(((9,2),3),5))),1);
+   tree rep.8260000 = (12,(((3,(2,9)),5),((((7,14),4),13),((8,10),(15,(11,6))))),1);
+   tree rep.8270000 = (12,((((6,15),11),(8,10)),(5,((14,(13,7)),(3,(4,(2,9)))))),1);
+   tree rep.8280000 = (12,(((((7,13),4),((2,9),3)),(5,14)),((8,10),(6,(15,11)))),1);
+   tree rep.8290000 = ((((5,((4,(14,(13,7))),(3,(2,9)))),(8,((6,15),11))),10),12,1);
+   tree rep.8300000 = (12,(((((7,13),4),(5,14)),(3,(9,2))),((6,(15,11)),(10,8))),1);
+   tree rep.8310000 = (12,(((10,8),((((4,(13,7)),((9,2),3)),5),14)),((15,11),6)),1);
+   tree rep.8320000 = ((((5,(((9,2),3),4)),(14,(13,7))),((10,8),((6,15),11))),12,1);
+   tree rep.8330000 = (12,((((11,(6,15)),8),10),((5,((2,9),3)),((4,(7,13)),14))),1);
+   tree rep.8340000 = (12,(((9,2),3),(((4,((8,10),(6,(11,15)))),5),((13,7),14))),1);
+   tree rep.8350000 = (12,(((14,(3,(2,9))),(((7,13),5),4)),((6,(11,15)),(8,10))),1);
+   tree rep.8360000 = (12,(((9,2),(3,((7,13),(4,(5,14))))),(10,(((11,15),6),8))),1);
+   tree rep.8370000 = (((((15,6),11),(10,8)),(((2,9),3),(5,((14,4),(7,13))))),12,1);
+   tree rep.8380000 = (12,(((5,14),((10,((15,11),6)),8)),(((13,7),4),(3,(2,9)))),1);
+   tree rep.8390000 = (12,((((5,14),((9,2),(3,4))),(13,7)),((8,(6,(11,15))),10)),1);
+   tree rep.8400000 = (((((4,14),5),((7,13),((9,2),3))),((10,8),((15,6),11))),12,1);
+   tree rep.8410000 = ((5,(((12,((13,7),4)),14),((9,2),3))),(10,(8,((15,6),11))),1);
+   tree rep.8420000 = (((5,((15,(11,6)),(8,10))),(((13,(7,4)),14),((2,9),3))),12,1);
+   tree rep.8430000 = (12,(((5,((4,(7,13)),14)),((2,9),3)),(8,((11,(15,6)),10))),1);
+   tree rep.8440000 = (12,(((14,5),(4,((10,8),((11,15),6)))),((3,(9,2)),(7,13))),1);
+   tree rep.8450000 = (12,((((13,7),(4,14)),((3,(2,9)),5)),((11,(15,6)),(8,10))),1);
+   tree rep.8460000 = (12,((5,((14,(13,7)),((3,(9,2)),4))),(((15,6),11),(10,8))),1);
+   tree rep.8470000 = (12,((11,(15,6)),(8,(10,(((13,7),4),(5,((3,(9,2)),14)))))),1);
+   tree rep.8480000 = ((((((4,(7,13)),14),(3,(9,2))),5),(8,(((11,15),6),10))),12,1);
+   tree rep.8490000 = (12,(((10,8),((6,15),11)),(((4,(7,13)),14),(5,((9,2),3)))),1);
+   tree rep.8500000 = (((((11,15),6),(10,8)),((5,((14,4),(7,13))),(3,(9,2)))),12,1);
+   tree rep.8510000 = ((((5,4),(3,(9,2))),(7,(14,13))),(12,(((11,(15,6)),8),10)),1);
+   tree rep.8520000 = (((8,10),(6,(15,11))),(12,((((13,7),(4,(14,5))),3),(2,9))),1);
+   tree rep.8530000 = (((((4,(14,(7,13))),5),((2,9),3)),((10,8),(11,(6,15)))),12,1);
+   tree rep.8540000 = (((10,(((15,11),6),8)),(((5,14),((9,2),3)),(4,(7,13)))),12,1);
+   tree rep.8550000 = (12,((10,(((15,11),6),8)),(5,(((2,9),3),((13,7),(4,14))))),1);
+   tree rep.8560000 = ((((3,(9,2)),(4,((14,5),(13,7)))),(((15,6),11),(10,8))),12,1);
+   tree rep.8570000 = ((((3,(9,2)),(((14,(13,7)),4),5)),((10,8),((6,15),11))),12,1);
+   tree rep.8580000 = (((5,14),((3,(2,9)),(((8,10),(11,(15,6))),(4,(7,13))))),12,1);
+   tree rep.8590000 = (12,((((4,(7,13)),(14,5)),(3,(9,2))),(8,(((11,15),6),10))),1);
+   tree rep.8600000 = (12,((14,((((13,7),4),5),((2,9),3))),(((15,(6,11)),8),10)),1);
+   tree rep.8610000 = (12,((5,(((14,4),(13,7)),((2,9),3))),(((15,6),11),(8,10))),1);
+   tree rep.8620000 = (((14,5),(((3,(9,2)),((7,13),4)),((6,(15,11)),(8,10)))),12,1);
+   tree rep.8630000 = (12,(((8,10),(11,(15,6))),((5,((4,(14,13)),7)),((2,9),3))),1);
+   tree rep.8640000 = (12,(((8,((15,11),6)),10),((5,(14,(4,(13,7)))),(3,(9,2)))),1);
+   tree rep.8650000 = (((14,(4,(7,13))),((((8,10),(6,(15,11))),5),(3,(2,9)))),12,1);
+   tree rep.8660000 = (12,(((10,8),(15,(6,11))),(((3,(9,2)),((4,(13,7)),14)),5)),1);
+   tree rep.8670000 = (((((14,5),(4,(13,7))),((9,2),3)),(8,((6,(11,15)),10))),12,1);
+   tree rep.8680000 = ((12,(((11,(6,15)),8),10)),(5,((3,(9,2)),(((7,13),14),4))),1);
+   tree rep.8690000 = (((((((2,9),3),5),(4,14)),(13,7)),((((15,6),11),10),8)),12,1);
+   tree rep.8700000 = (((4,((5,(3,(2,9))),(14,(13,7)))),12),(8,(((11,15),6),10)),1);
+   tree rep.8710000 = ((((12,(2,9)),3),((14,5),((10,(15,(11,6))),8))),((4,13),7),1);
+   tree rep.8720000 = (12,(((4,(7,13)),((14,5),((2,9),3))),(8,((11,(15,6)),10))),1);
+   tree rep.8730000 = (12,((((2,9),3),(((13,7),4),(5,14))),((6,(15,11)),(10,8))),1);
+   tree rep.8740000 = (((10,8),(11,(15,6))),(12,(((4,(13,7)),14),(5,(3,(2,9))))),1);
+   tree rep.8750000 = ((10,((((4,(13,7)),(14,5)),(((2,9),3),12)),((6,15),11))),8,1);
+   tree rep.8760000 = (12,(((3,(9,2)),(((4,(13,7)),14),(10,(((15,6),11),8)))),5),1);
+   tree rep.8770000 = (((4,(13,7)),((((((11,15),6),10),8),((9,3),2)),(5,14))),12,1);
+   tree rep.8780000 = (12,((14,((5,(3,(9,2))),(4,(13,7)))),(10,((6,(15,11)),8))),1);
+   tree rep.8790000 = (((4,(13,7)),((((2,9),12),3),14)),(((10,8),(6,(11,15))),5),1);
+   tree rep.8800000 = ((5,((3,(9,2)),((4,14),(7,13)))),((8,(10,(6,(11,15)))),12),1);
+   tree rep.8810000 = ((10,(8,(11,(6,15)))),((5,(4,(14,(7,13)))),(12,((2,9),3))),1);
+   tree rep.8820000 = (12,(((8,10),(6,(11,15))),(((((4,5),14),(7,13)),3),(9,2))),1);
+   tree rep.8830000 = ((((((3,(2,9)),5),4),14),(13,7)),(12,((8,10),(11,(6,15)))),1);
+   tree rep.8840000 = (12,((10,(8,(6,(15,11)))),(5,((4,(13,7)),(14,((9,2),3))))),1);
+   tree rep.8850000 = ((((10,((15,11),6)),8),((3,(9,2)),(4,((14,5),(7,13))))),12,1);
+   tree rep.8860000 = (((((4,14),(13,7)),5),(((8,10),((6,15),11)),((2,9),3))),12,1);
+   tree rep.8870000 = (12,(((8,10),((((4,(7,13)),14),5),((2,9),3))),(11,(15,6))),1);
+   tree rep.8880000 = ((((15,11),6),(10,8)),(12,((5,((4,(7,13)),14)),((2,9),3))),1);
+   tree rep.8890000 = (((((13,7),(14,4)),(((11,(15,6)),(10,8)),((2,9),3))),5),12,1);
+   tree rep.8900000 = ((((((15,6),11),8),10),(((((7,13),4),14),((9,2),3)),5)),12,1);
+   tree rep.8910000 = (((((4,13),(14,7)),(((9,2),3),5)),((10,(11,(15,6))),8)),12,1);
+   tree rep.8920000 = ((((8,10),(11,(6,15))),((((7,(13,9)),14),4),(5,(2,3)))),12,1);
+   tree rep.8930000 = (12,((((3,(9,2)),5),((13,7),(14,4))),(10,(8,((6,15),11)))),1);
+   tree rep.8940000 = (12,(((5,((4,(7,13)),14)),((2,9),3)),((10,8),((15,6),11))),1);
+   tree rep.8950000 = (12,((8,(((15,6),11),10)),(((3,(2,9)),5),(((13,7),14),4))),1);
+   tree rep.8960000 = (12,((((3,(9,2)),5),((14,(7,13)),4)),((((15,6),11),8),10)),1);
+   tree rep.8970000 = (12,(((6,(11,15)),(10,8)),(((3,(9,2)),((4,(13,7)),14)),5)),1);
+   tree rep.8980000 = ((((5,((14,4),(7,13))),((9,2),3)),(((15,6),11),(10,8))),12,1);
+   tree rep.8990000 = ((((3,(9,2)),(((4,(7,13)),5),14)),((((15,11),6),10),8)),12,1);
+   tree rep.9000000 = (12,(((3,(2,9)),((4,(14,(7,13))),5)),(((6,15),11),(8,10))),1);
+   tree rep.9010000 = (12,((((2,9),3),((4,(5,(13,7))),14)),(((6,15),11),(10,8))),1);
+   tree rep.9020000 = ((((6,(15,11)),8),10),((((13,7),4),(12,(((2,9),3),14))),5),1);
+   tree rep.9030000 = (((8,((11,(15,6)),10)),((14,((2,9),3)),(5,((13,7),4)))),12,1);
+   tree rep.9040000 = (12,((10,(8,(11,(6,15)))),(((14,5),((13,7),4)),(3,(2,9)))),1);
+   tree rep.9050000 = (((((14,(13,4)),7),((3,(2,9)),5)),(((6,15),11),(8,10))),12,1);
+   tree rep.9060000 = ((((5,(7,13)),(12,((9,2),3))),(4,14)),(((11,15),6),(10,8)),1);
+   tree rep.9070000 = (((((7,13),((3,(2,9)),(14,5))),4),((10,8),(6,(11,15)))),12,1);
+   tree rep.9080000 = ((((10,((15,11),6)),8),(((((13,7),4),14),((9,2),3)),5)),12,1);
+   tree rep.9090000 = ((((10,(11,(6,15))),8),(((3,(9,2)),5),(14,(7,(4,13))))),12,1);
+   tree rep.9100000 = (12,(((((((13,7),(5,(3,(2,9)))),4),14),(11,(6,15))),8),10),1);
+   tree rep.9110000 = (((((6,15),11),(8,10)),((5,((2,9),3)),(14,(4,(13,7))))),12,1);
+   tree rep.9120000 = ((((8,(11,(6,15))),10),(((9,2),3),(5,((14,(7,13)),4)))),12,1);
+   tree rep.9130000 = (((((14,5),(4,(7,13))),(3,(9,2))),(8,(((15,11),6),10))),12,1);
+   tree rep.9140000 = (12,((((14,5),((9,2),3)),(13,(7,4))),((8,10),(6,(15,11)))),1);
+   tree rep.9150000 = ((5,((((4,(7,13)),14),((9,2),3)),((6,(15,11)),(10,8)))),12,1);
+   tree rep.9160000 = (12,(((((2,9),3),(5,14)),(4,(7,13))),((8,(6,(11,15))),10)),1);
+   tree rep.9170000 = ((((8,10),((15,6),11)),((((9,2),3),5),(((7,13),14),4))),12,1);
+   tree rep.9180000 = ((((15,(11,6)),10),8),(12,(((9,2),3),(((7,13),(14,4)),5))),1);
+   tree rep.9190000 = ((((8,10),(11,(15,6))),(((3,(9,2)),4),((14,5),(13,7)))),12,1);
+   tree rep.9200000 = (12,((((3,(9,2)),(4,(7,13))),(5,14)),((8,10),(11,(6,15)))),1);
+   tree rep.9210000 = (12,((((6,15),11),(8,10)),((((14,(7,13)),4),((9,2),3)),5)),1);
+   tree rep.9220000 = (12,(((4,(7,(14,13))),(((10,8),((15,11),6)),(9,2))),(5,3)),1);
+   tree rep.9230000 = (((((15,11),6),(8,10)),(((4,14),(7,13)),(5,((2,9),3)))),12,1);
+   tree rep.9240000 = (((((2,9),3),5),(14,(4,(13,7)))),(12,((10,8),((11,15),6))),1);
+   tree rep.9250000 = (12,(((8,(6,(15,11))),10),(((3,(9,2)),4),(5,(14,(7,13))))),1);
+   tree rep.9260000 = ((((8,10),(5,((14,(4,(13,7))),(3,(2,9))))),((15,11),6)),12,1);
+   tree rep.9270000 = (((((2,9),3),(((7,13),(4,14)),5)),(10,(8,((11,15),6)))),12,1);
+   tree rep.9280000 = ((((5,(4,((13,7),14))),((9,2),3)),((11,(15,6)),(8,10))),12,1);
+   tree rep.9290000 = (12,((((6,(11,15)),(8,10)),(14,((13,7),4))),(((9,2),3),5)),1);
+   tree rep.9300000 = (12,((((3,(9,2)),((4,(7,13)),14)),5),(10,((11,(6,15)),8))),1);
+   tree rep.9310000 = (12,(((((9,2),3),(4,(7,13))),(5,14)),(((11,15),6),(8,10))),1);
+   tree rep.9320000 = (12,(((6,(11,15)),(10,8)),(((3,(2,9)),((13,(14,7)),4)),5)),1);
+   tree rep.9330000 = (((((15,6),11),(10,8)),(((13,(4,7)),14),((3,(2,9)),5))),12,1);
+   tree rep.9340000 = ((((9,2),3),(((4,(((8,10),(11,(15,6))),14)),5),(7,13))),12,1);
+   tree rep.9350000 = (12,(((((15,6),11),8),10),((14,5),((4,(13,7)),(3,(9,2))))),1);
+   tree rep.9360000 = (12,((((3,(9,2)),(((7,13),4),(5,14))),(15,(6,11))),(8,10)),1);
+   tree rep.9370000 = ((((((9,2),5),3),(((7,13),4),14)),(10,(((6,15),11),8))),12,1);
+   tree rep.9380000 = ((((3,(9,2)),((4,(7,13)),(5,14))),12),((((15,11),6),10),8),1);
+   tree rep.9390000 = ((((9,2),3),((((13,7),4),14),((8,((11,(6,15)),10)),5))),12,1);
+   tree rep.9400000 = (((13,7),(((14,(4,5)),((9,2),3)),12)),((8,10),(15,(6,11))),1);
+   tree rep.9410000 = ((((8,10),(6,(11,15))),((((9,2),3),(4,(7,13))),(5,14))),12,1);
+   tree rep.9420000 = (((8,10),((11,6),15)),(((3,12),(9,2)),(((7,13),4),(5,14))),1);
+   tree rep.9430000 = ((((5,((7,(4,13)),14)),(3,(2,9))),((8,10),(11,(15,6)))),12,1);
+   tree rep.9440000 = (12,((9,(3,2)),((((4,(13,7)),14),5),(10,(8,((15,6),11))))),1);
+   tree rep.9450000 = ((14,((((11,(6,15)),(8,10)),(5,4)),(((2,9),3),(7,13)))),12,1);
+   tree rep.9460000 = (((((3,(9,2)),5),((14,(7,13)),4)),(10,(8,(11,(6,15))))),12,1);
+   tree rep.9470000 = (((5,((2,9),((((13,7),14),4),3))),((11,(15,6)),(10,8))),12,1);
+   tree rep.9480000 = ((((14,(7,13)),(4,((3,(2,9)),5))),12),((6,(15,11)),(10,8)),1);
+   tree rep.9490000 = ((((10,(11,(15,6))),8),((((13,7),4),(14,5)),(3,(2,9)))),12,1);
+   tree rep.9500000 = (12,(((((11,6),15),10),8),((5,((7,(13,4)),14)),((9,2),3))),1);
+   tree rep.9510000 = (12,((((11,(6,15)),8),10),(((2,9),3),((((7,13),4),5),14))),1);
+   tree rep.9520000 = ((((6,11),15),(8,10)),(((3,(2,9)),(4,(7,13))),(12,(5,14))),1);
+   tree rep.9530000 = (((((5,((7,13),14)),4),(3,(2,9))),(((11,(15,6)),10),8)),12,1);
+   tree rep.9540000 = (12,((10,(8,((6,15),11))),((14,5),(((13,7),4),(3,(2,9))))),1);
+   tree rep.9550000 = (12,(((8,10),((6,15),11)),(((9,2),3),(5,(((14,4),7),13)))),1);
+   tree rep.9560000 = (((10,(8,((11,15),6))),((14,((9,2),3)),(((7,13),4),5))),12,1);
+   tree rep.9570000 = (((14,(3,(2,9))),(5,((13,7),4))),(12,(8,(((15,6),11),10))),1);
+   tree rep.9580000 = (((((9,2),(((7,13),14),4)),(3,5)),(((11,15),6),(8,10))),12,1);
+   tree rep.9590000 = (12,(((9,2),3),(5,((((6,(11,15)),(10,8)),((13,7),4)),14))),1);
+   tree rep.9600000 = (12,((5,((((10,8),(11,(6,15))),((4,7),13)),(3,(9,2)))),14),1);
+   tree rep.9610000 = (12,(((10,((15,6),11)),8),((13,7),(((14,5),(3,(9,2))),4))),1);
+   tree rep.9620000 = (((11,(15,6)),(10,8)),((3,((2,9),(14,((4,(13,7)),5)))),12),1);
+   tree rep.9630000 = (((((11,(15,6)),8),10),((((9,2),3),((14,4),(13,7))),5)),12,1);
+   tree rep.9640000 = (12,(((5,((9,2),3)),(4,(14,(7,13)))),((10,8),(6,(11,15)))),1);
+   tree rep.9650000 = (((5,((14,(4,(13,7))),((9,2),3))),((8,((15,11),6)),10)),12,1);
+   tree rep.9660000 = ((8,(10,((6,15),11))),(((3,(2,9)),((14,(5,(13,7))),4)),12),1);
+   tree rep.9670000 = ((((10,8),(6,(11,15))),((3,(2,9)),((((7,13),5),4),14))),12,1);
+   tree rep.9680000 = (((11,(15,6)),(10,8)),(12,(((2,9),3),(((14,(13,7)),4),5))),1);
+   tree rep.9690000 = ((((6,(11,15)),(8,10)),((((5,14),(3,(9,2))),4),(13,7))),12,1);
+   tree rep.9700000 = (((((((3,(9,2)),5),(14,((7,13),4))),8),10),(11,(15,6))),12,1);
+   tree rep.9710000 = (((11,(6,15)),(((((9,2),3),5),(((13,7),4),14)),(8,10))),12,1);
+   tree rep.9720000 = (12,((10,(8,((15,6),11))),((((4,(7,13)),14),5),(3,(9,2)))),1);
+   tree rep.9730000 = (12,((((7,(14,5)),(3,(9,2))),(13,4)),((8,10),((15,11),6))),1);
+   tree rep.9740000 = (12,(((10,8),((15,11),6)),((5,((9,2),3)),(4,((7,13),14)))),1);
+   tree rep.9750000 = (12,((((11,(15,6)),(8,10)),(5,(14,((7,13),4)))),(3,(9,2))),1);
+   tree rep.9760000 = (((8,10),(((11,15),6),((((9,2),3),5),(((13,7),4),14)))),12,1);
+   tree rep.9770000 = (((((14,5),(3,(9,2))),((7,13),4)),(8,(10,(6,(11,15))))),12,1);
+   tree rep.9780000 = ((((((((6,15),11),8),10),((13,7),4)),((3,(2,9)),14)),12),5,1);
+   tree rep.9790000 = (12,(((4,(13,7)),(14,(((9,2),3),(((11,15),6),(8,10))))),5),1);
+   tree rep.9800000 = ((((3,2),9),((((6,(11,15)),8),10),(14,((4,(13,7)),5)))),12,1);
+   tree rep.9810000 = ((((10,(11,(6,15))),8),((14,(((9,2),3),5)),(4,(7,13)))),12,1);
+   tree rep.9820000 = ((10,(((11,15),6),8)),((((((7,13),14),5),4),(3,(9,2))),12),1);
+   tree rep.9830000 = (12,(((14,((4,(13,7)),((9,2),3))),5),((10,8),(11,(15,6)))),1);
+   tree rep.9840000 = (12,(((6,(15,11)),(10,8)),(((9,2),3),(14,(5,(4,(7,13)))))),1);
+   tree rep.9850000 = (((((6,15),11),(10,8)),((((2,9),3),(((7,13),4),14)),5)),12,1);
+   tree rep.9860000 = ((((3,(2,9)),(5,((7,13),(4,14)))),(8,(((11,15),6),10))),12,1);
+   tree rep.9870000 = ((8,((((5,((14,7),(13,4))),((2,9),3)),((6,15),11)),10)),12,1);
+   tree rep.9880000 = (((4,((14,5),(((11,15),6),(8,10)))),((3,(2,9)),(7,13))),12,1);
+   tree rep.9890000 = ((((5,(((13,7),(2,9)),4)),(14,3)),((10,((15,6),11)),8)),12,1);
+   tree rep.9900000 = (12,(((6,(11,15)),(10,8)),(14,((((7,13),4),5),((9,2),3)))),1);
+   tree rep.9910000 = (12,((5,(((9,2),3),((4,(7,13)),14))),((10,8),((15,11),6))),1);
+   tree rep.9920000 = ((((((2,9),3),(4,(13,7))),(5,14)),(8,(((15,6),11),10))),12,1);
+   tree rep.9930000 = (12,(((10,8),((11,15),6)),((4,(((14,13),7),(3,(2,9)))),5)),1);
+   tree rep.9940000 = (12,((5,(14,(((9,2),3),((7,13),4)))),(8,(((15,11),6),10))),1);
+   tree rep.9950000 = ((((((9,2),3),5),((14,(7,13)),4)),12),(((6,(15,11)),8),10),1);
+   tree rep.9960000 = (12,(((2,9),3),(14,(13,(5,(4,((8,(((15,11),6),10)),7)))))),1);
+   tree rep.9970000 = ((12,(10,(8,((15,6),11)))),((14,((7,13),4)),((2,9),(5,3))),1);
+   tree rep.9980000 = (12,(((14,((((6,15),11),(8,10)),((2,9),3))),5),(4,(13,7))),1);
+   tree rep.9990000 = (((10,(8,((11,15),6))),((13,7),(14,((4,(3,(9,2))),5)))),12,1);
+   tree rep.10000000 = (12,((((5,14),4),((13,7),(8,(10,((15,11),6))))),((3,2),9)),1);
+end;
diff --git a/inst/extdata/trees/woodmouse.mrbayes.nex.run2.t b/inst/extdata/trees/woodmouse.mrbayes.nex.run2.t
new file mode 100644
index 0000000..59675fc
--- /dev/null
+++ b/inst/extdata/trees/woodmouse.mrbayes.nex.run2.t
@@ -0,0 +1,1021 @@
+#NEXUS
+[ID: 2542150086]
+begin trees;
+   translate
+       1 No305,
+       2 No304,
+       3 No306,
+       4 No0906S,
+       5 No0908S,
+       6 No0909S,
+       7 No0910S,
+       8 No0912S,
+       9 No0913S,
+      10 No1103S,
+      11 No1007S,
+      12 No1114S,
+      13 No1202S,
+      14 No1206S,
+      15 No1208S;
+   tree rep.1 = ((((3,(((4,(8,(15,5))),2),((14,11),12))),(9,13)),7),(10,6),1);
+   tree rep.10000 = (12,(((8,((15,6),11)),10),((((2,9),3),(14,((7,13),4))),5)),1);
+   tree rep.20000 = (12,((8,((6,(11,15)),10)),(((14,((13,7),5)),4),((9,2),3))),1);
+   tree rep.30000 = (12,(((3,(9,2)),(5,((14,4),(7,13)))),((8,10),((6,15),11))),1);
+   tree rep.40000 = ((((12,5),((2,9),3)),(14,((7,13),4))),((8,((11,15),6)),10),1);
+   tree rep.50000 = (((((11,(6,15)),(8,10)),((4,((13,7),14)),5)),((2,9),3)),12,1);
+   tree rep.60000 = ((10,(8,(((4,(((9,2),3),((7,13),14))),5),(11,(15,6))))),12,1);
+   tree rep.70000 = (12,((10,(((11,15),6),8)),((((13,7),4),(5,14)),((9,2),3))),1);
+   tree rep.80000 = (12,(((3,(9,2)),(((7,13),4),(14,5))),((8,(11,(15,6))),10)),1);
+   tree rep.90000 = (((((((13,7),4),5),((2,9),3)),14),((10,8),((11,15),6))),12,1);
+   tree rep.100000 = (12,((10,8),(((9,2),((13,7),4)),(((5,14),(6,(11,15))),3))),1);
+   tree rep.110000 = (12,((((7,13),4),(14,(5,((9,2),3)))),(10,(8,(11,(6,15))))),1);
+   tree rep.120000 = (((10,(8,((6,15),11))),((5,(3,(2,9))),(14,(4,(13,7))))),12,1);
+   tree rep.130000 = (((((4,((7,13),14)),5),(3,(2,9))),(8,(10,((15,6),11)))),12,1);
+   tree rep.140000 = ((((10,8),((15,11),6)),((((7,13),(4,14)),5),(3,(2,9)))),12,1);
+   tree rep.150000 = ((((5,(((9,2),3),14)),((7,13),4)),12),((8,10),((15,11),6)),1);
+   tree rep.160000 = (((((11,(6,15)),10),8),((5,(((7,13),4),14)),((9,2),3))),12,1);
+   tree rep.170000 = (12,((((10,8),((15,6),11)),4),((((9,2),3),5),(14,(7,13)))),1);
+   tree rep.180000 = ((((3,(9,2)),(5,(4,(14,(13,7))))),((8,((15,11),6)),10)),12,1);
+   tree rep.190000 = (12,(((((9,2),3),5),((14,4),(13,7))),((((6,15),11),8),10)),1);
+   tree rep.200000 = (12,((14,((5,(7,13)),(((((11,6),15),10),8),4))),((9,2),3)),1);
+   tree rep.210000 = ((((5,(3,(9,2))),(((13,4),7),14)),((8,10),((15,11),6))),12,1);
+   tree rep.220000 = (12,(((((13,7),14),4),5),(((9,2),3),((11,(6,15)),(8,10)))),1);
+   tree rep.230000 = (12,(((6,15),11),(((5,((13,(4,7)),(3,(9,2)))),14),(8,10))),1);
+   tree rep.240000 = ((((13,7),(((11,(6,15)),(8,10)),((5,4),14))),((2,9),3)),12,1);
+   tree rep.250000 = (((4,(13,7)),((5,14),((2,9),3))),(((10,8),((11,15),6)),12),1);
+   tree rep.260000 = ((((((4,(13,7)),14),(3,(2,9))),5),(8,(((15,11),6),10))),12,1);
+   tree rep.270000 = (12,((8,(10,((11,15),6))),(3,((13,7),(((9,2),5),(4,14))))),1);
+   tree rep.280000 = (((((9,2),3),(5,((7,13),(14,4)))),(((11,15),6),(8,10))),12,1);
+   tree rep.290000 = ((((((7,13),14),4),((3,(2,9)),5)),((10,8),(11,(15,6)))),12,1);
+   tree rep.300000 = ((((((8,(6,(11,15))),10),5),((9,2),3)),(((13,7),14),4)),12,1);
+   tree rep.310000 = (12,(((((2,9),3),5),(((13,7),14),4)),(8,((11,(15,6)),10))),1);
+   tree rep.320000 = (12,((10,((6,(15,11)),8)),((5,((4,(13,7)),14)),((2,9),3))),1);
+   tree rep.330000 = (12,(((8,10),((6,15),11)),(((13,7),(4,(5,14))),((2,9),3))),1);
+   tree rep.340000 = ((((((11,15),6),((((2,9),3),5),(4,((13,7),14)))),10),8),12,1);
+   tree rep.350000 = (12,((8,(((15,6),11),10)),((((9,2),3),5),(14,(4,(7,13))))),1);
+   tree rep.360000 = ((((((11,15),6),8),10),((5,((9,2),3)),((7,13),(14,4)))),12,1);
+   tree rep.370000 = ((((((11,15),6),(8,10)),(3,(5,(9,2)))),((4,(7,13)),14)),12,1);
+   tree rep.380000 = ((((((14,(7,13)),4),(3,(9,2))),5),(((6,15),11),(10,8))),12,1);
+   tree rep.390000 = (12,((14,((((9,2),3),((13,7),4)),5)),(((11,(6,15)),8),10)),1);
+   tree rep.400000 = (12,((5,((14,((7,13),4)),(3,(9,2)))),(10,((6,(15,11)),8))),1);
+   tree rep.410000 = (((10,((6,(15,11)),8)),(((3,(9,2)),5),(((7,13),14),4))),12,1);
+   tree rep.420000 = (12,((5,((7,13),((14,4),((9,2),3)))),((11,(15,6)),(10,8))),1);
+   tree rep.430000 = ((((7,13),5),((((9,2),3),4),14)),((10,(8,(6,(11,15)))),12),1);
+   tree rep.440000 = (12,(((4,(14,(13,7))),(5,(3,(9,2)))),((8,((15,11),6)),10)),1);
+   tree rep.450000 = (((((9,2),3),((((7,13),4),14),5)),((8,10),((11,15),6))),12,1);
+   tree rep.460000 = (12,((((15,11),6),(10,8)),((4,((9,2),((3,5),(13,7)))),14)),1);
+   tree rep.470000 = (12,((8,((6,(11,15)),10)),(5,((3,(9,2)),((7,(13,4)),14)))),1);
+   tree rep.480000 = (12,(((5,((9,2),3)),((11,(15,6)),(8,10))),(((7,13),14),4)),1);
+   tree rep.490000 = (12,(((((13,7),4),(5,14)),(3,(9,2))),(((6,15),11),(8,10))),1);
+   tree rep.500000 = (((((13,7),4),(14,5)),(12,((9,2),3))),((8,((11,15),6)),10),1);
+   tree rep.510000 = ((((8,10),(6,(15,11))),((7,13),(((9,2),3),(5,(14,4))))),12,1);
+   tree rep.520000 = (12,((((((9,2),3),((5,14),(13,(7,4)))),(6,(15,11))),8),10),1);
+   tree rep.530000 = (12,((5,(((2,9),3),((13,7),(4,14)))),((10,8),(11,(6,15)))),1);
+   tree rep.540000 = ((((((15,6),11),8),10),((((7,13),4),(14,5)),(3,(2,9)))),12,1);
+   tree rep.550000 = ((((12,(9,2)),(4,(13,7))),((14,5),3)),(((15,6),11),(10,8)),1);
+   tree rep.560000 = (12,((((7,13),((9,2),3)),(4,(14,5))),((10,8),((6,15),11))),1);
+   tree rep.570000 = (12,((((5,14),(4,(7,13))),((2,9),3)),((6,(15,11)),(8,10))),1);
+   tree rep.580000 = (12,(((8,10),((6,15),11)),(((13,4),7),(((2,9),3),(14,5)))),1);
+   tree rep.590000 = ((5,(3,(9,2))),((12,(10,(8,(6,(11,15))))),((4,14),(7,13))),1);
+   tree rep.600000 = (12,(((8,(15,(6,11))),10),(((9,2),3),(((7,13),(5,14)),4))),1);
+   tree rep.610000 = (12,(((3,(2,9)),(5,((4,7),(14,13)))),(8,(((15,6),11),10))),1);
+   tree rep.620000 = (((((6,(11,15)),8),10),(((14,((7,13),4)),5),((2,9),3))),12,1);
+   tree rep.630000 = (((((2,9),3),(5,(14,((7,13),4)))),(((11,(15,6)),10),8)),12,1);
+   tree rep.640000 = (12,(((((9,2),3),(13,(7,4))),(14,5)),(10,(8,((6,15),11)))),1);
+   tree rep.650000 = (12,((8,(((15,11),6),10)),(((3,(9,2)),(4,(7,13))),(14,5))),1);
+   tree rep.660000 = ((((3,(2,9)),(((13,(7,4)),14),5)),(((15,11),6),(8,10))),12,1);
+   tree rep.670000 = ((((11,(15,6)),(8,10)),(((14,(7,13)),4),(5,(3,(2,9))))),12,1);
+   tree rep.680000 = (((((11,15),6),(8,10)),(((4,(14,(7,13))),5),(3,(9,2)))),12,1);
+   tree rep.690000 = (12,(((8,10),((11,6),15)),((3,(9,2)),((14,4),(5,(7,13))))),1);
+   tree rep.700000 = (((((5,(7,13)),14),(((2,9),3),4)),((6,(11,15)),(8,10))),12,1);
+   tree rep.710000 = (12,(((10,8),(11,(6,15))),((((14,(7,13)),4),(3,(9,2))),5)),1);
+   tree rep.720000 = (12,((5,((3,(9,2)),((4,14),(7,13)))),(8,(10,(11,(6,15))))),1);
+   tree rep.730000 = ((((13,7),((3,(9,2)),(((15,6),11),(10,8)))),((14,5),4)),12,1);
+   tree rep.740000 = (12,((8,(10,((15,6),11))),((3,(9,2)),(4,((7,13),(14,5))))),1);
+   tree rep.750000 = (((5,((((8,10),((11,15),6)),12),((2,9),3))),((7,13),4)),14,1);
+   tree rep.760000 = (12,(((14,4),5),((((8,10),(11,(6,15))),(3,(2,9))),(13,7))),1);
+   tree rep.770000 = ((((14,(7,13)),4),(((((11,6),15),(8,10)),((2,9),3)),5)),12,1);
+   tree rep.780000 = (((((3,(2,9)),((8,10),((11,15),6))),(14,5)),(4,(13,7))),12,1);
+   tree rep.790000 = (((((4,(13,7)),14),(5,(3,(9,2)))),((10,8),(6,(11,15)))),12,1);
+   tree rep.800000 = (12,(8,((10,(((14,(4,(7,13))),5),((9,2),3))),(11,(6,15)))),1);
+   tree rep.810000 = (12,(((10,((6,15),11)),8),(14,(((4,(13,7)),(3,(2,9))),5))),1);
+   tree rep.820000 = ((((5,(14,((13,7),4))),(3,(2,9))),((10,8),(11,(15,6)))),12,1);
+   tree rep.830000 = ((4,(13,7)),((14,((((2,9),12),3),(((6,15),11),(8,10)))),5),1);
+   tree rep.840000 = ((((10,8),(6,(11,15))),((14,((7,13),4)),(5,(3,(2,9))))),12,1);
+   tree rep.850000 = (((8,(10,((15,11),6))),((((9,2),3),14),(((13,7),4),5))),12,1);
+   tree rep.860000 = (12,((((6,(11,15)),8),10),((4,(7,13)),((14,5),((9,2),3)))),1);
+   tree rep.870000 = (12,(((4,(7,13)),(((9,2),3),(14,5))),(8,(((15,6),11),10))),1);
+   tree rep.880000 = (12,(((3,(9,2)),(((4,13),7),(5,14))),((((11,6),15),8),10)),1);
+   tree rep.890000 = (((2,9),((5,(((13,7),14),4)),3)),(12,((11,(15,6)),(10,8))),1);
+   tree rep.900000 = (12,(8,((((3,(9,2)),(5,((4,(13,7)),14))),((15,11),6)),10)),1);
+   tree rep.910000 = ((12,5),(((((7,13),4),((((15,11),6),8),10)),((2,9),3)),14),1);
+   tree rep.920000 = (((((9,2),3),((14,(4,(13,7))),5)),((11,(6,15)),(8,10))),12,1);
+   tree rep.930000 = (((8,((6,(15,11)),10)),(((14,(5,4)),(7,13)),((9,2),3))),12,1);
+   tree rep.940000 = ((((10,8),((15,11),6)),((7,13),(14,(((2,(9,3)),4),5)))),12,1);
+   tree rep.950000 = (((5,(3,(2,9))),(14,((4,7),13))),(12,(8,(10,(6,(15,11))))),1);
+   tree rep.960000 = (((((((6,15),11),8),10),5),(4,((3,(9,2)),(14,(13,7))))),12,1);
+   tree rep.970000 = ((((10,((11,15),6)),8),(((3,(2,9)),((14,4),(7,13))),5)),12,1);
+   tree rep.980000 = (12,((3,(2,9)),((((8,((15,11),6)),10),5),((4,(13,7)),14))),1);
+   tree rep.990000 = (12,(((14,((7,13),4)),(((9,2),3),5)),((10,((6,15),11)),8)),1);
+   tree rep.1000000 = ((((6,(11,15)),8),(10,((((9,2),3),((7,13),4)),(14,5)))),12,1);
+   tree rep.1010000 = ((((10,(11,(15,6))),8),(5,(((2,9),3),(((13,7),4),14)))),12,1);
+   tree rep.1020000 = ((((10,(11,(6,15))),8),((5,(14,(4,(13,7)))),((9,2),3))),12,1);
+   tree rep.1030000 = ((((5,(4,(3,(9,2)))),(14,(7,13))),(8,((11,(15,6)),10))),12,1);
+   tree rep.1040000 = ((((((11,15),6),8),10),(4,((14,(5,(3,(9,2)))),(13,7)))),12,1);
+   tree rep.1050000 = (12,((5,(14,4)),((((9,2),3),(13,7)),(10,(8,((11,6),15))))),1);
+   tree rep.1060000 = (((((4,(7,13)),(5,14)),(3,(9,2))),((10,8),((15,6),11))),12,1);
+   tree rep.1070000 = ((((10,(11,(15,6))),8),((((9,2),14),((13,5),7)),(4,3))),12,1);
+   tree rep.1080000 = ((((10,8),(11,(15,6))),(((2,3),5),(14,((9,4),(13,7))))),12,1);
+   tree rep.1090000 = (12,((8,(((6,11),15),10)),(((4,5),(14,(13,7))),(3,(2,9)))),1);
+   tree rep.1100000 = (((11,(6,15)),((4,(((7,13),(14,5)),(3,(9,2)))),(8,10))),12,1);
+   tree rep.1110000 = ((((((4,13),7),14),5),(3,(9,2))),(12,(10,(8,(6,(15,11))))),1);
+   tree rep.1120000 = ((((((13,7),14),4),(5,((9,2),3))),((10,(15,(6,11))),8)),12,1);
+   tree rep.1130000 = (12,((10,(8,((15,11),6))),(5,(((9,2),3),(14,(4,(7,13)))))),1);
+   tree rep.1140000 = (12,(((4,((6,(11,15)),(8,10))),14),(((2,9),3),((7,13),5))),1);
+   tree rep.1150000 = (12,((((6,(11,15)),8),10),((5,((2,9),3)),((7,13),(4,14)))),1);
+   tree rep.1160000 = (12,((((3,(2,9)),((7,13),4)),(5,14)),(8,(((15,11),6),10))),1);
+   tree rep.1170000 = ((((3,(2,9)),(((7,13),14),4)),5),((10,8),((11,(6,15)),12)),1);
+   tree rep.1180000 = (((5,14),(((7,13),4),(3,(2,9)))),(12,((8,((15,11),6)),10)),1);
+   tree rep.1190000 = (((7,13),(4,(14,(5,(3,(9,2)))))),((((15,6),11),(10,8)),12),1);
+   tree rep.1200000 = ((((10,(11,(6,15))),8),(((13,7),4),(((9,2),3),(14,5)))),12,1);
+   tree rep.1210000 = ((((8,((6,15),11)),10),(((3,5),(2,9)),((14,4),(7,13)))),12,1);
+   tree rep.1220000 = (((((15,(6,11)),8),10),(((5,((9,2),3)),14),(4,(13,7)))),12,1);
+   tree rep.1230000 = (12,((4,((((2,9),3),((13,7),14)),5)),((10,(15,(11,6))),8)),1);
+   tree rep.1240000 = (12,(((10,8),(6,(11,15))),((5,((2,9),3)),((13,7),(14,4)))),1);
+   tree rep.1250000 = ((12,(3,(9,2))),(((10,8),((15,6),11)),(5,((14,4),(7,13)))),1);
+   tree rep.1260000 = (((14,(7,13)),(4,(((9,2),3),5))),(12,(10,(((15,6),11),8))),1);
+   tree rep.1270000 = (12,(((15,6),11),(10,(8,((((9,2),3),(14,(4,(13,7)))),5)))),1);
+   tree rep.1280000 = ((((10,8),((15,11),6)),(((5,14),(4,(7,13))),(3,(9,2)))),12,1);
+   tree rep.1290000 = (((14,5),(((3,(2,9)),(((10,8),(11,(15,6))),(7,13))),4)),12,1);
+   tree rep.1300000 = (12,((((10,(6,(15,11))),8),5),(((7,13),(14,4)),(3,(2,9)))),1);
+   tree rep.1310000 = (((((15,11),6),(((7,13),(14,4)),(((9,2),3),5))),(10,8)),12,1);
+   tree rep.1320000 = (12,(((14,5),((4,(7,13)),(3,(9,2)))),((6,(15,11)),(8,10))),1);
+   tree rep.1330000 = ((((3,(2,9)),((13,7),14)),(4,5)),((8,(10,(6,(15,11)))),12),1);
+   tree rep.1340000 = ((((10,8),((6,15),11)),((5,(3,(2,9))),(((13,7),4),14))),12,1);
+   tree rep.1350000 = (((((14,(7,4)),13),(((9,2),3),5)),((10,(11,(6,15))),8)),12,1);
+   tree rep.1360000 = (12,((((15,11),6),(8,10)),((7,13),((4,14),(((2,9),3),5)))),1);
+   tree rep.1370000 = (12,((((5,(14,(13,(7,4)))),3),(2,9)),(10,((15,(11,6)),8))),1);
+   tree rep.1380000 = ((8,((11,(15,6)),10)),((12,(14,((7,13),4))),(5,((2,9),3))),1);
+   tree rep.1390000 = ((((3,(2,9)),(4,((7,13),14))),5),(((((6,15),11),8),10),12),1);
+   tree rep.1400000 = ((((13,7),((5,(2,9)),(4,((10,(6,(11,15))),8)))),(14,3)),12,1);
+   tree rep.1410000 = ((((6,(11,15)),(8,10)),(((3,(9,2)),((14,5),(13,7))),4)),12,1);
+   tree rep.1420000 = (12,((((13,7),4),5),(((((11,15),6),(8,10)),((9,2),3)),14)),1);
+   tree rep.1430000 = (12,(((6,(11,15)),(8,10)),(((13,7),((14,5),4)),(3,(9,2)))),1);
+   tree rep.1440000 = (((((3,(9,2)),5),(14,(4,(13,7)))),(8,(10,((15,6),11)))),12,1);
+   tree rep.1450000 = (12,(((5,(((13,7),4),14)),(3,(9,2))),((8,((15,6),11)),10)),1);
+   tree rep.1460000 = (((11,(6,15)),((10,8),(((5,14),((9,2),3)),((13,7),4)))),12,1);
+   tree rep.1470000 = ((((11,(15,6)),(((14,5),((13,7),4)),(10,8))),12),(3,(9,2)),1);
+   tree rep.1480000 = (((12,(8,(((15,11),6),10))),((2,9),3)),(((4,(7,13)),5),14),1);
+   tree rep.1490000 = (((10,((6,(15,11)),8)),((5,((2,9),3)),(14,((7,13),4)))),12,1);
+   tree rep.1500000 = (12,((5,(14,((3,(9,2)),(13,(4,7))))),((8,(6,(11,15))),10)),1);
+   tree rep.1510000 = (12,(((5,((9,2),3)),(4,((7,13),14))),((10,8),(6,(15,11)))),1);
+   tree rep.1520000 = (12,((((14,(3,(9,2))),(5,((13,7),4))),(10,8)),((15,6),11)),1);
+   tree rep.1530000 = (12,(((8,10),((11,15),6)),(((3,(9,2)),5),(((13,7),4),14))),1);
+   tree rep.1540000 = ((((11,(15,6)),(10,8)),((((13,7),4),(14,5)),(3,(9,2)))),12,1);
+   tree rep.1550000 = (12,((((8,(10,(11,(15,6)))),(5,14)),((3,9),2)),((13,7),4)),1);
+   tree rep.1560000 = (((((3,(2,9)),((13,7),(14,5))),4),((11,(6,15)),(10,8))),12,1);
+   tree rep.1570000 = (12,((6,(15,11)),((10,(4,(((3,(2,9)),(14,(13,7))),5))),8)),1);
+   tree rep.1580000 = (12,((((2,9),3),(5,((14,4),(7,13)))),(10,(((15,6),11),8))),1);
+   tree rep.1590000 = ((((10,8),((11,15),6)),((4,5),((3,(9,2)),((7,13),14)))),12,1);
+   tree rep.1600000 = (12,((10,8),((14,((3,(9,2)),(((13,7),4),5))),((11,15),6))),1);
+   tree rep.1610000 = ((((5,(((13,7),4),14)),((2,9),3)),(10,(8,(6,(15,11))))),12,1);
+   tree rep.1620000 = ((12,((3,(2,9)),(((14,4),5),(7,13)))),(((6,(11,15)),8),10),1);
+   tree rep.1630000 = (12,((4,((14,(5,(7,13))),(3,(2,9)))),((8,10),((15,11),6))),1);
+   tree rep.1640000 = (12,((((10,8),(11,(15,6))),((3,(9,2)),((14,4),(7,13)))),5),1);
+   tree rep.1650000 = (((((6,15),11),(10,8)),(((3,(9,2)),5),((7,13),(14,4)))),12,1);
+   tree rep.1660000 = (((((11,15),6),10),8),(12,(14,(((7,13),(3,(2,9))),(5,4)))),1);
+   tree rep.1670000 = (((((2,9),3),((((13,7),4),14),5)),(((6,15),11),(10,8))),12,1);
+   tree rep.1680000 = (((10,(8,(11,(15,6)))),(5,((((7,13),4),14),(3,(9,2))))),12,1);
+   tree rep.1690000 = ((((3,(9,2)),5),(4,(14,(7,13)))),(12,((11,(15,6)),(8,10))),1);
+   tree rep.1700000 = (((((13,7),(4,14)),((9,2),3)),(12,(((6,15),11),(10,8)))),5,1);
+   tree rep.1710000 = (((((14,((7,13),(5,3))),4),(9,2)),((10,((15,6),11)),8)),12,1);
+   tree rep.1720000 = (12,(((((13,7),4),(5,14)),((9,2),3)),((10,8),((15,11),6))),1);
+   tree rep.1730000 = (((((6,(11,15)),10),8),(((2,9),3),((14,(5,(13,7))),4))),12,1);
+   tree rep.1740000 = (((((9,2),3),(14,5)),((13,7),4)),(((8,10),((11,15),6)),12),1);
+   tree rep.1750000 = (((8,(11,(15,6))),10),(((3,(9,2)),12),(((4,(7,13)),14),5)),1);
+   tree rep.1760000 = (((((13,7),4),(14,((3,(2,9)),5))),12),(8,(10,(6,(15,11)))),1);
+   tree rep.1770000 = (((10,8),(11,(15,6))),(((13,7),4),((5,14),(12,((2,9),3)))),1);
+   tree rep.1780000 = ((12,((5,(14,((13,7),((2,9),3)))),4)),(((6,15),11),(8,10)),1);
+   tree rep.1790000 = (12,((6,(11,15)),(((((9,2),3),4),((13,7),(14,5))),(10,8))),1);
+   tree rep.1800000 = ((((3,((13,7),(14,4))),5),(9,2)),(12,((15,(6,11)),(8,10))),1);
+   tree rep.1810000 = (12,((((15,6),11),(8,10)),(((5,(3,(2,9))),(4,(13,7))),14)),1);
+   tree rep.1820000 = (((((((15,11),6),(10,8)),((9,2),3)),5),(((13,7),4),14)),12,1);
+   tree rep.1830000 = ((((10,8),((6,15),11)),((5,(((13,7),4),14)),(3,(9,2)))),12,1);
+   tree rep.1840000 = (((12,(11,(15,6))),(8,10)),((((9,2),3),(7,13)),((14,4),5)),1);
+   tree rep.1850000 = ((10,((((14,(((7,13),5),4)),((2,9),3)),((6,15),11)),8)),12,1);
+   tree rep.1860000 = (((((4,(13,7)),((2,9),3)),(5,14)),((10,8),((15,6),11))),12,1);
+   tree rep.1870000 = (((10,(8,((6,15),11))),((5,(3,(9,2))),((4,14),(7,13)))),12,1);
+   tree rep.1880000 = (12,((10,(((15,6),11),8)),((7,13),(((4,5),14),((9,2),3)))),1);
+   tree rep.1890000 = ((((3,(2,9)),((14,5),((7,13),4))),12),(10,(((11,15),6),8)),1);
+   tree rep.1900000 = (((8,10),(6,(15,11))),(12,(((3,(2,9)),5),(14,(4,(7,13))))),1);
+   tree rep.1910000 = ((((14,(((13,7),4),(9,2))),(5,3)),(((6,(11,15)),10),8)),12,1);
+   tree rep.1920000 = (12,((3,(9,2)),((((13,7),5),(4,14)),(8,(10,((6,15),11))))),1);
+   tree rep.1930000 = (((((5,(4,(7,13))),14),((9,2),3)),((10,8),(11,(6,15)))),12,1);
+   tree rep.1940000 = (12,((13,(4,(((9,2),3),(7,(14,5))))),((10,8),((15,11),6))),1);
+   tree rep.1950000 = (((8,10),(11,(6,15))),((((((13,7),4),3),((9,2),14)),5),12),1);
+   tree rep.1960000 = ((((14,((13,7),4)),(((2,9),3),5)),((10,8),((6,15),11))),12,1);
+   tree rep.1970000 = ((12,((10,8),(6,(15,11)))),((14,5),(((9,2),3),(4,(7,13)))),1);
+   tree rep.1980000 = (12,(((((15,11),6),8),10),(5,(((9,2),3),((13,7),(4,14))))),1);
+   tree rep.1990000 = (12,(((((2,9),3),(5,(14,(4,(7,13))))),(10,8)),((11,15),6)),1);
+   tree rep.2000000 = (12,((((7,13),3),(14,(((9,2),5),4))),((10,8),((6,11),15))),1);
+   tree rep.2010000 = (12,((((15,6),11),(8,10)),((5,(((4,7),13),14)),(3,(9,2)))),1);
+   tree rep.2020000 = ((14,(((9,2),3),((4,(13,7)),5))),(12,(8,(10,(11,(15,6))))),1);
+   tree rep.2030000 = (((((3,(9,2)),((7,4),13)),(14,5)),((10,8),(11,(15,6)))),12,1);
+   tree rep.2040000 = ((5,((3,(9,2)),((((6,(11,15)),8),10),(((7,13),4),14)))),12,1);
+   tree rep.2050000 = ((12,(5,(((9,2),3),(14,((13,7),4))))),((10,((11,15),6)),8),1);
+   tree rep.2060000 = ((((((11,15),6),8),10),12),((4,((14,5),(7,13))),(3,(9,2))),1);
+   tree rep.2070000 = (((14,(5,(((9,2),3),((7,13),4)))),(((15,6),11),(10,8))),12,1);
+   tree rep.2080000 = (((((9,2),3),(((7,13),4),14)),(5,((8,(11,(15,6))),10))),12,1);
+   tree rep.2090000 = (12,(((11,(6,15)),(10,8)),(((4,14),(13,7)),(((2,9),3),5))),1);
+   tree rep.2100000 = ((((((15,6),11),8),10),((3,(2,9)),((14,(4,(13,7))),5))),12,1);
+   tree rep.2110000 = (12,(((14,(((2,9),3),5)),((7,13),4)),(10,(8,((15,6),11)))),1);
+   tree rep.2120000 = (12,((8,(((15,6),11),10)),((14,(4,(13,7))),(((9,2),3),5))),1);
+   tree rep.2130000 = ((((((15,11),6),8),10),(((5,14),((2,9),3)),(4,(7,13)))),12,1);
+   tree rep.2140000 = (((6,(15,11)),(10,8)),(((5,(3,(2,9))),(14,((13,7),4))),12),1);
+   tree rep.2150000 = (12,(((8,10),((6,15),11)),((5,14),(((2,9),3),(4,(13,7))))),1);
+   tree rep.2160000 = (12,((((9,2),3),((14,(5,4)),(7,13))),(8,(10,(11,(6,15))))),1);
+   tree rep.2170000 = (((11,(15,6)),(10,8)),(((((13,7),(14,4)),(3,(9,2))),5),12),1);
+   tree rep.2180000 = ((((6,(15,11)),(8,10)),(((14,5),(4,(3,(9,2)))),(13,7))),12,1);
+   tree rep.2190000 = (12,((5,((14,((7,13),4)),((2,9),3))),((8,10),((15,6),11))),1);
+   tree rep.2200000 = ((((((14,5),3),4),((13,7),(2,9))),(((15,6),11),(8,10))),12,1);
+   tree rep.2210000 = ((((((((7,13),4),((2,9),3)),(14,5)),((11,15),6)),10),8),12,1);
+   tree rep.2220000 = (((8,((6,(11,15)),10)),(((13,7),4),((14,5),(3,(9,2))))),12,1);
+   tree rep.2230000 = (12,(((8,10),((4,(7,13)),((5,14),((9,2),3)))),(11,(15,6))),1);
+   tree rep.2240000 = (((((5,(7,13)),14),(4,((2,9),3))),(10,((6,(11,15)),8))),12,1);
+   tree rep.2250000 = (((((15,6),11),(10,8)),((5,(3,(9,2))),((7,13),(4,14)))),12,1);
+   tree rep.2260000 = (12,(((5,(14,(7,13))),(4,((2,9),3))),(10,(8,((6,15),11)))),1);
+   tree rep.2270000 = (((((14,(13,7)),(4,5)),((2,9),3)),(8,((11,(6,15)),10))),12,1);
+   tree rep.2280000 = ((((10,((6,15),11)),8),(((14,(7,13)),4),(5,((9,2),3)))),12,1);
+   tree rep.2290000 = ((((8,10),(14,(((9,2),3),(5,((7,13),4))))),12),(11,(15,6)),1);
+   tree rep.2300000 = (((((11,6),15),(8,10)),(((9,2),3),(5,(14,(4,(7,13)))))),12,1);
+   tree rep.2310000 = (12,(5,(((4,(7,13)),14),(((2,9),3),(((15,6),11),(10,8))))),1);
+   tree rep.2320000 = (12,(((4,14),((2,9),3)),(((8,(((6,15),11),10)),(13,7)),5)),1);
+   tree rep.2330000 = ((((10,8),(11,(15,6))),(((14,5),(((7,13),4),(2,9))),3)),12,1);
+   tree rep.2340000 = ((((5,(7,13)),((3,(2,9)),(4,14))),12),(10,(((11,15),6),8)),1);
+   tree rep.2350000 = ((((((9,2),3),((4,14),(7,13))),5),(10,(8,(11,(15,6))))),12,1);
+   tree rep.2360000 = (((5,(((4,(7,13)),14),((9,2),3))),((6,(15,11)),(10,8))),12,1);
+   tree rep.2370000 = (12,((((11,15),6),(8,10)),(((7,13),((4,((9,2),3)),5)),14)),1);
+   tree rep.2380000 = ((8,(10,(15,(6,11)))),(12,((3,(9,2)),(14,((4,(7,13)),5)))),1);
+   tree rep.2390000 = (((((14,5),(3,(9,2))),(4,(7,13))),((10,8),((15,6),11))),12,1);
+   tree rep.2400000 = (12,(((6,(11,15)),(10,8)),(((4,(14,(13,7))),5),((2,9),3))),1);
+   tree rep.2410000 = (((((3,(2,9)),5),((7,13),(14,4))),(((11,(6,15)),8),10)),12,1);
+   tree rep.2420000 = ((5,(((13,7),(14,4)),(3,(9,2)))),(((10,8),(6,(11,15))),12),1);
+   tree rep.2430000 = ((((6,(11,15)),10),8),((5,12),((3,(9,2)),((13,7),(14,4)))),1);
+   tree rep.2440000 = (12,((((8,10),(6,(11,15))),((9,2),3)),((7,13),((5,14),4))),1);
+   tree rep.2450000 = ((12,((8,(10,(6,(15,11)))),(14,((7,13),(4,5))))),((2,9),3),1);
+   tree rep.2460000 = (12,((5,(((13,7),14),((10,8),((6,15),11)))),(((9,2),3),4)),1);
+   tree rep.2470000 = ((((10,8),(6,(15,11))),((4,(13,7)),((3,(9,2)),(5,14)))),12,1);
+   tree rep.2480000 = (12,((((4,(7,13)),((8,10),(6,(15,11)))),((9,2),3)),(5,14)),1);
+   tree rep.2490000 = ((((7,13),(14,(4,(((9,2),3),5)))),(8,((6,(15,11)),10))),12,1);
+   tree rep.2500000 = ((((((9,2),3),((13,7),5)),(14,4)),((10,(6,(15,11))),8)),12,1);
+   tree rep.2510000 = ((12,(((2,(3,9)),5),(((7,13),4),14))),(8,(10,(6,(11,15)))),1);
+   tree rep.2520000 = (12,(((11,(15,6)),(10,8)),((14,(((13,7),4),(3,(2,9)))),5)),1);
+   tree rep.2530000 = ((((11,(15,6)),8),10),(12,(5,(((14,(13,7)),4),((2,9),3)))),1);
+   tree rep.2540000 = ((((11,(6,15)),(8,10)),((5,((9,2),3)),(((13,7),14),4))),12,1);
+   tree rep.2550000 = (12,(((10,8),(6,(11,15))),((5,(14,((7,13),4))),(3,(2,9)))),1);
+   tree rep.2560000 = (12,(((14,(4,(13,7))),((5,3),(9,2))),((6,(11,15)),(10,8))),1);
+   tree rep.2570000 = (((11,(15,6)),(10,8)),(12,((14,5),((4,(7,13)),((2,9),3)))),1);
+   tree rep.2580000 = (12,((((3,(2,9)),5),(4,(14,(7,13)))),(((11,(15,6)),8),10)),1);
+   tree rep.2590000 = (((10,((11,15),6)),8),(((5,(3,(9,2))),((14,4),(13,7))),12),1);
+   tree rep.2600000 = ((((5,((14,((13,7),4)),3)),(2,9)),(((11,(6,15)),8),10)),12,1);
+   tree rep.2610000 = (((8,(((15,6),11),10)),12),(((14,5),(3,(9,2))),(4,(7,13))),1);
+   tree rep.2620000 = (((11,(6,15)),(10,8)),(((((7,13),(14,5)),4),(3,(9,2))),12),1);
+   tree rep.2630000 = (12,(5,((((4,14),(13,7)),((9,2),3)),((8,10),((6,15),11)))),1);
+   tree rep.2640000 = (12,(((5,14),((4,(7,13)),(3,(9,2)))),(10,((6,(11,15)),8))),1);
+   tree rep.2650000 = (12,((5,(((14,(13,7)),4),((9,2),3))),(10,(8,(11,(15,6))))),1);
+   tree rep.2660000 = (12,((7,(((13,14),(5,(3,(9,2)))),4)),(10,(8,((11,15),6)))),1);
+   tree rep.2670000 = ((8,10),((6,(11,15)),(((5,((9,2),3)),(((7,13),14),4)),12)),1);
+   tree rep.2680000 = ((((5,((7,13),((2,9),3))),(4,14)),((15,(11,6)),(8,10))),12,1);
+   tree rep.2690000 = (12,(((10,(6,(15,11))),8),(((((7,13),4),14),5),((9,2),3))),1);
+   tree rep.2700000 = ((((8,10),((6,15),11)),((5,((3,(9,2)),14)),((7,13),4))),12,1);
+   tree rep.2710000 = (((4,((13,7),14)),(((2,9),3),5)),(((10,8),(11,(15,6))),12),1);
+   tree rep.2720000 = (((5,(((4,(13,7)),(3,(2,9))),14)),((8,((15,11),6)),10)),12,1);
+   tree rep.2730000 = (((((13,7),4),(5,(14,(3,(9,2))))),((10,8),((15,11),6))),12,1);
+   tree rep.2740000 = (12,(((8,10),(6,(11,15))),(5,((((7,13),14),4),((9,2),3)))),1);
+   tree rep.2750000 = (((((13,7),(14,4)),((3,(9,2)),5)),((8,((15,6),11)),10)),12,1);
+   tree rep.2760000 = ((((((13,7),(2,9)),3),((4,14),5)),((11,(6,15)),(8,10))),12,1);
+   tree rep.2770000 = ((((14,(3,(2,9))),(5,(4,(13,7)))),((10,8),(11,(15,6)))),12,1);
+   tree rep.2780000 = (12,((((5,14),(((2,9),3),4)),(13,7)),(((11,15),6),(8,10))),1);
+   tree rep.2790000 = (12,(((13,7),4),(((14,5),((2,9),3)),((10,((15,6),11)),8))),1);
+   tree rep.2800000 = ((((8,((6,15),11)),10),((((2,(3,9)),((7,13),14)),4),5)),12,1);
+   tree rep.2810000 = ((((5,(3,(9,2))),(14,(4,(7,13)))),(((11,(6,15)),10),8)),12,1);
+   tree rep.2820000 = (12,(((10,((11,15),6)),8),((4,((13,7),14)),((3,(9,2)),5))),1);
+   tree rep.2830000 = ((12,((11,(6,15)),(8,10))),(((9,2),3),(5,((14,4),(7,13)))),1);
+   tree rep.2840000 = ((10,(8,((11,15),6))),((5,(14,(((7,13),4),(3,(9,2))))),12),1);
+   tree rep.2850000 = (((11,(6,15)),(8,10)),((((9,2),3),((((13,7),4),14),5)),12),1);
+   tree rep.2860000 = ((((15,6),11),(10,8)),(((12,5),(3,(9,2))),(14,((7,13),4))),1);
+   tree rep.2870000 = (12,(((((13,7),4),((2,9),3)),(5,14)),((8,10),(11,(6,15)))),1);
+   tree rep.2880000 = ((((8,10),(15,(6,11))),(((7,13),((3,(2,9)),(4,14))),5)),12,1);
+   tree rep.2890000 = (12,(((10,(6,(15,11))),8),((7,13),(((5,14),((2,9),3)),4))),1);
+   tree rep.2900000 = (12,((5,(3,(9,2))),((8,((6,(11,15)),10)),(((7,13),4),14))),1);
+   tree rep.2910000 = ((((10,((15,6),11)),8),12),((((14,4),(13,7)),((2,9),3)),5),1);
+   tree rep.2920000 = (12,((((6,15),11),(10,8)),((5,(((4,(7,13)),14),3)),(9,2))),1);
+   tree rep.2930000 = (((((9,2),3),(14,(5,(4,(13,7))))),((8,10),(11,(15,6)))),12,1);
+   tree rep.2940000 = (12,(((3,(2,9)),(((13,7),(14,5)),4)),(((11,(6,15)),8),10)),1);
+   tree rep.2950000 = ((((((7,13),14),4),5),(12,((2,9),3))),((8,((11,15),6)),10),1);
+   tree rep.2960000 = (((4,(((13,7),3),((2,9),5))),14),(12,((10,8),((6,15),11))),1);
+   tree rep.2970000 = (12,(((((13,7),(14,5)),4),((9,2),3)),((6,(15,11)),(10,8))),1);
+   tree rep.2980000 = (((10,(8,((14,(5,((7,13),(3,(2,9))))),4))),((11,15),6)),12,1);
+   tree rep.2990000 = (((((6,11),15),(8,10)),(((14,4),(13,7)),((5,3),(2,9)))),12,1);
+   tree rep.3000000 = (12,((5,(((2,9),3),(((15,11),6),(10,8)))),(14,((13,7),4))),1);
+   tree rep.3010000 = ((((((13,7),4),14),((3,(2,9)),5)),((6,(11,15)),(8,10))),12,1);
+   tree rep.3020000 = (12,(((14,5),(((9,2),3),(4,(13,7)))),((11,(6,15)),(8,10))),1);
+   tree rep.3030000 = ((((8,(11,(15,6))),10),(((9,2),3),((5,14),((13,7),4)))),12,1);
+   tree rep.3040000 = ((((8,(6,(15,11))),10),(5,((4,(14,(7,13))),((2,9),3)))),12,1);
+   tree rep.3050000 = (12,((((((13,7),14),4),((2,9),3)),5),((8,10),((15,6),11))),1);
+   tree rep.3060000 = (12,(((10,8),(6,(11,15))),(((7,4),13),((3,(2,9)),(14,5)))),1);
+   tree rep.3070000 = ((((11,(15,6)),10),8),(((3,(2,9)),(((13,7),(14,5)),4)),12),1);
+   tree rep.3080000 = (12,((8,((6,(11,15)),10)),((((13,7),(4,14)),(3,(2,9))),5)),1);
+   tree rep.3090000 = (12,((((3,(2,9)),5),((14,(7,13)),4)),(10,(8,((15,6),11)))),1);
+   tree rep.3100000 = (((((15,6),11),(((2,9),(5,(14,(4,(13,7))))),3)),(10,8)),12,1);
+   tree rep.3110000 = (((10,((11,(15,6)),8)),((3,(2,9)),((14,5),(7,(4,13))))),12,1);
+   tree rep.3120000 = (((((14,4),(13,7)),(((2,9),3),5)),((8,(11,(15,6))),10)),12,1);
+   tree rep.3130000 = ((12,((6,(11,15)),(8,10))),((((2,9),3),(14,(4,(7,13)))),5),1);
+   tree rep.3140000 = (((10,((11,(6,15)),8)),(((4,(14,(7,13))),5),((2,9),3))),12,1);
+   tree rep.3150000 = (((10,8),((((9,2),3),((14,((7,13),4)),5)),((6,15),11))),12,1);
+   tree rep.3160000 = (((10,(((15,11),6),8)),((5,14),((4,(3,(2,9))),(7,13)))),12,1);
+   tree rep.3170000 = ((5,(((((13,7),4),12),(3,(2,9))),14)),((10,8),((15,6),11)),1);
+   tree rep.3180000 = ((((((9,2),3),((4,(14,5)),(13,7))),(6,(11,15))),(8,10)),12,1);
+   tree rep.3190000 = (((((15,11),6),(10,8)),(5,(((9,2),3),(((13,7),4),14)))),12,1);
+   tree rep.3200000 = (((((15,11),6),8),10),(12,(((5,(4,(13,7))),14),(3,(9,2)))),1);
+   tree rep.3210000 = (((((3,(9,2)),(7,13)),(4,(5,14))),((11,(15,6)),(8,10))),12,1);
+   tree rep.3220000 = (((5,((4,(14,(13,7))),((9,2),3))),((10,((15,6),11)),8)),12,1);
+   tree rep.3230000 = ((((((4,(13,7)),14),((9,2),3)),5),((10,8),((15,6),11))),12,1);
+   tree rep.3240000 = ((((5,((3,9),2)),(14,(4,(13,7)))),((10,(11,(15,6))),8)),12,1);
+   tree rep.3250000 = (12,(((15,(11,6)),(10,8)),(4,(((14,5),((9,2),3)),(7,13)))),1);
+   tree rep.3260000 = (12,((8,((11,(6,15)),10)),((((7,13),4),((2,9),3)),(5,14))),1);
+   tree rep.3270000 = (((14,(4,(5,(13,7)))),(((((6,15),11),8),10),(3,(2,9)))),12,1);
+   tree rep.3280000 = (((10,(8,((6,11),15))),12),((4,14),((3,(2,9)),(5,(13,7)))),1);
+   tree rep.3290000 = (((8,10),((15,6),11)),((14,((7,13),(5,(12,(3,(2,9)))))),4),1);
+   tree rep.3300000 = ((((5,((2,9),3)),((4,14),(7,13))),((10,8),((11,15),6))),12,1);
+   tree rep.3310000 = (((10,((6,(15,11)),8)),(5,(((9,2),3),((14,4),(13,7))))),12,1);
+   tree rep.3320000 = ((((((14,(4,13)),7),5),(3,(9,2))),((10,8),(6,(11,15)))),12,1);
+   tree rep.3330000 = (12,((8,(((15,11),6),10)),((14,(7,13)),(4,(5,((9,2),3))))),1);
+   tree rep.3340000 = (12,((3,(9,2)),(5,(((4,(13,7)),14),(10,(((6,11),15),8))))),1);
+   tree rep.3350000 = (12,((10,(((15,11),6),8)),(((9,2),3),((14,5),(4,(7,13))))),1);
+   tree rep.3360000 = (12,(((10,8),(((14,(13,7)),4),(5,(3,(9,2))))),((11,6),15)),1);
+   tree rep.3370000 = ((12,((14,(13,7)),4)),(((9,2),(5,3)),(((11,15),6),(10,8))),1);
+   tree rep.3380000 = ((((4,((14,5),(7,13))),(3,(2,9))),(8,((6,(15,11)),10))),12,1);
+   tree rep.3390000 = ((((3,(2,9)),5),((14,4),(13,7))),((((15,11),6),(10,8)),12),1);
+   tree rep.3400000 = (((10,((11,(6,15)),8)),(((7,13),(14,(5,4))),(3,(9,2)))),12,1);
+   tree rep.3410000 = (12,((((9,2),3),((((13,7),4),14),5)),(10,(((15,11),6),8))),1);
+   tree rep.3420000 = (12,(((((4,(13,7)),((2,9),3)),(((6,15),11),(8,10))),14),5),1);
+   tree rep.3430000 = (12,(((7,13),((4,((3,(2,9)),5)),14)),((10,8),((11,15),6))),1);
+   tree rep.3440000 = (((14,((3,(2,9)),5)),((10,(((11,15),6),8)),(13,7))),(12,4),1);
+   tree rep.3450000 = ((((4,(7,13)),((5,14),((9,2),3))),((15,(11,6)),(10,8))),12,1);
+   tree rep.3460000 = (((((15,6),11),(10,8)),(((3,(9,2)),5),(14,((13,7),4)))),12,1);
+   tree rep.3470000 = ((((9,2),3),(5,((4,14),(7,13)))),((((15,6),11),(10,8)),12),1);
+   tree rep.3480000 = (12,(((8,(11,(6,15))),10),((((9,2),3),(14,5)),(4,(7,13)))),1);
+   tree rep.3490000 = (((5,((3,14),(((7,13),4),(9,2)))),(10,((6,(15,11)),8))),12,1);
+   tree rep.3500000 = (12,((((2,9),3),(5,(((13,7),4),14))),(10,(8,(15,(11,6))))),1);
+   tree rep.3510000 = (12,(((14,5),((4,(7,13)),(3,(9,2)))),(10,(((15,6),11),8))),1);
+   tree rep.3520000 = ((12,(((3,(2,9)),(5,14)),(4,(13,7)))),(((11,(6,15)),8),10),1);
+   tree rep.3530000 = ((((6,(11,15)),(10,8)),(((13,7),4),((2,9),(3,(5,14))))),12,1);
+   tree rep.3540000 = ((((5,(3,(2,9))),((4,(13,7)),14)),((10,8),((6,15),11))),12,1);
+   tree rep.3550000 = (12,((3,(2,9)),((5,14),((4,(13,7)),((10,8),(11,(6,15)))))),1);
+   tree rep.3560000 = (12,((((((9,2),3),(7,13)),5),4),(((8,(15,(11,6))),10),14)),1);
+   tree rep.3570000 = ((((10,8),(11,(6,15))),((5,(14,(4,(13,7)))),(3,(9,2)))),12,1);
+   tree rep.3580000 = (12,((((9,2),3),((5,14),((7,13),4))),(8,(10,(15,(11,6))))),1);
+   tree rep.3590000 = ((((8,(6,(15,11))),10),(((9,2),3),((14,(4,(13,7))),5))),12,1);
+   tree rep.3600000 = (12,(((((4,(7,13)),14),(((6,(15,11)),10),8)),5),((9,2),3)),1);
+   tree rep.3610000 = (((5,((14,(4,(7,13))),(3,(9,2)))),((8,10),(11,(6,15)))),12,1);
+   tree rep.3620000 = (12,((((((7,13),(8,(10,(11,(6,15))))),5),14),4),((9,2),3)),1);
+   tree rep.3630000 = ((12,((6,(11,15)),(10,8))),((5,14),((3,(9,2)),(7,(4,13)))),1);
+   tree rep.3640000 = ((((8,(11,(15,6))),10),((5,((2,9),3)),(((13,7),4),14))),12,1);
+   tree rep.3650000 = (((5,(3,(9,2))),((14,4),(13,7))),(12,(10,((11,(15,6)),8))),1);
+   tree rep.3660000 = ((((4,(7,13)),(5,14)),((9,2),3)),(12,((8,10),((11,15),6))),1);
+   tree rep.3670000 = (12,((((11,(15,6)),8),10),(5,(4,(((9,2),3),((7,13),14))))),1);
+   tree rep.3680000 = ((((((9,2),3),((4,(7,13)),14)),5),(((15,6),11),(10,8))),12,1);
+   tree rep.3690000 = (12,(((8,10),((15,11),6)),((3,(9,2)),((14,((13,7),4)),5))),1);
+   tree rep.3700000 = ((14,(((4,(7,13)),5),((9,2),3))),(12,(8,((6,(15,11)),10))),1);
+   tree rep.3710000 = ((((5,14),(((7,13),4),(3,(2,9)))),12),(8,((11,(15,6)),10)),1);
+   tree rep.3720000 = (12,(((5,((2,9),3)),((7,13),(4,14))),((8,((15,6),11)),10)),1);
+   tree rep.3730000 = (12,(((5,((9,2),3)),((14,(7,13)),4)),((15,(6,11)),(8,10))),1);
+   tree rep.3740000 = (((4,(9,(13,7))),((3,2),((14,5),(((11,15),6),(8,10))))),12,1);
+   tree rep.3750000 = ((((14,5),(((7,13),4),(3,(9,2)))),12),((10,8),((15,6),11)),1);
+   tree rep.3760000 = (((8,10),((5,((9,2),(((4,(7,13)),14),3))),((11,15),6))),12,1);
+   tree rep.3770000 = ((((5,(((13,7),4),(3,(9,2)))),14),((10,((11,15),6)),8)),12,1);
+   tree rep.3780000 = (12,(5,((14,(4,(13,7))),(((11,(15,6)),(8,10)),(3,(2,9))))),1);
+   tree rep.3790000 = (12,((((10,8),((15,6),11)),((3,(9,2)),(14,(13,7)))),(5,4)),1);
+   tree rep.3800000 = (((((11,15),6),(8,10)),(((9,2),3),(14,(((7,13),4),5)))),12,1);
+   tree rep.3810000 = ((((6,(11,15)),(8,10)),(((7,13),(4,((9,2),3))),(5,14))),12,1);
+   tree rep.3820000 = (((((15,6),11),(8,10)),((((13,7),4),14),(5,((9,2),3)))),12,1);
+   tree rep.3830000 = (((((15,6),11),8),10),((5,((9,2),3)),((12,14),(4,(13,7)))),1);
+   tree rep.3840000 = (12,((((13,7),4),(((3,(9,2)),14),5)),((10,(11,(6,15))),8)),1);
+   tree rep.3850000 = (12,(((14,(4,(7,13))),(5,(3,(9,2)))),(10,(((15,6),11),8))),1);
+   tree rep.3860000 = (((4,(13,7)),(((2,9),3),(5,14))),(((8,((11,15),6)),10),12),1);
+   tree rep.3870000 = (12,(((((6,15),11),10),8),((4,((((9,2),3),(7,13)),14)),5)),1);
+   tree rep.3880000 = (((5,((14,(4,(13,7))),(3,(9,2)))),(10,((11,(15,6)),8))),12,1);
+   tree rep.3890000 = (12,(((3,(9,2)),(((4,(7,13)),14),5)),(((11,6),15),(8,10))),1);
+   tree rep.3900000 = (((((9,2),3),((14,(4,(13,7))),5)),(10,(((15,11),6),8))),12,1);
+   tree rep.3910000 = ((((3,(9,2)),((7,13),14)),(5,4)),(((10,(6,(15,11))),8),12),1);
+   tree rep.3920000 = ((((8,10),((11,15),6)),(((4,(7,13)),14),(5,((2,9),3)))),12,1);
+   tree rep.3930000 = (((12,(14,(4,(13,7)))),((3,(2,9)),5)),((10,8),(11,(15,6))),1);
+   tree rep.3940000 = (12,(((4,((14,5),((9,2),3))),(13,7)),(((15,(11,6)),10),8)),1);
+   tree rep.3950000 = (12,(((10,(6,(15,11))),8),(((14,5),(4,(13,7))),((9,2),3))),1);
+   tree rep.3960000 = (12,(((3,(9,2)),((5,14),((7,13),4))),((10,8),((11,15),6))),1);
+   tree rep.3970000 = (((14,((((7,13),4),5),(3,(9,2)))),((8,10),(6,(15,11)))),12,1);
+   tree rep.3980000 = (((5,((((9,2),3),14),((13,7),4))),(10,(8,(11,(6,15))))),12,1);
+   tree rep.3990000 = ((((4,((14,5),(3,(2,9)))),((8,10),((15,11),6))),(7,13)),12,1);
+   tree rep.4000000 = (12,(((((2,9),3),5),(14,(4,(7,13)))),(10,((6,(11,15)),8))),1);
+   tree rep.4010000 = ((((15,6),11),(10,8)),((12,((9,2),3)),((5,14),((13,7),4))),1);
+   tree rep.4020000 = (12,((((15,6),11),(8,10)),(((((2,9),3),(14,5)),4),(7,13))),1);
+   tree rep.4030000 = ((((((9,2),3),((8,10),(11,(15,6)))),(((13,7),4),14)),5),12,1);
+   tree rep.4040000 = (12,(((((11,15),6),10),8),((13,(7,4)),((((9,2),3),14),5))),1);
+   tree rep.4050000 = (((8,(10,((11,15),6))),(5,((4,((2,9),3)),(14,(7,13))))),12,1);
+   tree rep.4060000 = ((((6,(11,15)),(10,8)),(((13,7),14),(((2,9),3),(5,4)))),12,1);
+   tree rep.4070000 = ((((((3,(2,9)),5),((13,7),4)),14),(((15,6),11),(8,10))),12,1);
+   tree rep.4080000 = ((((((2,9),3),5),(14,(4,(13,7)))),12),(((11,(6,15)),8),10),1);
+   tree rep.4090000 = (((((13,(7,4)),(5,14)),(3,(2,9))),(8,(10,((15,11),6)))),12,1);
+   tree rep.4100000 = (((((9,2),3),(5,(14,((7,13),4)))),((6,(11,15)),(10,8))),12,1);
+   tree rep.4110000 = ((((10,8),(11,(6,15))),((3,(9,2)),((4,(14,(13,7))),5))),12,1);
+   tree rep.4120000 = (((((9,2),3),(((4,14),(7,13)),5)),(10,(8,((15,6),11)))),12,1);
+   tree rep.4130000 = ((((10,8),(11,(6,15))),12),((3,5),((9,2),((7,13),(4,14)))),1);
+   tree rep.4140000 = (12,((4,((14,(7,13)),(5,((9,2),3)))),((8,10),((15,11),6))),1);
+   tree rep.4150000 = (((10,(8,((6,15),11))),((5,((14,4),(7,13))),((9,2),3))),12,1);
+   tree rep.4160000 = (12,((5,(((9,2),3),((4,14),(13,7)))),(((6,(15,11)),10),8)),1);
+   tree rep.4170000 = (12,(((((9,2),3),((14,(7,13)),5)),4),(((15,11),6),(8,10))),1);
+   tree rep.4180000 = (12,(((5,(3,(9,2))),((4,14),(7,13))),(10,(((15,6),11),8))),1);
+   tree rep.4190000 = (((((15,6),11),(8,10)),12),((5,(3,(2,9))),((13,7),(4,14))),1);
+   tree rep.4200000 = ((((8,(6,(15,11))),10),(((3,(2,9)),((7,13),(14,4))),5)),12,1);
+   tree rep.4210000 = (((((11,15),6),8),10),((((((13,7),14),4),5),(3,(2,9))),12),1);
+   tree rep.4220000 = ((((7,13),4),(((5,((10,8),((6,15),11))),(3,(2,9))),14)),12,1);
+   tree rep.4230000 = (((((11,15),6),(10,8)),12),(4,((5,((7,14),13)),((2,9),3))),1);
+   tree rep.4240000 = ((((14,((7,13),4)),5),((9,2),3)),(((((11,15),6),8),10),12),1);
+   tree rep.4250000 = (((((15,6),11),(10,8)),(((4,(3,(2,9))),(14,(7,13))),5)),12,1);
+   tree rep.4260000 = ((((3,(2,9)),(4,(14,((13,7),5)))),((10,8),((15,6),11))),12,1);
+   tree rep.4270000 = (5,((((11,(6,15)),(10,8)),(((13,7),4),14)),(12,((9,2),3))),1);
+   tree rep.4280000 = (((10,((15,6),11)),8),(12,((5,(((2,9),3),(4,14))),(7,13))),1);
+   tree rep.4290000 = ((12,(10,8)),(((15,6),11),((5,((14,(13,7)),4)),((9,2),3))),1);
+   tree rep.4300000 = (12,(((((9,(3,2)),4),(7,13)),(14,5)),(10,((15,(6,11)),8))),1);
+   tree rep.4310000 = (12,(((((13,7),4),14),(5,(3,(9,2)))),((10,((15,11),6)),8)),1);
+   tree rep.4320000 = (((10,(8,(6,(15,11)))),(4,(((13,7),((2,9),(14,5))),3))),12,1);
+   tree rep.4330000 = (((10,(((15,6),11),8)),(((13,7),4),((14,5),(3,(9,2))))),12,1);
+   tree rep.4340000 = (((12,(5,(((4,14),(7,13)),(3,(9,2))))),(10,(11,(15,6)))),8,1);
+   tree rep.4350000 = (12,((14,((13,7),4)),((((6,15),11),(10,8)),(((9,2),3),5))),1);
+   tree rep.4360000 = ((((10,8),(6,(15,11))),(((7,(13,14)),4),(5,(3,(2,9))))),12,1);
+   tree rep.4370000 = ((((((2,9),3),((14,4),(13,7))),5),((8,(6,(15,11))),10)),12,1);
+   tree rep.4380000 = (((((9,2),3),(5,((7,13),(4,14)))),(8,(10,(6,(15,11))))),12,1);
+   tree rep.4390000 = (((10,(8,(11,(6,15)))),(((14,(4,(7,13))),(3,(2,9))),5)),12,1);
+   tree rep.4400000 = ((10,((11,(15,6)),8)),(12,(((5,14),(4,(7,13))),(3,(9,2)))),1);
+   tree rep.4410000 = ((((((11,15),6),(10,8)),((((13,7),(9,2)),5),(3,4))),12),14,1);
+   tree rep.4420000 = ((12,(((5,(9,2)),((14,4),(7,13))),3)),((10,8),((15,11),6)),1);
+   tree rep.4430000 = ((((11,(15,6)),(8,10)),(14,(5,((3,(2,9)),(4,(13,7)))))),12,1);
+   tree rep.4440000 = (12,((((7,13),4),((14,5),((2,9),3))),(10,(8,((11,15),6)))),1);
+   tree rep.4450000 = (12,(((((7,13),4),((2,9),3)),(5,14)),((11,(6,15)),(10,8))),1);
+   tree rep.4460000 = (((10,8),((11,(6,15)),12)),((((7,13),4),14),(5,(9,(3,2)))),1);
+   tree rep.4470000 = (12,((((11,15),6),(10,8)),((5,((14,(7,13)),4)),((2,9),3))),1);
+   tree rep.4480000 = (((8,10),((6,15),11)),(12,(((5,14),((7,13),4)),(3,(2,9)))),1);
+   tree rep.4490000 = (((((2,9),3),((8,10),((15,6),11))),((5,(14,4)),(13,7))),12,1);
+   tree rep.4500000 = ((((8,((6,11),15)),10),((14,((((9,2),3),5),(13,7))),4)),12,1);
+   tree rep.4510000 = ((5,(12,((2,9),3))),((((6,15),11),(10,8)),(14,((13,7),4))),1);
+   tree rep.4520000 = (((8,(10,(6,(15,11)))),(((5,((((9,2),13),7),14)),4),3)),12,1);
+   tree rep.4530000 = (((15,6),11),(12,((((((9,2),3),(14,(4,(13,7)))),5),8),10)),1);
+   tree rep.4540000 = (12,((((((((2,9),3),5),((13,7),4)),14),10),8),((6,15),11)),1);
+   tree rep.4550000 = (12,(((((2,9),5),3),((13,7),(14,4))),(((6,15),11),(10,8))),1);
+   tree rep.4560000 = (((((2,9),3),((4,(13,7)),(14,5))),((10,(6,(15,11))),8)),12,1);
+   tree rep.4570000 = ((((10,(8,(6,(15,11)))),((2,9),(3,12))),5),(14,(4,(7,13))),1);
+   tree rep.4580000 = (((((14,((13,7),4)),5),(3,(9,2))),((8,(6,(15,11))),10)),12,1);
+   tree rep.4590000 = (12,(((5,14),((3,(9,2)),((7,13),4))),(((15,6),11),(8,10))),1);
+   tree rep.4600000 = (12,((((3,(2,9)),((13,7),(4,14))),5),((15,(11,6)),(10,8))),1);
+   tree rep.4610000 = ((((7,(13,4)),((8,10),((15,11),6))),((5,((2,9),3)),14)),12,1);
+   tree rep.4620000 = (((10,(((6,11),15),8)),((5,((9,2),3)),((4,14),(7,13)))),12,1);
+   tree rep.4630000 = ((((5,((4,((13,7),(3,(9,2)))),14)),((11,15),6)),(8,10)),12,1);
+   tree rep.4640000 = (((10,8),(6,(15,11))),(5,(14,(((7,13),4),(((9,2),3),12)))),1);
+   tree rep.4650000 = (((7,13),(((((((11,15),6),(8,10)),5),(2,(9,3))),4),14)),12,1);
+   tree rep.4660000 = ((((2,9),3),(((14,(7,(13,4))),5),((6,(15,11)),(8,10)))),12,1);
+   tree rep.4670000 = (12,(((3,(2,9)),(((7,13),4),(5,14))),((10,((15,6),11)),8)),1);
+   tree rep.4680000 = (((((9,2),3),(5,(14,((7,4),13)))),((10,(11,(15,6))),8)),12,1);
+   tree rep.4690000 = (12,(((14,5),(((13,7),4),(3,(2,9)))),((8,((6,15),11)),10)),1);
+   tree rep.4700000 = (12,((10,(((15,11),6),8)),((4,(13,7)),((5,14),((2,9),3)))),1);
+   tree rep.4710000 = (((10,(((6,15),11),8)),12),((3,(2,9)),((((13,4),7),14),5)),1);
+   tree rep.4720000 = (12,(((((4,(7,13)),14),5),((2,9),3)),((6,(11,15)),(10,8))),1);
+   tree rep.4730000 = (12,((8,((11,(15,6)),10)),(5,((3,(9,2)),((4,(13,7)),14)))),1);
+   tree rep.4740000 = (12,(((11,(6,15)),(8,10)),((5,((14,4),(7,13))),(3,(2,9)))),1);
+   tree rep.4750000 = (12,((((2,9),3),(((13,7),4),(5,14))),(((15,11),6),(8,10))),1);
+   tree rep.4760000 = (((((15,6),11),(8,10)),(((14,5),((13,7),4)),(3,(2,9)))),12,1);
+   tree rep.4770000 = (((14,((13,7),4)),(((2,9),3),5)),(12,((10,(6,(15,11))),8)),1);
+   tree rep.4780000 = (((((10,8),(((13,7),4),(5,(11,(6,15))))),14),(3,(9,2))),12,1);
+   tree rep.4790000 = ((((3,(2,9)),((13,7),4)),(14,5)),(12,((10,(6,(15,11))),8)),1);
+   tree rep.4800000 = ((((((3,(9,2)),((7,13),4)),14),5),((10,(11,(15,6))),8)),12,1);
+   tree rep.4810000 = (12,((((11,15),6),(10,8)),((((3,(2,9)),((7,13),4)),14),5)),1);
+   tree rep.4820000 = (12,(((8,(6,(15,11))),10),(((2,9),3),((4,(7,13)),(14,5)))),1);
+   tree rep.4830000 = (12,(5,((((8,10),(11,(6,15))),(14,(13,(7,4)))),((9,2),3))),1);
+   tree rep.4840000 = (((10,(((11,6),15),8)),(((14,5),((7,13),4)),(3,(2,9)))),12,1);
+   tree rep.4850000 = (12,((((4,(13,7)),(14,5)),((9,2),3)),((10,(11,(6,15))),8)),1);
+   tree rep.4860000 = (((((3,(9,2)),5),((14,4),(13,7))),((((6,15),11),8),10)),12,1);
+   tree rep.4870000 = ((((((10,8),((6,11),15)),((9,2),3)),(4,(14,(7,13)))),5),12,1);
+   tree rep.4880000 = ((((8,10),(11,(6,15))),(5,((((4,7),13),14),((2,9),3)))),12,1);
+   tree rep.4890000 = ((((((9,2),14),(3,(5,4))),(7,13)),((10,8),(6,(15,11)))),12,1);
+   tree rep.4900000 = (((10,((15,6),11)),8),(12,((((2,9),(14,(4,(13,7)))),3),5)),1);
+   tree rep.4910000 = ((((((15,11),6),10),8),((4,((7,13),14)),((3,(9,2)),5))),12,1);
+   tree rep.4920000 = (((8,10),((15,11),6)),((((7,13),(14,4)),(((9,2),3),5)),12),1);
+   tree rep.4930000 = (((14,((5,(3,(9,2))),(4,(13,7)))),(10,(((6,15),11),8))),12,1);
+   tree rep.4940000 = (12,((((14,4),(7,13)),((8,10),(6,(11,15)))),(((9,2),3),5)),1);
+   tree rep.4950000 = (12,((((15,6),11),(8,10)),((3,(((4,(7,13)),14),5)),(2,9))),1);
+   tree rep.4960000 = (12,((8,(10,((15,6),11))),(((3,(9,2)),5),(((7,13),4),14))),1);
+   tree rep.4970000 = ((3,(9,2)),(((5,14),((6,(11,15)),(10,8))),((13,7),(12,4))),1);
+   tree rep.4980000 = (12,(((3,(2,9)),(5,(((13,7),14),4))),(((11,15),6),(10,8))),1);
+   tree rep.4990000 = (((((6,11),15),(10,8)),12),((3,(((14,(7,13)),4),(2,9))),5),1);
+   tree rep.5000000 = ((((((2,9),3),((10,8),((15,11),6))),(5,14)),(4,(7,13))),12,1);
+   tree rep.5010000 = (((((((4,(7,13)),14),3),(((11,15),6),(8,10))),(2,9)),5),12,1);
+   tree rep.5020000 = (((((2,9),3),(4,(5,((13,7),14)))),(8,(10,(11,(6,15))))),12,1);
+   tree rep.5030000 = ((((6,(15,11)),(10,8)),((14,5),(((7,13),4),(3,(2,9))))),12,1);
+   tree rep.5040000 = (12,(((((13,7),14),5),(4,(3,(2,9)))),(((11,15),6),(10,8))),1);
+   tree rep.5050000 = ((4,(((3,(2,9)),(7,13)),((5,(8,(10,((15,11),6)))),14))),12,1);
+   tree rep.5060000 = ((((4,(14,(7,13))),(((2,9),3),5)),((8,10),(11,(6,15)))),12,1);
+   tree rep.5070000 = ((((((15,11),6),(10,8)),(3,(9,2))),((13,7),((5,14),4))),12,1);
+   tree rep.5080000 = (12,(10,((((15,11),6),(((3,(9,2)),14),((4,(13,7)),5))),8)),1);
+   tree rep.5090000 = ((((8,10),((15,6),11)),((4,((13,7),14)),((3,(9,2)),5))),12,1);
+   tree rep.5100000 = (((((6,15),11),(10,8)),((5,14),((4,(7,13)),((2,9),3)))),12,1);
+   tree rep.5110000 = ((((((13,7),4),14),(((2,9),3),5)),((((15,11),6),8),10)),12,1);
+   tree rep.5120000 = (12,((((14,4),(7,13)),((3,(9,2)),5)),(((11,15),6),(10,8))),1);
+   tree rep.5130000 = (12,(((5,((9,2),3)),(4,((13,7),14))),(10,((11,(15,6)),8))),1);
+   tree rep.5140000 = (((10,((6,(11,15)),8)),(5,((3,(9,2)),((4,14),(13,7))))),12,1);
+   tree rep.5150000 = ((((((15,6),11),10),8),((((13,7),4),((9,2),3)),(14,5))),12,1);
+   tree rep.5160000 = ((((3,((((7,13),4),14),5)),(9,2)),(8,(((15,11),6),10))),12,1);
+   tree rep.5170000 = ((((7,13),((5,(4,14)),((9,2),3))),((10,((6,15),11)),8)),12,1);
+   tree rep.5180000 = ((((((9,2),3),((4,(13,7)),14)),5),(10,(8,((15,6),11)))),12,1);
+   tree rep.5190000 = ((12,(8,(((15,6),11),10))),(((9,2),3),((14,((13,7),4)),5)),1);
+   tree rep.5200000 = (((((7,13),(4,14)),(5,(3,(9,2)))),((8,(6,(15,11))),10)),12,1);
+   tree rep.5210000 = (12,((10,(8,(6,(15,11)))),((3,(9,2)),(5,(4,((13,7),14))))),1);
+   tree rep.5220000 = ((((((4,(7,13)),((9,2),3)),14),5),(((11,6),15),(8,10))),12,1);
+   tree rep.5230000 = (12,(((8,(11,(6,15))),10),(((4,(13,7)),(14,5)),(3,(9,2)))),1);
+   tree rep.5240000 = ((((((4,(13,7)),14),(3,(9,2))),5),(10,(8,((6,15),11)))),12,1);
+   tree rep.5250000 = ((12,((10,8),(6,(11,15)))),(((14,4),((13,7),5)),(3,(9,2))),1);
+   tree rep.5260000 = (12,(((8,10),(11,(15,6))),((14,((4,(13,7)),((9,2),3))),5)),1);
+   tree rep.5270000 = (12,((14,(((2,9),3),(((7,13),4),5))),((8,(11,(6,15))),10)),1);
+   tree rep.5280000 = (((((6,15),11),(10,8)),(((14,5),(4,(7,13))),((2,9),3))),12,1);
+   tree rep.5290000 = (((((13,7),(14,4)),(((2,9),3),5)),(((6,15),11),(8,10))),12,1);
+   tree rep.5300000 = ((14,(13,7)),((4,(((2,9),3),5)),(12,((8,((6,11),15)),10))),1);
+   tree rep.5310000 = (12,(((10,8),(6,(15,11))),(5,(((3,2),9),(14,(4,(7,13)))))),1);
+   tree rep.5320000 = (12,((((9,2),3),((4,5),(14,(13,7)))),(8,(10,(11,(15,6))))),1);
+   tree rep.5330000 = ((((((7,13),4),(5,14)),(3,(9,2))),((15,(6,11)),(8,10))),12,1);
+   tree rep.5340000 = ((((((13,7),4),14),(5,(3,(9,2)))),((8,(6,(15,11))),10)),12,1);
+   tree rep.5350000 = ((((4,(13,7)),((5,14),((2,9),3))),((8,(11,(6,15))),10)),12,1);
+   tree rep.5360000 = (((((6,15),11),(10,8)),((3,(2,9)),(((14,(13,7)),4),5))),12,1);
+   tree rep.5370000 = ((((8,10),(11,(15,6))),(((((7,13),4),14),((9,2),3)),5)),12,1);
+   tree rep.5380000 = ((((5,(((7,13),4),14)),(3,(9,2))),(((6,(11,15)),8),10)),12,1);
+   tree rep.5390000 = (((5,((3,(9,2)),((4,(13,7)),14))),(8,(10,((15,11),6)))),12,1);
+   tree rep.5400000 = (12,(((7,13),((14,5),(((2,9),3),4))),((8,10),((15,6),11))),1);
+   tree rep.5410000 = (12,((((2,9),3),((((13,7),4),14),5)),(10,(((11,6),15),8))),1);
+   tree rep.5420000 = (12,((5,(((13,(4,7)),14),(3,(2,9)))),(10,((11,(15,6)),8))),1);
+   tree rep.5430000 = (12,(((3,(((4,(7,13)),(2,9)),14)),5),((10,(6,(15,11))),8)),1);
+   tree rep.5440000 = (((10,(8,(11,(6,15)))),(((5,(3,(9,2))),(4,(13,7))),14)),12,1);
+   tree rep.5450000 = ((((10,(6,(11,15))),8),((14,5),(((2,9),3),((7,4),13)))),12,1);
+   tree rep.5460000 = ((((2,9),3),((((6,(15,11)),(10,8)),5),(((13,7),4),14))),12,1);
+   tree rep.5470000 = (12,(((5,(14,((7,13),4))),(3,(2,9))),(((6,15),11),(10,8))),1);
+   tree rep.5480000 = ((8,(10,(11,(6,15)))),(12,(5,(((2,9),3),(((7,13),4),14)))),1);
+   tree rep.5490000 = (((((6,15),11),(10,8)),(((((7,13),4),14),5),(3,(9,2)))),12,1);
+   tree rep.5500000 = ((5,((14,((9,2),3)),(4,(13,7)))),((8,((6,(11,15)),10)),12),1);
+   tree rep.5510000 = ((12,((((4,(13,7)),14),((9,2),3)),5)),((10,((6,15),11)),8),1);
+   tree rep.5520000 = ((12,((10,(6,(15,11))),8)),(((14,(4,(7,13))),5),(3,(9,2))),1);
+   tree rep.5530000 = (12,(((3,(9,2)),((13,7),(4,(5,14)))),(((6,15),11),(10,8))),1);
+   tree rep.5540000 = (12,((8,(10,(6,(11,15)))),(((4,(7,13)),(3,(9,2))),(5,14))),1);
+   tree rep.5550000 = (((((15,(11,6)),8),10),(5,((14,((7,13),4)),((9,2),3)))),12,1);
+   tree rep.5560000 = (12,(((14,5),(((7,13),4),((9,2),3))),((((6,15),11),8),10)),1);
+   tree rep.5570000 = (((((2,9),3),((5,14),(4,(13,7)))),(((15,6),11),(8,10))),12,1);
+   tree rep.5580000 = (((((4,((13,7),14)),(3,(9,2))),5),((((11,6),15),8),10)),12,1);
+   tree rep.5590000 = (12,(((((5,((8,10),(11,(6,15)))),9),(2,3)),14),((7,13),4)),1);
+   tree rep.5600000 = (12,(((10,8),((15,6),11)),((((3,5),14),(2,9)),((13,7),4))),1);
+   tree rep.5610000 = (12,((((((((8,10),((6,11),15)),14),(13,7)),4),5),(2,9)),3),1);
+   tree rep.5620000 = (12,((8,(10,((11,15),6))),(4,((13,7),((3,(9,2)),(14,5))))),1);
+   tree rep.5630000 = (12,((5,(((2,9),3),((4,(13,7)),14))),((11,(6,15)),(10,8))),1);
+   tree rep.5640000 = (((((3,(9,2)),((14,((7,13),4)),5)),(11,(6,15))),(8,10)),12,1);
+   tree rep.5650000 = (12,(((3,(8,(10,((15,6),11)))),(((4,(7,13)),(2,9)),14)),5),1);
+   tree rep.5660000 = (12,((((2,9),3),((7,(13,4)),(5,14))),((10,(11,(6,15))),8)),1);
+   tree rep.5670000 = (((((11,(6,15)),(10,8)),(5,14)),(((2,9),3),(4,(7,13)))),12,1);
+   tree rep.5680000 = (((((15,11),6),(10,8)),(4,((7,13),((3,(2,9)),(5,14))))),12,1);
+   tree rep.5690000 = (12,((((15,11),6),(8,10)),((5,(14,((7,13),4))),(3,(9,2)))),1);
+   tree rep.5700000 = (((((6,15),11),(10,8)),(5,(((9,2),3),(4,(14,(7,13)))))),12,1);
+   tree rep.5710000 = (12,((8,(10,((11,15),6))),((5,4),(((7,13),14),((2,9),3)))),1);
+   tree rep.5720000 = (((((15,11),6),(8,10)),12),(((2,9),3),((7,13),((5,14),4))),1);
+   tree rep.5730000 = ((((15,(11,6)),(8,10)),(3,((5,((13,7),(4,14))),(2,9)))),12,1);
+   tree rep.5740000 = (12,(((8,10),((15,11),6)),((((2,9),3),5),(14,((7,13),4)))),1);
+   tree rep.5750000 = (12,((((4,((7,13),((2,9),3))),14),5),(((15,11),6),(8,10))),1);
+   tree rep.5760000 = (((((2,9),3),((7,13),((5,14),4))),(8,((11,(15,6)),10))),12,1);
+   tree rep.5770000 = ((((2,9),3),(((5,(13,7)),(4,14)),((((6,15),11),10),8))),12,1);
+   tree rep.5780000 = (((10,8),((15,6),11)),(12,((((4,14),(7,13)),(3,(9,2))),5)),1);
+   tree rep.5790000 = (((((9,2),3),((14,(4,(7,13))),5)),((((6,15),11),10),8)),12,1);
+   tree rep.5800000 = (((3,(2,9)),(12,(((7,13),(4,14)),(((6,(15,11)),8),10)))),5,1);
+   tree rep.5810000 = (12,(((11,(15,6)),(((((7,13),14),4),((3,5),(2,9))),8)),10),1);
+   tree rep.5820000 = ((((3,(9,2)),((10,8),(11,(15,6)))),(5,((4,(7,13)),14))),12,1);
+   tree rep.5830000 = (12,(((3,(9,2)),((4,(14,(13,7))),5)),(((11,(15,6)),8),10)),1);
+   tree rep.5840000 = (12,(((10,(6,(11,15))),8),((4,((13,7),14)),(5,((9,2),3)))),1);
+   tree rep.5850000 = (12,(((11,(6,15)),(8,10)),((4,(7,13)),((14,5),(2,(9,3))))),1);
+   tree rep.5860000 = (12,(((4,((14,5),(7,13))),((9,2),3)),((11,(15,6)),(10,8))),1);
+   tree rep.5870000 = (12,((14,(9,2)),((5,3),(((10,8),((15,6),11)),((7,13),4)))),1);
+   tree rep.5880000 = ((12,((3,(9,2)),((((7,13),14),4),5))),(((11,(6,15)),8),10),1);
+   tree rep.5890000 = (((((11,15),6),8),10),(12,((((13,7),4),14),(5,(3,(9,2))))),1);
+   tree rep.5900000 = (((3,(2,9)),(5,(4,((7,13),14)))),(12,((10,8),((15,6),11))),1);
+   tree rep.5910000 = (12,(((5,((13,7),(14,4))),((2,9),3)),((8,10),((15,11),6))),1);
+   tree rep.5920000 = ((((15,(11,6)),(8,10)),12),((((13,7),14),((3,(2,9)),5)),4),1);
+   tree rep.5930000 = (((3,(2,9)),((4,((7,13),14)),(5,((11,(15,6)),(10,8))))),12,1);
+   tree rep.5940000 = (12,(((13,7),4),((3,(2,9)),(((10,8),((11,15),6)),(5,14)))),1);
+   tree rep.5950000 = (12,(((((6,15),11),8),10),(((4,14),(7,13)),((3,(9,2)),5))),1);
+   tree rep.5960000 = (12,(((5,(14,(4,(13,7)))),((2,9),3)),((10,8),(11,(15,6)))),1);
+   tree rep.5970000 = ((14,((5,((9,2),(((8,((15,6),11)),10),12))),3)),(13,(7,4)),1);
+   tree rep.5980000 = (12,(((((9,2),3),5),(14,((7,13),4))),((((15,11),6),8),10)),1);
+   tree rep.5990000 = ((((8,10),(6,(15,11))),(((14,(9,2)),(5,3)),(4,(13,7)))),12,1);
+   tree rep.6000000 = ((((5,((9,2),3)),(14,(4,(13,7)))),12),((10,8),(11,(15,6))),1);
+   tree rep.6010000 = ((((4,(13,7)),((9,2),3)),(14,5)),((((15,11),6),(8,10)),12),1);
+   tree rep.6020000 = ((10,(8,(6,(15,11)))),((((3,(2,9)),((4,(7,13)),5)),14),12),1);
+   tree rep.6030000 = (12,((((2,9),3),((14,5),(4,(7,13)))),((8,10),(6,(15,11)))),1);
+   tree rep.6040000 = (12,((((15,(6,11)),10),8),((((13,7),4),(3,(2,9))),(5,14))),1);
+   tree rep.6050000 = ((((6,(15,11)),(8,10)),(((13,7),(14,4)),((3,(2,9)),5))),12,1);
+   tree rep.6060000 = ((((8,(11,(15,6))),10),((((2,9),3),(5,14)),(13,(4,7)))),12,1);
+   tree rep.6070000 = (12,((((4,(14,5)),(13,7)),((9,2),3)),((8,10),(11,(6,15)))),1);
+   tree rep.6080000 = (12,(((10,8),(11,(15,6))),(((9,2),3),((14,5),(4,(13,7))))),1);
+   tree rep.6090000 = (12,(((((2,9),3),(14,4)),((13,7),5)),(((11,15),6),(10,8))),1);
+   tree rep.6100000 = ((((((8,(10,(11,(15,6)))),3),(12,(9,2))),(4,(7,13))),14),5,1);
+   tree rep.6110000 = (((8,10),(11,(15,6))),(((((9,2),3),((12,14),4)),(7,13)),5),1);
+   tree rep.6120000 = (((5,((3,(9,2)),(14,(4,(13,7))))),(8,((6,(15,11)),10))),12,1);
+   tree rep.6130000 = (((12,((14,((13,7),4)),5)),((9,2),3)),(((11,15),6),(10,8)),1);
+   tree rep.6140000 = (((8,(10,((15,11),6))),(5,((3,(9,2)),(14,(4,(13,7)))))),12,1);
+   tree rep.6150000 = ((((10,(11,(15,6))),8),((5,(((7,13),4),14)),((2,9),3))),12,1);
+   tree rep.6160000 = (12,(((8,((15,6),11)),10),(((14,5),((2,9),3)),((13,7),4))),1);
+   tree rep.6170000 = (12,(((((2,9),3),(14,(4,(13,7)))),5),((10,8),((11,15),6))),1);
+   tree rep.6180000 = ((((3,(9,2)),((((13,7),4),14),5)),((11,(6,15)),(10,8))),12,1);
+   tree rep.6190000 = ((((((10,8),(11,(6,15))),((2,9),3)),(7,(13,4))),(14,5)),12,1);
+   tree rep.6200000 = (12,(((10,8),((15,6),11)),((14,(4,(13,7))),(((9,2),3),5))),1);
+   tree rep.6210000 = (((5,(((2,9),3),((7,13),(14,4)))),(10,(8,(15,(6,11))))),12,1);
+   tree rep.6220000 = (((((13,7),4),((5,14),((2,9),3))),(((11,15),6),(10,8))),12,1);
+   tree rep.6230000 = (12,(((5,((3,(2,9)),14)),(8,((6,(15,11)),10))),(4,(13,7))),1);
+   tree rep.6240000 = (12,(((((2,9),3),((14,(7,4)),13)),5),((8,10),((15,11),6))),1);
+   tree rep.6250000 = (((((15,6),11),10),8),((12,(3,(2,9))),(5,((14,(13,7)),4))),1);
+   tree rep.6260000 = (12,(((3,(9,2)),(((4,(7,13)),14),5)),((((15,6),11),8),10)),1);
+   tree rep.6270000 = ((((((6,11),15),8),10),(((4,((9,2),3)),((13,7),14)),5)),12,1);
+   tree rep.6280000 = (((((15,6),11),(8,10)),12),(((3,(9,2)),((4,(13,7)),14)),5),1);
+   tree rep.6290000 = (((((14,4),((9,2),3)),((7,13),5)),12),(10,(8,((15,11),6))),1);
+   tree rep.6300000 = (12,((5,(((4,13),7),14)),((3,(9,2)),((8,10),(11,(15,6))))),1);
+   tree rep.6310000 = (12,((((11,(15,6)),(10,8)),(14,(((13,7),4),((9,2),3)))),5),1);
+   tree rep.6320000 = (12,(((((2,9),3),5),((4,(7,13)),14)),((10,8),(15,(6,11)))),1);
+   tree rep.6330000 = ((10,8),(((5,(3,(9,2))),(12,((4,(13,7)),14))),(6,(11,15))),1);
+   tree rep.6340000 = ((((10,(11,(6,15))),8),((5,((13,7),(4,14))),((2,9),3))),12,1);
+   tree rep.6350000 = (12,((((13,7),(14,((3,(2,9)),4))),5),((8,10),(6,(15,11)))),1);
+   tree rep.6360000 = ((((8,(11,(6,15))),10),((14,((7,13),4)),(5,(3,(2,9))))),12,1);
+   tree rep.6370000 = ((((((7,13),4),(3,(9,2))),(14,5)),(((6,(15,11)),8),10)),12,1);
+   tree rep.6380000 = ((8,((6,(15,11)),10)),(((14,((13,7),4)),((3,(9,2)),5)),12),1);
+   tree rep.6390000 = ((((6,(15,11)),(10,8)),(((3,(2,9)),((13,7),4)),(5,14))),12,1);
+   tree rep.6400000 = (((((13,7),4),14),(5,(3,(2,9)))),((((11,(15,6)),10),8),12),1);
+   tree rep.6410000 = (12,((10,(8,((11,6),15))),(((14,(4,(7,13))),5),((2,9),3))),1);
+   tree rep.6420000 = (12,(((5,(4,((7,13),14))),((9,2),3)),((((15,11),6),8),10)),1);
+   tree rep.6430000 = ((((10,((11,15),6)),8),(3,((9,2),((4,(13,7)),(14,5))))),12,1);
+   tree rep.6440000 = (((8,(10,((15,6),11))),(5,(3,(14,(((13,7),4),(9,2)))))),12,1);
+   tree rep.6450000 = (12,(((14,4),(((7,13),5),((9,2),3))),(((6,15),11),(8,10))),1);
+   tree rep.6460000 = ((((((13,7),4),((3,(2,9)),5)),14),(10,(8,((6,15),11)))),12,1);
+   tree rep.6470000 = (12,(((6,(15,11)),(10,8)),(((13,7),(4,(14,5))),((2,9),3))),1);
+   tree rep.6480000 = ((((3,(2,9)),((14,5),(4,(7,13)))),((6,(11,15)),(10,8))),12,1);
+   tree rep.6490000 = ((((3,(2,9)),(((4,14),(13,7)),5)),((10,8),(11,(15,6)))),12,1);
+   tree rep.6500000 = (((8,10),((15,6),11)),(5,((14,((13,7),4)),(12,(3,(9,2))))),1);
+   tree rep.6510000 = (((8,((6,(11,15)),10)),(((9,2),3),((14,5),((7,13),4)))),12,1);
+   tree rep.6520000 = ((((((9,2),3),5),((14,4),(13,7))),((8,((11,15),6)),10)),12,1);
+   tree rep.6530000 = (12,((((3,(9,2)),(14,(4,(13,7)))),5),(8,(10,((6,15),11)))),1);
+   tree rep.6540000 = (12,((5,(((13,7),(14,4)),(3,(9,2)))),(((11,(15,6)),8),10)),1);
+   tree rep.6550000 = ((8,(10,((15,6),11))),(12,(5,((((7,13),14),4),((9,2),3)))),1);
+   tree rep.6560000 = (12,(((6,(11,15)),(8,10)),(((13,7),(14,4)),(5,((9,2),3)))),1);
+   tree rep.6570000 = (((((6,15),11),(10,8)),12),((14,5),((4,(7,13)),(3,(9,2)))),1);
+   tree rep.6580000 = ((((8,10),((15,11),6)),12),((14,4),((7,13),(5,(3,(9,2))))),1);
+   tree rep.6590000 = (12,(((5,(3,(9,2))),(14,((7,13),4))),((8,10),((11,15),6))),1);
+   tree rep.6600000 = (12,((((6,(11,15)),10),8),(((13,7),(4,(5,14))),((9,2),3))),1);
+   tree rep.6610000 = (12,((((11,15),6),(8,10)),(5,((14,(4,(13,7))),((9,2),3)))),1);
+   tree rep.6620000 = (((((((2,9),3),14),(4,(13,7))),5),((8,10),(6,(15,11)))),12,1);
+   tree rep.6630000 = ((12,((10,8),(11,(6,15)))),(((14,(9,2)),((4,(13,7)),5)),3),1);
+   tree rep.6640000 = ((12,((8,(6,(11,15))),10)),(5,((14,(4,(13,7))),((9,2),3))),1);
+   tree rep.6650000 = ((((8,10),(6,(11,15))),(((14,5),((7,13),4)),(3,(2,9)))),12,1);
+   tree rep.6660000 = ((((6,(15,11)),(10,8)),(((5,(4,(7,13))),14),(3,(2,9)))),12,1);
+   tree rep.6670000 = ((((12,((8,((15,11),6)),10)),5),((9,2),3)),(4,((7,13),14)),1);
+   tree rep.6680000 = (12,((((15,6),11),(10,8)),(((4,(14,(7,13))),((9,2),3)),5)),1);
+   tree rep.6690000 = ((((6,(11,15)),(8,10)),((3,(9,2)),((((13,7),14),4),5))),12,1);
+   tree rep.6700000 = (12,(((11,(6,15)),(8,10)),((((2,9),3),5),(4,(14,(7,13))))),1);
+   tree rep.6710000 = (12,((10,((15,11),6)),(8,((((13,7),4),(3,(9,2))),(14,5)))),1);
+   tree rep.6720000 = ((14,((((9,2),3),5),((13,7),4))),((((15,6),11),(8,10)),12),1);
+   tree rep.6730000 = ((((10,8),((11,15),6)),((((2,9),3),((14,4),5)),(7,13))),12,1);
+   tree rep.6740000 = (((((13,7),(14,4)),(3,(9,2))),5),(12,((8,10),(11,(15,6)))),1);
+   tree rep.6750000 = ((((14,((9,2),3)),((4,(7,13)),5)),(8,(((6,15),11),10))),12,1);
+   tree rep.6760000 = (12,(((((9,2),(14,5)),((7,13),4)),3),(10,(((15,6),11),8))),1);
+   tree rep.6770000 = (((((((11,15),6),(8,10)),5),(3,(9,2))),(14,((7,13),4))),12,1);
+   tree rep.6780000 = (((10,8),(11,(6,15))),((5,(((2,9),3),(4,(14,(13,7))))),12),1);
+   tree rep.6790000 = (((((3,(2,9)),(((13,7),14),4)),5),((10,(11,(6,15))),8)),12,1);
+   tree rep.6800000 = ((((8,10),(11,(15,6))),((((2,9),3),((13,7),5)),(4,14))),12,1);
+   tree rep.6810000 = (12,(((8,(11,(15,6))),10),((((14,(9,2)),((7,13),4)),5),3)),1);
+   tree rep.6820000 = ((8,(((15,6),11),10)),(12,((13,7),(((5,(3,(9,2))),14),4))),1);
+   tree rep.6830000 = (12,(((((11,15),6),8),10),((14,5),(((7,13),((2,9),4)),3))),1);
+   tree rep.6840000 = ((((8,(11,(15,6))),10),((5,(((2,9),3),(4,14))),(7,13))),12,1);
+   tree rep.6850000 = (((((10,8),(6,(11,15))),4),(((7,13),(((2,9),3),12)),14)),5,1);
+   tree rep.6860000 = (12,(((((4,((7,13),14)),3),(9,2)),5),(((15,(11,6)),8),10)),1);
+   tree rep.6870000 = (12,(((6,(15,11)),((9,2),((14,(((13,7),4),3)),5))),(10,8)),1);
+   tree rep.6880000 = (12,((((6,15),11),(8,10)),((3,(9,2)),(5,(14,(4,(13,7)))))),1);
+   tree rep.6890000 = (((((6,(15,11)),8),10),((((7,13),14),5),(4,((2,3),9)))),12,1);
+   tree rep.6900000 = ((((8,10),(15,(11,6))),(3,((4,((9,2),((7,13),14))),5))),12,1);
+   tree rep.6910000 = (12,(((8,(11,(6,15))),10),((3,(9,2)),(((13,7),(4,14)),5))),1);
+   tree rep.6920000 = ((((((6,15),11),10),8),(((2,9),(((5,(13,7)),4),3)),14)),12,1);
+   tree rep.6930000 = ((5,(((8,10),(11,(6,15))),((((13,7),4),14),(3,(2,9))))),12,1);
+   tree rep.6940000 = (12,((5,((14,(4,(7,13))),(3,(2,9)))),((6,(11,15)),(10,8))),1);
+   tree rep.6950000 = (12,((((2,9),3),(14,((4,(7,13)),5))),(8,(((15,6),11),10))),1);
+   tree rep.6960000 = ((((8,10),(6,(15,11))),(((5,14),(3,(9,2))),((7,13),4))),12,1);
+   tree rep.6970000 = (((((11,(6,15)),8),10),(((9,2),3),((4,(13,7)),(5,14)))),12,1);
+   tree rep.6980000 = (12,(((14,((2,9),(3,5))),((7,13),4)),((8,10),(15,(11,6)))),1);
+   tree rep.6990000 = (12,((8,((6,(11,15)),10)),((5,14),(((4,13),7),((9,2),3)))),1);
+   tree rep.7000000 = ((((8,10),((3,(2,9)),(5,((7,13),(4,14))))),(6,(11,15))),12,1);
+   tree rep.7010000 = ((8,(((3,((((4,7),13),14),(5,(2,9)))),(6,(11,15))),10)),12,1);
+   tree rep.7020000 = ((((14,5),((13,7),4)),((8,(10,(11,(15,6)))),((9,2),3))),12,1);
+   tree rep.7030000 = (12,(((4,((3,(2,9)),(5,14))),(7,13)),(10,(((11,15),6),8))),1);
+   tree rep.7040000 = (((((13,7),(((11,(6,15)),(8,10)),(5,((2,9),3)))),4),14),12,1);
+   tree rep.7050000 = ((((8,10),((15,11),6)),(((3,5),(13,7)),((14,4),(2,9)))),12,1);
+   tree rep.7060000 = (12,((((4,(7,13)),(5,14)),((9,2),3)),((11,(15,6)),(8,10))),1);
+   tree rep.7070000 = (12,(((10,((15,6),11)),8),((((7,13),4),14),(5,(3,(2,9))))),1);
+   tree rep.7080000 = (12,(((8,10),((11,15),6)),(5,(((2,9),3),((4,(13,7)),14)))),1);
+   tree rep.7090000 = ((((6,(15,11)),(10,8)),(5,(((9,2),3),((13,7),(14,4))))),12,1);
+   tree rep.7100000 = (((5,(((9,2),3),(14,((13,7),4)))),(8,(((15,6),11),10))),12,1);
+   tree rep.7110000 = (12,((((6,15),11),(8,10)),((4,((14,5),((2,9),3))),(7,13))),1);
+   tree rep.7120000 = ((5,(((9,2),3),(4,(14,(7,13))))),((((15,11),6),(10,8)),12),1);
+   tree rep.7130000 = ((((11,15),6),(8,10)),((4,(14,(7,13))),((3,(2,9)),(12,5))),1);
+   tree rep.7140000 = (((((4,((7,13),9)),(14,5)),(3,2)),(((15,11),6),(10,8))),12,1);
+   tree rep.7150000 = (((((6,(11,15)),10),8),12),(4,(((9,2),3),((7,13),(14,5)))),1);
+   tree rep.7160000 = (12,((((11,15),6),(8,10)),(((3,(9,2)),(((13,7),4),14)),5)),1);
+   tree rep.7170000 = (((10,((((4,(13,7)),14),(((2,9),3),5)),(6,(15,11)))),8),12,1);
+   tree rep.7180000 = ((14,((13,7),(((10,8),((15,11),6)),((3,(9,2)),(5,4))))),12,1);
+   tree rep.7190000 = (((6,(15,11)),12),(((3,(2,9)),((4,14),5)),((7,13),(10,8))),1);
+   tree rep.7200000 = (((((13,7),5),14),(((10,8),((11,15),6)),(4,((9,2),3)))),12,1);
+   tree rep.7210000 = ((12,((((4,14),(7,13)),5),(3,(2,9)))),((10,8),(11,(6,15))),1);
+   tree rep.7220000 = ((((10,((15,11),6)),8),(((5,((13,7),4)),14),((9,2),3))),12,1);
+   tree rep.7230000 = ((8,(((15,11),6),10)),(12,((((9,2),3),(14,((7,13),4))),5)),1);
+   tree rep.7240000 = ((12,((5,4),((14,(7,13)),((9,2),3)))),(10,((11,(15,6)),8)),1);
+   tree rep.7250000 = ((((3,(9,2)),(((13,7),4),(5,14))),(8,(10,(11,(15,6))))),12,1);
+   tree rep.7260000 = (((((9,2),3),14),(5,((4,7),13))),(12,((8,10),(6,(11,15)))),1);
+   tree rep.7270000 = (((((6,15),11),(10,8)),(14,((13,7),((4,(3,(2,9))),5)))),12,1);
+   tree rep.7280000 = (((10,8),(11,(15,6))),(12,(((14,(7,13)),(4,((9,2),3))),5)),1);
+   tree rep.7290000 = ((((((11,15),6),10),8),((((13,7),(3,(9,2))),4),(14,5))),12,1);
+   tree rep.7300000 = (12,((14,((3,(2,9)),(5,(4,(13,7))))),((((6,15),11),10),8)),1);
+   tree rep.7310000 = (12,(((14,5),(((3,(2,9)),(7,4)),13)),((((6,15),11),10),8)),1);
+   tree rep.7320000 = ((((3,(2,9)),(((7,13),4),(5,14))),((15,(6,11)),(8,10))),12,1);
+   tree rep.7330000 = (((5,((2,9),3)),(((13,7),14),4)),((((11,(15,6)),10),8),12),1);
+   tree rep.7340000 = (12,(4,(((14,(13,7)),(5,((15,(6,11)),(8,10)))),((3,9),2))),1);
+   tree rep.7350000 = (12,(((9,2),3),((5,(((15,6),11),(10,8))),((4,(7,13)),14))),1);
+   tree rep.7360000 = (12,((3,(9,2)),(5,(((4,(13,7)),14),((10,8),(11,(6,15)))))),1);
+   tree rep.7370000 = (12,((((7,13),((9,2),3)),(5,(14,4))),((((6,15),11),8),10)),1);
+   tree rep.7380000 = (12,((((4,((7,13),14)),5),((2,9),3)),(((15,11),6),(8,10))),1);
+   tree rep.7390000 = ((((10,8),((15,6),11)),(14,((4,(13,7)),(5,(3,(9,2)))))),12,1);
+   tree rep.7400000 = (12,(((14,(4,(7,13))),(5,(3,(9,2)))),((8,10),((6,15),11))),1);
+   tree rep.7410000 = (12,((3,(((4,(5,14)),(13,7)),(9,2))),(8,((11,(15,6)),10))),1);
+   tree rep.7420000 = (((((11,6),15),(8,10)),(((2,9),3),((13,7),(5,(14,4))))),12,1);
+   tree rep.7430000 = ((5,(((7,13),(14,4)),((9,2),3))),(12,(8,(10,(11,(15,6))))),1);
+   tree rep.7440000 = ((((5,14),(3,(2,9))),(((((11,15),6),10),8),12)),((4,7),13),1);
+   tree rep.7450000 = (12,(((5,(((7,13),4),14)),((9,2),3)),(((6,15),11),(10,8))),1);
+   tree rep.7460000 = ((((5,((3,(9,2)),(4,(13,7)))),14),(8,(10,(6,(15,11))))),12,1);
+   tree rep.7470000 = ((10,8),(((((4,(13,7)),((12,3),(2,9))),(6,(15,11))),14),5),1);
+   tree rep.7480000 = ((((3,(2,9)),(((4,14),(13,7)),5)),(10,(((15,11),6),8))),12,1);
+   tree rep.7490000 = (12,(5,((((7,13),14),4),(((6,(15,11)),(10,8)),(3,(9,2))))),1);
+   tree rep.7500000 = (((5,(((2,9),3),((14,4),(13,7)))),(((6,(11,15)),10),8)),12,1);
+   tree rep.7510000 = (((((6,(11,15)),8),10),12),(((2,9),3),(((4,(7,13)),5),14)),1);
+   tree rep.7520000 = (12,(((3,(9,2)),(5,(14,((7,13),4)))),((11,(6,15)),(8,10))),1);
+   tree rep.7530000 = (((((6,15),11),(10,8)),((3,(9,2)),(((14,4),(13,7)),5))),12,1);
+   tree rep.7540000 = ((((4,5),(14,(7,13))),((12,3),(2,9))),((8,(11,(15,6))),10),1);
+   tree rep.7550000 = (12,((8,(10,(15,(11,6)))),(5,((((9,2),3),14),(4,(13,7))))),1);
+   tree rep.7560000 = ((((((6,15),11),8),10),(5,(((4,14),(7,13)),(3,(2,9))))),12,1);
+   tree rep.7570000 = (12,(((5,(3,(9,2))),(4,(14,(7,13)))),((11,(6,15)),(10,8))),1);
+   tree rep.7580000 = ((((((11,15),6),8),10),(((7,13),((5,(3,(9,2))),14)),4)),12,1);
+   tree rep.7590000 = ((((6,11),15),(10,8)),(((3,(((14,4),(13,7)),12)),(2,9)),5),1);
+   tree rep.7600000 = (12,((8,(((5,((4,(13,14)),7)),(3,(2,9))),(11,(6,15)))),10),1);
+   tree rep.7610000 = ((5,((3,(9,2)),((4,(14,(7,13))),(((11,(15,6)),10),8)))),12,1);
+   tree rep.7620000 = (12,((10,(((15,6),11),8)),((5,((14,(13,7)),4)),(3,(9,2)))),1);
+   tree rep.7630000 = ((((6,(15,11)),8),10),(12,(((2,9),3),((4,(13,7)),(5,14)))),1);
+   tree rep.7640000 = ((14,((5,(4,(7,13))),(3,(2,9)))),(((8,10),((11,15),6)),12),1);
+   tree rep.7650000 = ((((2,9),((5,3),(14,((7,13),4)))),((8,10),(6,(11,15)))),12,1);
+   tree rep.7660000 = (((((5,3),(4,((7,13),14))),(2,9)),((8,10),(6,(11,15)))),12,1);
+   tree rep.7670000 = (12,((((7,4),13),((((2,9),3),14),5)),((10,(11,(15,6))),8)),1);
+   tree rep.7680000 = (12,((10,((6,(11,15)),8)),(14,((((7,13),4),((2,9),3)),5))),1);
+   tree rep.7690000 = (((((6,(11,15)),10),8),((4,((((9,2),3),5),14)),(7,13))),12,1);
+   tree rep.7700000 = (((((2,9),3),(((10,8),(15,(6,11))),(7,13))),(4,(14,5))),12,1);
+   tree rep.7710000 = (((((15,6),11),(10,8)),((3,(2,9)),(5,(14,(4,(7,13)))))),12,1);
+   tree rep.7720000 = (12,(((7,13),(4,(14,(((9,2),3),5)))),((8,(11,(15,6))),10)),1);
+   tree rep.7730000 = ((((5,(6,(11,15))),(((14,4),(13,7)),((9,2),3))),(8,10)),12,1);
+   tree rep.7740000 = (12,((8,(10,(6,(11,15)))),((4,((5,14),(3,(2,9)))),(13,7))),1);
+   tree rep.7750000 = ((((10,8),(6,(15,11))),((((3,(2,9)),5),14),(4,(13,7)))),12,1);
+   tree rep.7760000 = (12,((((14,(7,13)),((3,(9,2)),5)),4),(((6,(11,15)),8),10)),1);
+   tree rep.7770000 = (5,(4,(((12,((11,(15,6)),(8,10))),(13,7)),(14,((9,2),3)))),1);
+   tree rep.7780000 = (((((9,2),(((11,(15,6)),(10,8)),3)),(14,5)),((7,13),4)),12,1);
+   tree rep.7790000 = (12,(((4,(13,7)),(5,(14,(3,(9,2))))),((((15,6),11),10),8)),1);
+   tree rep.7800000 = (((8,10),(((5,14),(((9,2),3),(13,(4,7)))),(6,(15,11)))),12,1);
+   tree rep.7810000 = (((((6,15),11),8),10),(12,(((9,2),3),(((14,(7,13)),4),5))),1);
+   tree rep.7820000 = ((((9,2),3),(((7,13),(4,14)),((((6,(11,15)),8),10),5))),12,1);
+   tree rep.7830000 = ((8,(((((5,((2,9),3)),14),((4,7),13)),((11,15),6)),10)),12,1);
+   tree rep.7840000 = (12,((((4,(13,7)),14),(((2,9),3),5)),((8,((15,11),6)),10)),1);
+   tree rep.7850000 = (12,((5,(((7,13),4),(14,(3,(2,9))))),(((11,(15,6)),10),8)),1);
+   tree rep.7860000 = ((12,(3,((2,9),(14,((13,7),(5,4)))))),((10,(11,(6,15))),8),1);
+   tree rep.7870000 = (((10,(((6,15),11),8)),(((9,2),3),(5,((14,4),(7,13))))),12,1);
+   tree rep.7880000 = (12,(((9,2),3),((((((15,11),6),8),10),((5,14),(7,13))),4)),1);
+   tree rep.7890000 = (((5,((((13,7),14),4),((9,2),3))),12),(10,(8,(6,(15,11)))),1);
+   tree rep.7900000 = ((((12,(14,5)),((9,2),3)),((13,7),4)),((8,10),(11,(15,6))),1);
+   tree rep.7910000 = (((3,((9,2),((14,5),(4,(7,13))))),(((6,(11,15)),10),8)),12,1);
+   tree rep.7920000 = ((12,((10,8),(11,(15,6)))),((5,(14,((13,7),(3,(9,2))))),4),1);
+   tree rep.7930000 = ((((6,(11,15)),(10,8)),(((9,2),3),(5,((7,4),(14,13))))),12,1);
+   tree rep.7940000 = (12,(((15,(11,6)),(8,10)),((14,((3,((13,7),4)),5)),(2,9))),1);
+   tree rep.7950000 = (12,(((4,(13,7)),5),((((8,10),((15,6),11)),((2,9),3)),14)),1);
+   tree rep.7960000 = ((((((14,4),(7,13)),(3,(2,9))),5),((10,8),((15,11),6))),12,1);
+   tree rep.7970000 = (((3,(2,9)),((5,(10,(((6,15),11),8))),(14,(4,(7,13))))),12,1);
+   tree rep.7980000 = (12,((((6,(15,11)),8),10),((((3,2),9),5),((13,(7,4)),14))),1);
+   tree rep.7990000 = ((((((7,13),14),4),5),(3,(2,9))),(12,((10,8),((11,15),6))),1);
+   tree rep.8000000 = (((((11,15),6),(8,10)),((3,(2,9)),(5,((7,13),(14,4))))),12,1);
+   tree rep.8010000 = (12,(((4,(9,(3,2))),((((10,8),((11,15),6)),14),5)),(13,7)),1);
+   tree rep.8020000 = (((3,(((2,9),5),14)),((13,7),4)),(12,(((15,11),6),(8,10))),1);
+   tree rep.8030000 = (12,(((3,(2,9)),((14,((7,13),4)),5)),((10,8),((6,15),11))),1);
+   tree rep.8040000 = ((((10,8),((11,15),6)),(((2,9),3),(14,(4,(5,(7,13)))))),12,1);
+   tree rep.8050000 = ((((10,8),((6,11),15)),(((5,14),((7,13),4)),(3,(2,9)))),12,1);
+   tree rep.8060000 = (12,(((8,10),((15,6),11)),(5,(((7,13),(4,14)),((9,2),3)))),1);
+   tree rep.8070000 = ((((4,(7,13)),((14,5),(3,(2,9)))),(10,(8,((11,15),6)))),12,1);
+   tree rep.8080000 = (((8,(10,((6,15),11))),(((3,(9,2)),5),(14,((7,13),4)))),12,1);
+   tree rep.8090000 = ((((((7,13),4),(5,14)),(3,(9,2))),(10,(8,(11,(15,6))))),12,1);
+   tree rep.8100000 = (((14,((4,(13,7)),(5,((2,9),3)))),((((6,11),15),8),10)),12,1);
+   tree rep.8110000 = (((((6,15),11),(10,8)),(((14,(4,(13,7))),((2,9),3)),5)),12,1);
+   tree rep.8120000 = (((5,(((9,2),3),(14,((7,13),4)))),(8,((15,(6,11)),10))),12,1);
+   tree rep.8130000 = ((((8,10),((6,15),11)),(((13,7),4),((5,(3,(9,2))),14))),12,1);
+   tree rep.8140000 = (12,(((8,((6,15),11)),10),((4,(13,(14,7))),((3,(9,2)),5))),1);
+   tree rep.8150000 = (((5,((((7,13),4),(3,(2,9))),14)),((((11,15),6),10),8)),12,1);
+   tree rep.8160000 = (12,((((((7,13),5),4),((9,2),3)),14),(8,(10,(6,(15,11))))),1);
+   tree rep.8170000 = (((((9,2),3),(((13,7),4),14)),((((11,6),15),(8,10)),5)),12,1);
+   tree rep.8180000 = (12,(((((6,15),11),8),10),(((3,(5,(2,9))),(4,14)),(13,7))),1);
+   tree rep.8190000 = (12,(((8,(6,(15,11))),10),((5,(3,(2,9))),((4,(13,7)),14))),1);
+   tree rep.8200000 = (12,((5,((3,(9,2)),((4,(13,7)),14))),(((15,11),6),(10,8))),1);
+   tree rep.8210000 = (((2,9),(5,(((((6,15),11),(8,10)),(((13,4),7),14)),3))),12,1);
+   tree rep.8220000 = ((((3,(2,9)),((((7,13),14),4),5)),12),((8,10),(6,(11,15))),1);
+   tree rep.8230000 = (((((3,(2,9)),(14,((7,13),4))),5),(8,((11,(15,6)),10))),12,1);
+   tree rep.8240000 = (((((11,(6,15)),10),8),(((3,(2,9)),12),5)),(((7,13),4),14),1);
+   tree rep.8250000 = ((((((13,7),14),4),(5,(3,(2,9)))),((((6,15),11),8),10)),12,1);
+   tree rep.8260000 = (12,(((11,(6,15)),(10,8)),((((13,7),(4,14)),5),((2,9),3))),1);
+   tree rep.8270000 = (((((4,14),(13,7)),(((2,9),3),5)),((8,(6,(11,15))),10)),12,1);
+   tree rep.8280000 = (12,(((((6,(11,15)),10),8),(((13,7),(14,4)),(3,(2,9)))),5),1);
+   tree rep.8290000 = (((10,(8,((11,15),6))),((2,(9,3)),(5,(((7,13),4),14)))),12,1);
+   tree rep.8300000 = ((((8,10),((11,15),6)),(5,((((13,7),4),(3,(9,2))),14))),12,1);
+   tree rep.8310000 = (12,(((5,14),(((13,7),4),(3,(2,9)))),((10,8),(6,(11,15)))),1);
+   tree rep.8320000 = (12,((10,(8,(11,(15,6)))),(((3,(2,9)),((13,7),4)),(14,5))),1);
+   tree rep.8330000 = ((14,((8,(10,(6,(11,15)))),(((13,7),4),((3,(9,2)),5)))),12,1);
+   tree rep.8340000 = ((((((2,9),3),(((7,13),4),14)),5),(8,(10,(11,(15,6))))),12,1);
+   tree rep.8350000 = (12,((10,((6,(15,11)),8)),(14,((4,(((2,9),3),5)),(7,13)))),1);
+   tree rep.8360000 = (12,((8,(10,((11,15),6))),(((3,(9,2)),(14,(13,(4,7)))),5)),1);
+   tree rep.8370000 = (12,((10,(((6,15),11),8)),((4,(14,(13,7))),(5,((9,2),3)))),1);
+   tree rep.8380000 = ((((9,2),3),((4,(13,7)),(5,14))),(12,((((6,11),15),10),8)),1);
+   tree rep.8390000 = (12,(((((14,5),4),(7,13)),((9,2),3)),(((11,15),6),(8,10))),1);
+   tree rep.8400000 = (12,((8,((11,(6,15)),10)),((((14,(7,13)),4),5),((2,9),3))),1);
+   tree rep.8410000 = (((((11,15),6),(8,10)),(((((7,13),14),4),5),(3,(9,2)))),12,1);
+   tree rep.8420000 = (12,(((10,8),(11,(15,6))),(((13,(7,4)),14),((3,(9,2)),5))),1);
+   tree rep.8430000 = (12,((((7,13),4),((5,((2,9),3)),14)),(((11,(6,15)),8),10)),1);
+   tree rep.8440000 = (5,((14,((7,13),4)),((12,(3,(9,2))),(((11,15),6),(10,8)))),1);
+   tree rep.8450000 = ((4,(((7,13),((12,14),5)),((2,9),3))),((((15,11),6),10),8),1);
+   tree rep.8460000 = (((3,(2,9)),((4,(13,7)),((5,14),((8,10),((15,11),6))))),12,1);
+   tree rep.8470000 = (12,(((5,((9,2),3)),(14,(7,(13,4)))),((6,(11,15)),(8,10))),1);
+   tree rep.8480000 = (12,(((((15,6),11),10),8),((3,((14,(13,7)),4)),(5,(2,9)))),1);
+   tree rep.8490000 = ((((5,4),(((3,(2,9)),(((6,15),11),(8,10))),(13,7))),14),12,1);
+   tree rep.8500000 = (12,(((10,8),(6,(15,11))),((5,(3,((4,14),(7,13)))),(9,2))),1);
+   tree rep.8510000 = (((14,((((6,(11,15)),(10,8)),((2,9),3)),5)),(4,(7,13))),12,1);
+   tree rep.8520000 = ((((4,((13,7),14)),((3,(9,2)),5)),(((6,(15,11)),8),10)),12,1);
+   tree rep.8530000 = (12,(((5,(((7,13),4),14)),((2,3),9)),((8,10),((11,15),6))),1);
+   tree rep.8540000 = (12,(((8,10),(11,(15,6))),((5,(((13,7),4),14)),(3,(2,9)))),1);
+   tree rep.8550000 = ((((6,(15,11)),(10,8)),(((13,7),4),(12,((9,2),3)))),(14,5),1);
+   tree rep.8560000 = ((((10,8),((15,11),6)),((((9,2),3),5),((13,7),(4,14)))),12,1);
+   tree rep.8570000 = (12,(((10,((11,15),6)),8),(5,((3,(9,2)),(14,(4,(7,13)))))),1);
+   tree rep.8580000 = (((((15,6),11),10),8),(12,(((4,(13,7)),14),(5,((9,2),3)))),1);
+   tree rep.8590000 = ((((3,((13,7),(2,9))),(14,(5,4))),((((6,15),11),10),8)),12,1);
+   tree rep.8600000 = (((5,((2,9),3)),(4,((8,10),((6,15),11)))),(((7,13),14),12),1);
+   tree rep.8610000 = (((((7,13),4),(5,(((2,9),3),14))),((10,(6,(11,15))),8)),12,1);
+   tree rep.8620000 = (((10,(11,(15,6))),8),((5,((14,(4,(13,7))),(3,(2,9)))),12),1);
+   tree rep.8630000 = ((((((15,11),6),8),10),(((5,(3,(2,9))),14),((4,7),13))),12,1);
+   tree rep.8640000 = ((((5,((8,10),(6,(15,11)))),(((7,13),4),14)),((2,9),3)),12,1);
+   tree rep.8650000 = (12,(((((9,2),3),(4,(5,(13,7)))),14),((10,8),((11,15),6))),1);
+   tree rep.8660000 = (((12,5),(9,2)),(((3,((8,((11,15),6)),10)),(14,4)),(13,7)),1);
+   tree rep.8670000 = (12,(((8,10),((15,6),11)),(((14,4),(7,13)),(5,(3,(9,2))))),1);
+   tree rep.8680000 = ((((14,((13,7),4)),(5,(3,(2,9)))),((6,(11,15)),(10,8))),12,1);
+   tree rep.8690000 = (((((3,(9,2)),(4,((13,7),14))),5),((10,8),((15,6),11))),12,1);
+   tree rep.8700000 = (12,((10,((11,(6,15)),8)),(5,(((7,13),(14,4)),(3,(9,2))))),1);
+   tree rep.8710000 = (12,((10,8),((((9,2),3),((14,((13,7),4)),5)),(11,(6,15)))),1);
+   tree rep.8720000 = (12,(((3,(9,2)),(14,5)),(((7,13),4),((10,(11,(6,15))),8))),1);
+   tree rep.8730000 = (12,(5,(((4,14),((7,13),((9,2),3))),(((6,15),11),(8,10)))),1);
+   tree rep.8740000 = (((((((13,7),4),14),(3,(9,2))),5),((6,(11,15)),(8,10))),12,1);
+   tree rep.8750000 = (((10,(8,(11,(15,6)))),((((13,7),4),((2,9),3)),(5,14))),12,1);
+   tree rep.8760000 = ((((((2,9),3),((7,13),(4,14))),5),((10,((6,15),11)),8)),12,1);
+   tree rep.8770000 = (((((11,(6,15)),(10,8)),((((7,13),4),((2,9),3)),14)),5),12,1);
+   tree rep.8780000 = (12,(((5,((14,((7,13),4)),((10,8),((15,11),6)))),3),(2,9)),1);
+   tree rep.8790000 = (12,(((10,8),((15,6),11)),(((5,14),(3,(9,2))),((7,13),4))),1);
+   tree rep.8800000 = (12,((((5,14),(4,(13,7))),(3,(9,2))),((8,10),(11,(6,15)))),1);
+   tree rep.8810000 = (((((15,6),11),(8,10)),((((4,(13,7)),14),5),((2,9),3))),12,1);
+   tree rep.8820000 = (12,((3,(2,9)),(((14,5),((6,(15,11)),(10,8))),((7,13),4))),1);
+   tree rep.8830000 = (12,(((3,(2,9)),(((14,5),4),(13,7))),((10,((6,15),11)),8)),1);
+   tree rep.8840000 = ((12,((((3,(2,9)),4),5),(14,(7,13)))),((((11,15),6),8),10),1);
+   tree rep.8850000 = (12,((3,(9,2)),(((((15,11),6),8),10),(5,(14,(13,(4,7)))))),1);
+   tree rep.8860000 = (12,((3,(5,((9,2),((13,7),(14,4))))),(8,(((6,15),11),10))),1);
+   tree rep.8870000 = (12,((((2,9),3),((14,5),((10,(6,(11,15))),8))),(4,(7,13))),1);
+   tree rep.8880000 = (12,((((9,2),3),((14,4),(13,7))),(5,((8,10),((6,15),11)))),1);
+   tree rep.8890000 = (12,(((((13,7),4),5),14),(((9,2),3),(((15,6),11),(8,10)))),1);
+   tree rep.8900000 = ((((6,(11,15)),(8,10)),(((3,(2,9)),(13,(7,(4,14)))),5)),12,1);
+   tree rep.8910000 = ((5,(((8,10),(6,(11,15))),(((7,13),(14,4)),((2,9),3)))),12,1);
+   tree rep.8920000 = (12,(((((7,13),4),(14,5)),((9,2),3)),(((11,(6,15)),10),8)),1);
+   tree rep.8930000 = (12,(((8,((15,6),11)),10),(((14,(4,5)),(13,7)),(3,(2,9)))),1);
+   tree rep.8940000 = (12,(((3,(2,9)),((13,7),(14,(4,5)))),(((6,(15,11)),10),8)),1);
+   tree rep.8950000 = (12,(((3,(2,9)),((5,4),(14,(13,7)))),(((11,15),6),(10,8))),1);
+   tree rep.8960000 = ((12,((10,(11,(15,6))),8)),((3,(2,9)),(5,(14,((7,13),4)))),1);
+   tree rep.8970000 = (12,(((3,(2,9)),((14,((7,13),5)),4)),(10,(8,((15,6),11)))),1);
+   tree rep.8980000 = (12,((((14,5),(13,(4,7))),((2,9),3)),((((15,6),11),8),10)),1);
+   tree rep.8990000 = ((((11,(6,15)),(8,10)),12),((((((9,2),3),5),14),4),(13,7)),1);
+   tree rep.9000000 = ((((3,(9,2)),((((13,7),4),14),5)),((10,8),((15,11),6))),12,1);
+   tree rep.9010000 = ((((8,(11,(6,15))),10),(((3,(9,2)),14),(((13,7),4),5))),12,1);
+   tree rep.9020000 = ((((3,(5,(9,2))),14),(4,(7,13))),(12,((8,10),(6,(11,15)))),1);
+   tree rep.9030000 = ((((13,7),(4,14)),(5,(3,(9,2)))),(((10,((6,15),11)),8),12),1);
+   tree rep.9040000 = ((((7,13),4),(((2,9),3),(14,5))),((10,(8,((11,15),6))),12),1);
+   tree rep.9050000 = ((((((9,2),3),4),((10,(8,((6,15),11))),(14,(13,7)))),5),12,1);
+   tree rep.9060000 = (12,((((6,15),11),(10,8)),(((9,2),3),(((14,(7,13)),4),5))),1);
+   tree rep.9070000 = (((10,8),((((14,4),(7,13)),5),((11,(15,6)),((2,9),3)))),12,1);
+   tree rep.9080000 = (12,((((13,7),(14,4)),((8,10),(11,(15,6)))),((2,9),(5,3))),1);
+   tree rep.9090000 = (((((2,9),3),((((7,13),14),4),(((15,6),11),(8,10)))),5),12,1);
+   tree rep.9100000 = ((((((2,9),3),(4,(7,13))),(5,14)),(((15,11),6),(10,8))),12,1);
+   tree rep.9110000 = (12,(((3,(9,2)),(((13,7),4),(14,5))),(8,(10,((11,15),6)))),1);
+   tree rep.9120000 = (12,(14,((2,9),(((7,13),(5,((((15,6),11),(8,10)),4))),3))),1);
+   tree rep.9130000 = ((((14,(7,13)),(4,((3,(9,2)),5))),((((6,15),11),10),8)),12,1);
+   tree rep.9140000 = (((((((6,15),11),(8,10)),(14,(4,(13,7)))),(9,(2,3))),5),12,1);
+   tree rep.9150000 = (((8,((11,(15,6)),10)),(((3,(2,9)),((7,13),(14,4))),5)),12,1);
+   tree rep.9160000 = ((12,((10,(11,(15,6))),8)),(((((7,13),4),14),(3,(2,9))),5),1);
+   tree rep.9170000 = (((((6,(15,11)),10),8),((((4,(7,13)),14),((2,9),3)),5)),12,1);
+   tree rep.9180000 = ((((9,2),3),((((11,15),6),(8,10)),((13,7),(4,(5,14))))),12,1);
+   tree rep.9190000 = ((((11,6),15),(10,8)),(12,(5,(((2,9),3),(14,((7,13),4))))),1);
+   tree rep.9200000 = (((((2,9),3),((6,(15,11)),(10,8))),((14,4),((7,13),5))),12,1);
+   tree rep.9210000 = ((10,(8,((15,11),6))),((5,(((7,13),(14,4)),((2,9),3))),12),1);
+   tree rep.9220000 = (((10,(8,((((13,7),(((9,2),3),4)),14),5))),((6,15),11)),12,1);
+   tree rep.9230000 = (((((((7,13),(14,4)),(((2,9),3),5)),12),8),10),((15,6),11),1);
+   tree rep.9240000 = (12,((10,(8,(15,(6,11)))),((5,((13,7),(14,4))),((9,2),3))),1);
+   tree rep.9250000 = (((((4,(13,7)),5),(((9,2),3),14)),((6,(15,11)),(8,10))),12,1);
+   tree rep.9260000 = (((((15,6),11),(8,10)),(((7,13),14),(4,(5,(3,(2,9)))))),12,1);
+   tree rep.9270000 = ((14,(5,((4,(13,7)),((((11,(15,6)),8),10),((9,2),3))))),12,1);
+   tree rep.9280000 = (((((3,(2,9)),((4,14),(7,13))),5),(8,(10,((11,15),6)))),12,1);
+   tree rep.9290000 = (12,(((11,(6,15)),(8,10)),(((2,9),3),(4,((13,(5,14)),7)))),1);
+   tree rep.9300000 = (((8,10),(11,(6,15))),(12,(((3,(2,9)),5),((14,(13,7)),4))),1);
+   tree rep.9310000 = ((((15,6),11),((((13,7),4),14),((2,9),(3,(12,5))))),(10,8),1);
+   tree rep.9320000 = (12,(((8,10),(6,(15,11))),((13,(((14,((9,2),3)),7),5)),4)),1);
+   tree rep.9330000 = (12,(((5,14),((3,(2,9)),(((15,11),6),(10,8)))),(4,(7,13))),1);
+   tree rep.9340000 = (12,(((((2,9),3),5),((14,(13,7)),4)),(((15,6),11),(10,8))),1);
+   tree rep.9350000 = (((((((13,7),14),4),5),(3,(9,2))),((8,10),(11,(15,6)))),12,1);
+   tree rep.9360000 = (12,((5,((3,(9,2)),((4,(7,13)),14))),((10,((11,15),6)),8)),1);
+   tree rep.9370000 = ((((3,(9,2)),(14,(5,((13,7),4)))),(((11,15),6),(8,10))),12,1);
+   tree rep.9380000 = ((((6,(15,11)),(10,8)),(((4,(7,13)),(5,14)),(3,(9,2)))),12,1);
+   tree rep.9390000 = (12,(((((3,(2,9)),5),4),((13,7),14)),((8,10),(6,(11,15)))),1);
+   tree rep.9400000 = ((((3,(9,2)),(((13,7),14),4)),5),(12,((10,((6,15),11)),8)),1);
+   tree rep.9410000 = ((((3,(2,9)),(((7,13),4),14)),5),(12,(8,(10,((11,15),6)))),1);
+   tree rep.9420000 = (12,((8,(((15,6),11),10)),((4,((7,13),14)),(5,((9,2),3)))),1);
+   tree rep.9430000 = (((3,(9,2)),((((11,(6,15)),(10,8)),((4,14),(7,13))),5)),12,1);
+   tree rep.9440000 = ((12,(8,10)),(((15,6),11),((((2,9),3),4),((14,5),(13,7)))),1);
+   tree rep.9450000 = (12,((8,10),(((11,6),15),(5,((3,(2,9)),((4,(13,7)),14))))),1);
+   tree rep.9460000 = (((14,(((2,9),3),4)),(((((11,15),6),8),(12,10)),(7,13))),5,1);
+   tree rep.9470000 = (12,((((7,13),4),((10,8),(15,(6,11)))),(5,(((2,9),3),14))),1);
+   tree rep.9480000 = ((3,(((((8,10),(11,(15,6))),5),(14,((7,13),4))),(2,9))),12,1);
+   tree rep.9490000 = (12,(((3,(9,2)),((((7,13),4),14),5)),(((15,6),11),(10,8))),1);
+   tree rep.9500000 = (12,((((3,(2,9)),(4,(14,(13,7)))),5),((10,((6,15),11)),8)),1);
+   tree rep.9510000 = ((((5,14),(((2,9),3),((13,7),4))),(((6,15),11),(10,8))),12,1);
+   tree rep.9520000 = (((((9,2),3),12),(5,((4,(7,13)),14))),(((6,15),11),(8,10)),1);
+   tree rep.9530000 = (12,((5,(((14,4),(13,7)),((2,9),3))),((11,(15,6)),(10,8))),1);
+   tree rep.9540000 = (12,((10,(8,((11,15),6))),(((((13,7),4),14),(3,(2,9))),5)),1);
+   tree rep.9550000 = (((((2,9),3),((4,(13,7)),14)),(5,(((11,(6,15)),8),10))),12,1);
+   tree rep.9560000 = ((12,(10,(8,(15,(6,11))))),((3,(2,9)),(((4,(7,13)),14),5)),1);
+   tree rep.9570000 = (((10,((6,15),11)),((((5,14),(7,13)),(4,(3,(2,9)))),8)),12,1);
+   tree rep.9580000 = (((14,((13,7),4)),((3,(2,9)),5)),(12,(((6,(15,11)),8),10)),1);
+   tree rep.9590000 = (((((((2,9),3),5),(4,(7,13))),14),12),(((11,15),6),(10,8)),1);
+   tree rep.9600000 = ((((8,10),(15,(11,6))),(5,((4,((7,13),14)),((9,2),3)))),12,1);
+   tree rep.9610000 = (((((6,15),11),(8,10)),((3,(9,2)),(((13,7),4),(5,14)))),12,1);
+   tree rep.9620000 = (((((14,(4,(7,13))),((9,2),3)),5),(((6,(11,15)),10),8)),12,1);
+   tree rep.9630000 = (((5,((9,2),3)),(((6,(15,11)),(8,10)),(14,((7,13),4)))),12,1);
+   tree rep.9640000 = (12,((5,(((7,(13,4)),(((11,(15,6)),8),10)),14)),((9,2),3)),1);
+   tree rep.9650000 = ((((5,(3,(2,9))),(14,(4,(7,13)))),12),((8,((15,6),11)),10),1);
+   tree rep.9660000 = (12,((8,((6,(15,11)),10)),((3,(2,9)),(((5,(13,7)),4),14))),1);
+   tree rep.9670000 = (12,(((6,(15,11)),(8,10)),((4,(7,13)),((14,5),(3,(2,9))))),1);
+   tree rep.9680000 = ((((6,(11,15)),(10,8)),((14,((13,7),4)),(((2,9),3),5))),12,1);
+   tree rep.9690000 = (((((2,9),3),(((13,7),4),14)),(((6,(15,11)),(10,8)),5)),12,1);
+   tree rep.9700000 = ((((6,(11,15)),8),10),((5,(3,(9,2))),((((13,7),4),12),14)),1);
+   tree rep.9710000 = ((((13,7),((5,14),(4,((9,2),3)))),((8,10),(6,(15,11)))),12,1);
+   tree rep.9720000 = (12,(((8,10),(11,(6,15))),(((5,(3,(9,2))),(4,(7,13))),14)),1);
+   tree rep.9730000 = (((10,8),((15,6),11)),(((2,9),((5,(13,7)),3)),(12,(4,14))),1);
+   tree rep.9740000 = (12,(((8,10),(6,(15,11))),(((3,(2,9)),5),(14,(4,(13,7))))),1);
+   tree rep.9750000 = (((((9,2),3),(5,(4,((7,13),14)))),12),((8,10),((6,15),11)),1);
+   tree rep.9760000 = (12,(((5,((9,2),3)),((4,14),(13,7))),((((11,15),6),10),8)),1);
+   tree rep.9770000 = ((((10,((6,15),11)),8),((9,(2,3)),((4,((7,13),14)),5))),12,1);
+   tree rep.9780000 = ((((14,(5,(3,(2,9)))),(7,(4,13))),12),(10,(((11,15),6),8)),1);
+   tree rep.9790000 = (12,(((((9,2),3),(4,(13,7))),(14,5)),((6,(11,15)),(8,10))),1);
+   tree rep.9800000 = (12,(((10,8),((6,15),11)),((5,((4,(13,7)),14)),((9,2),3))),1);
+   tree rep.9810000 = ((((6,(15,11)),(8,10)),((5,14),((7,(13,4)),(3,(2,9))))),12,1);
+   tree rep.9820000 = (((((3,(9,2)),((7,13),(4,14))),((6,(15,11)),(10,8))),5),12,1);
+   tree rep.9830000 = ((12,((3,(9,2)),(((4,(7,13)),5),14))),((((15,11),6),10),8),1);
+   tree rep.9840000 = (12,(((((11,15),6),10),8),(((14,((13,7),4)),5),((9,2),3))),1);
+   tree rep.9850000 = ((12,(((4,((2,9),3)),(14,(7,13))),5)),(10,(8,((6,15),11))),1);
+   tree rep.9860000 = ((((11,(6,15)),(10,8)),(14,(((7,4),13),(5,(3,(9,2)))))),12,1);
+   tree rep.9870000 = (((8,((6,15),11)),10),(12,(3,((14,4),(((9,2),5),(13,7))))),1);
+   tree rep.9880000 = (((14,(((4,(13,7)),5),((2,9),3))),((((6,15),11),8),10)),12,1);
+   tree rep.9890000 = (12,(((5,((13,7),(4,14))),((2,9),3)),((((11,15),6),10),8)),1);
+   tree rep.9900000 = (12,(((10,8),(6,(15,11))),(((14,((7,13),4)),5),(3,(9,2)))),1);
+   tree rep.9910000 = (12,(((((14,4),(7,13)),((8,((11,15),6)),10)),(3,(9,2))),5),1);
+   tree rep.9920000 = (12,((10,((6,(11,15)),8)),((5,14),((3,(9,2)),(4,(7,13))))),1);
+   tree rep.9930000 = (((3,(9,2)),(((14,(7,13)),4),(5,(10,(8,(11,(6,15))))))),12,1);
+   tree rep.9940000 = ((((5,((9,2),3)),((13,7),(14,4))),(8,(((11,15),6),10))),12,1);
+   tree rep.9950000 = (12,(((10,((15,6),11)),8),(5,(((13,(14,7)),4),(3,(2,9))))),1);
+   tree rep.9960000 = (12,((((4,((7,13),14)),((9,2),3)),((8,10),(11,(15,6)))),5),1);
+   tree rep.9970000 = ((((3,(2,9)),(10,(8,((11,6),15)))),(4,((5,14),(7,13)))),12,1);
+   tree rep.9980000 = (((8,(10,((11,6),15))),((((14,(7,13)),4),5),((2,9),3))),12,1);
+   tree rep.9990000 = (12,((8,(10,((15,11),6))),((((13,7),(14,4)),((9,2),3)),5)),1);
+   tree rep.10000000 = (((((6,(11,15)),10),8),(((4,(13,7)),(5,(3,(2,9)))),14)),12,1);
+end;
diff --git a/inst/extdata/trees/woodmouse.nxs b/inst/extdata/trees/woodmouse.nxs
new file mode 100644
index 0000000..3f8a27b
--- /dev/null
+++ b/inst/extdata/trees/woodmouse.nxs
@@ -0,0 +1,517 @@
+#nexus
+
+BEGIN Taxa;
+DIMENSIONS ntax=15;
+TAXLABELS
+[1] 'No305'
+[2] 'No304'
+[3] 'No306'
+[4] 'No0906S'
+[5] 'No0908S'
+[6] 'No0909S'
+[7] 'No0910S'
+[8] 'No0912S'
+[9] 'No0913S'
+[10] 'No1103S'
+[11] 'No1007S'
+[12] 'No1114S'
+[13] 'No1202S'
+[14] 'No1206S'
+[15] 'No1208S'
+;
+END; [Taxa]
+
+BEGIN Characters;
+DIMENSIONS nchar=965;
+FORMAT
+ datatype=DNA missing=? gap=- symbols="atgc" labels=left transpose=no interleave=no;
+MATRIX
+'No305'   nttcgaaaaacacacccactactaaaanttatcagtcactccttcatcgacttaccagctccatctaacatttcatcatgatgaaacttcggctcattactaggagtctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgtcgagacgtaaattatggctgactaattcgatacatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatgtattacgggtcatacattttcatagaaacatgaaacatcggtgtggtccttttattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaanttactatcagcaattccatacatcggaactaccctagtagagtgaat [...]
+'No304'   attcgaaaaacacacccactactaaaaattatcaaccactccttcatcgacttaccagctccatctaacatttcatcatgatgaaacttcggctcattactaggaatctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgtcgagacgtaaattatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatgtattacgggtcatacatttttatagaaacatgaaacatcggtgtagtccttttattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattncaaatttactntcagcaattccatacatcggaactaccctagtagaatgaat [...]
+'No306'   attcgaaaaacacacccactactaaaaattatcaatcactccttcatcgacttaccagctccatctaacatttcatcatgatgaaacttcggctcattactaggaatctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgtcgagacgtaaattatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatgtattacgggtcatacatttttatagaaacatgaaacatcggtgtgatccttttattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaatttactatcagcaattccatacatcggaactaccctagtagaatgaat [...]
+'No0906S' attcgaaaaacacacccactactaaaaatcatcaatcactccttcatcgatttaccagctccatctaacatttcatcatgatgaaacttcggctcattactaggaatctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgtcgagacgtaaattatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatgtattacggatcatacatttttatagaaacatgaaacatcggtatgatccttttattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaatttactatcagcaattccatacatcggaactaccctagtagagtgaat [...]
+'No0908S' attcgaaaaacacacccactactaaaaattatcaatcactccttcatcgacttaccagccccatctaacatttcatcatgatgaaacttcggctcattactaggaatctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgtcgagacgtaaattatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttctccatgtaggacgaggaatgtattacgggtcatacatttttatagaaacatgaaacatcggtgtgatccttttattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggggctacagtaattacaaatttactatcagcaattccatatatcggaactaccctagtagagtgaat [...]
+'No0909S' attcgaaaaacacacccactactaaaaattatcaatcactccttcatcgacttaccagctccatctaacatctcatcatgatgaaacttcggctccttactaggaatctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgtcgagacgtaaactatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatgtattacgggtcatacactttcatagaaacatgaaacatcggtgtgatccttctattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaatttactatcagcaattccatacatcgggactaccctagtagagtgaat [...]
+'No0910S' attcgaaaaacacacccactactaaaaattatcaatcactctttcatcgatttaccagctccatctaacatttcatcatgatgaaacttcggctcattactaggaatctgcctaataatccagatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgtcgagacgtaaattatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatgtattacggatcatacatttttatagaaacatgaaacatcggtgtgatccttttattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaatttactatcagcaattccatacatcggaactaccctagtagagtgaat [...]
+'No0912S' attcgaaaaacacacccactactaaaaattatcaatcactccttcatcgacttaccagctccatctaacatctcatcatgatgaaacttcggctccttactaggaatctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgtcgagacgtaaattatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacggggaatgtattacgggtcatacattttcatagaaacatgaaacatcggtgtgatccttttattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaatttactatcagcaattccatacatcggaactaccctagtagagtgaat [...]
+'No0913S' attcgaaaaacacacccactactaaaaattatcaaccactccttcatcgacttaccagctccatctaacatttcatcatgatgaaacttcggctcattactaggaatctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgtcgagacgtaaattatggctgactaattcgatatatgcatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatgtattacggatcatacatttttatagaaacatgaaacatcggtgtgatccttttattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaatttactatcagcaattccatacatcggaactaccctagtagaatgaat [...]
+'No1103S' attcgaaaaacacacccactactaaaaattattaatcactccttcatcgacttaccagctccatctaacatctcatcatgatgaaacttcggctccttactaggaatctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgtcgagacgtaaattatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatgtattacgggtcatacattttcatagaaacatgaaacatcggtgtgatccttttattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaatttactatcagcaattccatacatcggaactaccctagtagagtgaat [...]
+'No1007S' attcgaaaaacacacccactactaaaaattatcaatcactccttcatcgacttaccagctccatctaacatctcatcatgatgaaacttcggctccttactaggaatctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgccgagacgtaaattatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatgtattacgggtcatacactttcatagaaacatgaaacatcggtgtgatccttctattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaatttactatcagcaattccatacatcgggactaccctagtagagtgaat [...]
+'No1114S' nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnatcgacttaccagctccatctaacatttcatcatgatgaaacttcggctcattactaggagtctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagnaacccatatttgccgagacgtaaattatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatatattacggctcatacattctcatagaaacatgaaacatcggtgtggtccttttattcgcagtaatagtcacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaatttcctatcagcaattccatacatcggaactaccctagtagagtgaat [...]
+'No1202S' attcgaaaaacacacccactactaaaaattatcaatcactccttcatcgatttaccagctccatctaacatttcatcatgatgaaacttcggctcattactaggaatctgcctaataatccagatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgccgagacgtaaattatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatgtattacggatcatacatttttatagaaacatgaaacatcggtgtgatccttttattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaatttactatcagcaattccatacatcggaactaccctagtagagtgaat [...]
+'No1206S' attcgaaaaacacacccactactaaaaattatcaatcactccttcatcgatttgccagctccatctaacatttcatcatgatgaaacttcggctcattactaggaatctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgtcgagacgtaaattatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttctccatgtaggacgaggaatgtattacgggtcatacatttttatagaaacatgaaacatcggtgtgatccttttattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccttctgaggagctacagtaattacaaatttactatcagcaattccatacatcggaactaccctagtagagtgaat [...]
+'No1208S' nnncgaaaaacacacccactactaaaaattatcaatcactccttcatcgacttaccagctccatctaacatctcatcatgatgaaacttcggctccttactaggaatctgcctaataatccaaatcctcacaggcttattcctagcaatacactacacatcagacacaataacagcattctcttcagtaacccatatttgccgagacgtaaactatggctgactaattcgatatatacatgcaaacggagcctcaatattttttatttgcctatttcttcatgtaggacgaggaatgtattacgggtcatacactttcatagaaacatgaaacatcggtgtgatccttctattcgcagtaatagccacagcattcataggatatgttcttccatgaggacaaatatccctctgaggagctacagtaattacaaatttactatcagcaattccatacatcgggactaccctagtagagtgaat [...]
+;
+END; [Characters]
+
+BEGIN Distances;
+DIMENSIONS ntax=15;
+FORMAT labels=left diagonal triangle=both;
+MATRIX
+[1] 'No305'     0.0 0.016684046 0.013541667 0.018789144 0.016701462 0.016701462 0.017745303 0.014613778 0.018789144 0.012526096 0.016701462 0.015317286 0.016701462 0.016701462 0.018828452
+[2] 'No304'     0.016684046 0.0 0.0052083335 0.0135557875 0.0114702815 0.015641293 0.012513034 0.0135557875 0.0052137645 0.0114702815 0.015641293 0.016429354 0.0114702815 0.012513034 0.017782427
+[3] 'No306'     0.013541667 0.0052083335 0.0 0.0093847755 0.00729927 0.0114702815 0.008342023 0.0093847755 0.0052137645 0.00729927 0.0114702815 0.015334063 0.00729927 0.008342023 0.013598327
+[4] 'No0906S'   0.018789144 0.0135557875 0.0093847755 0.0 0.012486992 0.016649324 0.009365245 0.014568158 0.012486992 0.012486992 0.016649324 0.020765027 0.008324662 0.01144641 0.018789144
+[5] 'No0908S'   0.016701462 0.0114702815 0.00729927 0.012486992 0.0 0.014568158 0.01144641 0.012486992 0.012486992 0.010405827 0.014568158 0.020765027 0.010405827 0.009365245 0.016701462
+[6] 'No0909S'   0.016701462 0.015641293 0.0114702815 0.016649324 0.014568158 0.0 0.015608741 0.010405827 0.016649324 0.008324662 0.0020811656 0.020765027 0.014568158 0.015608741 0.0020876827
+[7] 'No0910S'   0.017745303 0.012513034 0.008342023 0.009365245 0.01144641 0.015608741 0.0 0.013527576 0.009365245 0.01144641 0.015608741 0.019672131 0.003121748 0.010405827 0.017745303
+[8] 'No0912S'   0.014613778 0.0135557875 0.0093847755 0.014568158 0.012486992 0.010405827 0.013527576 0.0 0.014568158 0.004162331 0.010405827 0.018579235 0.012486992 0.013527576 0.012526096
+[9] 'No0913S'   0.018789144 0.0052137645 0.0052137645 0.012486992 0.012486992 0.016649324 0.009365245 0.014568158 0.0 0.012486992 0.016649324 0.018579235 0.008324662 0.013527576 0.018789144
+[10] 'No1103S'   0.012526096 0.0114702815 0.00729927 0.012486992 0.010405827 0.008324662 0.01144641 0.004162331 0.012486992 0.0 0.008324662 0.015300547 0.010405827 0.01144641 0.010438413
+[11] 'No1007S'   0.016701462 0.015641293 0.0114702815 0.016649324 0.014568158 0.0020811656 0.015608741 0.010405827 0.016649324 0.008324662 0.0 0.018579235 0.012486992 0.015608741 0.0020876827
+[12] 'No1114S'   0.015317286 0.016429354 0.015334063 0.020765027 0.020765027 0.020765027 0.019672131 0.018579235 0.018579235 0.015300547 0.018579235 0.0 0.01748634 0.021857923 0.020765027
+[13] 'No1202S'   0.016701462 0.0114702815 0.00729927 0.008324662 0.010405827 0.014568158 0.003121748 0.012486992 0.008324662 0.010405827 0.012486992 0.01748634 0.0 0.009365245 0.014613778
+[14] 'No1206S'   0.016701462 0.012513034 0.008342023 0.01144641 0.009365245 0.015608741 0.010405827 0.013527576 0.013527576 0.01144641 0.015608741 0.021857923 0.009365245 0.0 0.017745303
+[15] 'No1208S'   0.018828452 0.017782427 0.013598327 0.018789144 0.016701462 0.0020876827 0.017745303 0.012526096 0.018789144 0.010438413 0.0020876827 0.020765027 0.014613778 0.017745303 0.0
+;
+END; [Distances]
+
+BEGIN Splits;
+DIMENSIONS ntax=15 nsplits=43;
+FORMAT labels=no weights=yes confidences=no intervals=no;
+PROPERTIES fit=97.76178978414268 cyclic;
+CYCLE 1 12 3 2 9 13 7 4 14 5 11 15 6 8 10;
+MATRIX
+[1, size=1] 	 0.007878401 	  1 2 3 4 5 6 7 8 9 10 11 13 14 15,
+[2, size=4] 	 9.67039E-4 	  1 4 5 6 7 8 10 11 13 14 15,
+[3, size=7] 	 3.0405898E-4 	  1 5 6 8 10 11 14 15,
+[4, size=4] 	 8.927283E-5 	  1 6 8 10,
+[5, size=1] 	 0.006068427 	  1,
+[6, size=1] 	 4.1818016E-4 	  1 2 4 5 6 7 8 9 10 11 12 13 14 15,
+[7, size=3] 	 6.354771E-4 	  1 4 5 6 7 8 10 11 12 13 14 15,
+[8, size=7] 	 0.0018286711 	  1 6 8 10 11 12 15,
+[9, size=3] 	 3.1608884E-5 	  1 10 12,
+[10, size=2] 	 0.0030639141 	  1 12,
+[11, size=1] 	 0.0020751753 	  1 3 4 5 6 7 8 9 10 11 12 13 14 15,
+[12, size=2] 	 0.0022168073 	  1 3 4 5 6 7 8 10 11 12 13 14 15,
+[13, size=1] 	 0.0012816527 	  1 2 3 4 5 6 7 8 10 11 12 13 14 15,
+[14, size=3] 	 9.066461E-4 	  1 2 3 4 5 6 8 10 11 12 14 15,
+[15, size=4] 	 7.542655E-4 	  1 2 3 5 6 8 10 11 12 14 15,
+[16, size=5] 	 1.0719955E-4 	  1 2 3 5 6 8 10 11 12 15,
+[17, size=6] 	 6.0168037E-5 	  1 2 3 6 8 10 11 12 15,
+[18, size=1] 	 7.864587E-4 	  1 2 3 4 5 6 7 8 9 10 11 12 14 15,
+[19, size=2] 	 0.0011441667 	  1 2 3 4 5 6 8 9 10 11 12 14 15,
+[20, size=3] 	 3.7099395E-5 	  1 2 3 5 6 8 9 10 11 12 14 15,
+[21, size=4] 	 7.577939E-4 	  1 2 3 5 6 8 9 10 11 12 15,
+[22, size=6] 	 8.6808155E-5 	  1 2 3 9 10 12,
+[23, size=5] 	 1.3156666E-4 	  1 2 3 9 12,
+[24, size=1] 	 0.0020897626 	  1 2 3 4 5 6 8 9 10 11 12 13 14 15,
+[25, size=3] 	 1.0902213E-4 	  1 2 3 5 6 8 9 10 11 12 13 15,
+[26, size=4] 	 1.458757E-4 	  1 2 3 6 8 9 10 11 12 13 15,
+[27, size=1] 	 0.0051963497 	  1 2 3 5 6 7 8 9 10 11 12 13 14 15,
+[28, size=3] 	 1.40733355E-5 	  1 2 3 6 7 8 9 10 11 12 13 15,
+[29, size=1] 	 0.004156471 	  1 2 3 4 5 6 7 8 9 10 11 12 13 15,
+[30, size=2] 	 0.0010121305 	  1 2 3 4 6 7 8 9 10 11 12 13 15,
+[31, size=1] 	 0.004199673 	  1 2 3 4 6 7 8 9 10 11 12 13 14 15,
+[32, size=2] 	 8.544509E-4 	  1 2 3 4 5 6 7 8 9 10 12 13 14,
+[33, size=3] 	 0.0051881927 	  1 2 3 4 5 7 8 9 10 12 13 14,
+[34, size=4] 	 6.061471E-6 	  1 2 3 4 5 7 9 10 12 13 14,
+[35, size=5] 	 0.0010072162 	  1 2 3 4 5 7 9 12 13 14,
+[36, size=1] 	 0.0010342944 	  1 2 3 4 5 6 7 8 9 10 11 12 13 14,
+[37, size=2] 	 0.0010670845 	  1 2 3 4 5 7 8 9 10 11 12 13 14,
+[38, size=4] 	 2.1973468E-5 	  1 2 3 4 5 7 9 11 12 13 14,
+[39, size=2] 	 3.0782125E-5 	  1 2 3 4 5 7 9 10 11 12 13 14 15,
+[40, size=3] 	 7.4452415E-5 	  1 2 3 4 5 7 9 11 12 13 14 15,
+[41, size=1] 	 0.0030889313 	  1 2 3 4 5 6 7 9 10 11 12 13 14 15,
+[42, size=2] 	 0.0010669535 	  1 2 3 4 5 6 7 9 11 12 13 14 15,
+[43, size=1] 	 9.133177E-4 	  1 2 3 4 5 6 7 8 9 11 12 13 14 15,
+;
+END; [Splits]
+
+BEGIN Network;
+DIMENSIONS ntax=15 nvertices=130 nedges=215;
+DRAW to_scale;
+TRANSLATE
+2 'No305',
+3 'No1114S',
+4 'No306',
+5 'No304',
+6 'No0913S',
+7 'No1202S',
+8 'No0910S',
+9 'No0906S',
+10 'No1206S',
+11 'No0908S',
+12 'No1208S',
+13 'No0912S',
+14 'No1103S',
+117 'No1007S',
+123 'No0909S',
+;
+VERTICES
+1 -0.006068427 0.0 s=n,
+2 0.0 0.0 s=n,
+3 0.0015083641 0.0043967813 s=n,
+4 -0.009464912 0.002829434 s=n,
+5 -0.008871745 0.006696938 s=n,
+6 -0.010746697 0.0074311504 s=n,
+7 -0.013563724 0.0042226063 s=n,
+8 -0.015113663 0.004792512 s=n,
+9 -0.017300652 0.003006176 s=n,
+10 -0.016641626 -2.3478366E-4 s=n,
+11 -0.015087945 -0.0022330103 s=n,
+12 -0.009807543 -0.009778595 s=n,
+13 -0.0059371023 -0.004773448 s=n,
+14 -0.00708383 -0.002765694 s=n,
+15 -0.009065388 -6.370236E-4 s=n,
+16 -0.009096996 -6.370236E-4 s=n,
+17 -0.0061406503 5.2473253E-5 s=n,
+18 -0.009137611 -5.845503E-4 s=n,
+19 -0.009169219 -5.845503E-4 s=n,
+20 -0.009257255 -6.823234E-4 s=n,
+21 -0.009185032 -7.3479663E-4 s=n,
+22 -0.009153423 -7.3479663E-4 s=n,
+23 -0.009327484 -7.3334796E-4 s=n,
+24 -0.009255261 -7.858212E-4 s=n,
+25 -0.010392839 7.7441713E-4 s=n,
+26 -0.010480874 6.7664403E-4 s=n,
+27 -0.010551103 6.256195E-4 s=n,
+28 -0.006172433 3.5486656E-4 s=n,
+29 -0.009169393 -2.82157E-4 s=n,
+30 -0.009201002 -2.82157E-4 s=n,
+31 -0.010424622 0.0010768104 s=n,
+32 -0.010512657 9.790374E-4 s=n,
+33 -0.010582887 9.280128E-4 s=n,
+34 -0.010479588 0.001101283 s=n,
+35 -0.010567623 0.00100351 s=n,
+36 -0.010637853 9.5248537E-4 s=n,
+37 -0.01060607 6.50092E-4 s=n,
+38 -0.010566315 0.0011642933 s=n,
+39 -0.01065435 0.0010665202 s=n,
+40 -0.010724579 0.0010154956 s=n,
+41 -0.010692797 7.1310234E-4 s=n,
+42 -0.009016237 -0.0016912675 s=n,
+43 -0.008944014 -0.0017437408 s=n,
+44 -0.008873785 -0.0016927161 s=n,
+45 -0.008842176 -0.0016927161 s=n,
+46 -0.0056889136 0.0011923469 s=n,
+47 -0.008685874 5.553234E-4 s=n,
+48 -0.008717483 5.553234E-4 s=n,
+49 -0.009941103 0.0019142908 s=n,
+50 -0.009996069 0.0019387633 s=n,
+51 -0.010082795 0.0020017736 s=n,
+52 -0.010587498 0.0025623022 s=n,
+53 -0.011071017 0.0017248219 s=n,
+54 -0.011159052 0.0016270487 s=n,
+55 -0.011229281 0.0015760242 s=n,
+56 -0.01192156 0.0018842467 s=n,
+57 -0.011416858 0.0013237182 s=n,
+58 -0.011385076 0.0010213249 s=n,
+59 -0.012067436 0.0018842467 s=n,
+60 -0.011562734 0.0013237182 s=n,
+61 -0.011530952 0.0010213249 s=n,
+62 -0.010838672 7.1310234E-4 s=n,
+63 -0.010751946 6.50092E-4 s=n,
+64 -0.009015604 -0.0016972957 s=n,
+65 -0.00894338 -0.001749769 s=n,
+66 -0.009004617 -0.0017163253 s=n,
+67 -0.008932394 -0.0017687986 s=n,
+68 -0.008933027 -0.0017627702 s=n,
+69 -0.008862798 -0.0017117457 s=n,
+70 -0.008831189 -0.0017117457 s=n,
+71 -0.009744729 0.0025186655 s=n,
+72 -0.009799696 0.0025431379 s=n,
+73 -0.009886422 0.0026061484 s=n,
+74 -0.010391124 0.0031666767 s=n,
+75 -0.010844447 0.0039518555 s=n,
+76 -0.01104082 0.0033474807 s=n,
+77 -0.01152434 0.0025100003 s=n,
+78 -0.011612375 0.0024122272 s=n,
+79 -0.011682604 0.0023612028 s=n,
+80 -0.0123748835 0.0026694252 s=n,
+81 -0.012520759 0.0026694252 s=n,
+82 -0.012404897 0.0026912317 s=n,
+83 -0.012550773 0.0026912317 s=n,
+84 -0.01209745 0.0019060532 s=n,
+85 -0.012657413 0.0027138987 s=n,
+86 -0.01220409 0.0019287202 s=n,
+87 -0.0121740755 0.0019069137 s=n,
+88 -0.011669374 0.0013463852 s=n,
+89 -0.011637591 0.0010439919 s=n,
+90 -0.012217856 0.0019257942 s=n,
+91 -0.012187841 0.0019039877 s=n,
+92 -0.01168314 0.0013434592 s=n,
+93 -0.011651357 0.0010410659 s=n,
+94 -0.011544717 0.0010183989 s=n,
+95 -0.0108524375 7.1017636E-4 s=n,
+96 -0.010765712 6.4716605E-4 s=n,
+97 -0.009557918 -0.006857067 s=n,
+98 -0.009546931 -0.0068760966 s=n,
+99 -0.009474708 -0.0069285696 s=n,
+100 -0.0094248885 -0.0069838986 s=n,
+101 -0.008882575 -0.0018241275 s=n,
+102 -0.008883209 -0.0018180992 s=n,
+103 -0.00881298 -0.0017670747 s=n,
+104 -0.008781371 -0.0017670747 s=n,
+105 -0.00951301 0.0047233286 s=n,
+106 -0.009567976 0.0047478015 s=n,
+107 -0.009654703 0.0048108115 s=n,
+108 -0.010159405 0.00537134 s=n,
+109 -0.010612727 0.0061565186 s=n,
+110 -0.013170495 0.0035415133 s=n,
+111 -0.013316371 0.0035415133 s=n,
+112 -0.01342301 0.0035641803 s=n,
+113 -0.012575984 6.293953E-4 s=n,
+114 -0.012469344 6.067283E-4 s=n,
+115 -0.011777065 2.9850577E-4 s=n,
+116 -0.011690339 2.3549546E-4 s=n,
+117 -0.009821957 -0.007669698 s=n,
+118 -0.00981097 -0.0076887277 s=n,
+119 -0.009699429 -0.0087499665 s=n,
+120 -0.00943539 -0.007937335 s=n,
+121 -0.009363167 -0.007989809 s=n,
+122 -0.009313349 -0.008045138 s=n,
+123 -0.009297958 -0.008071796 s=n,
+124 -0.0094094975 -0.0070105568 s=n,
+125 -0.008867184 -0.0018507856 s=n,
+126 -0.008004 -0.002477925 s=n,
+127 -0.008019391 -0.002451267 s=n,
+128 -0.008020026 -0.0024452389 s=n,
+129 -0.007949796 -0.0023942143 s=n,
+130 -0.007918187 -0.0023942143 s=n,
+;
+VLABELS
+2 'No305' x=12 y=9 f='Dialog-PLAIN-16',
+3 'No1114S' x=11 y=14,
+4 'No306' x=-15 y=26,
+5 'No304' x=-19 y=28,
+6 'No0913S' x=-34 y=29,
+7 'No1202S' x=-39 y=27,
+8 'No0910S' x=-77 y=16,
+9 'No0906S' x=-79 y=11,
+10 'No1206S' x=-79 y=6,
+11 'No0908S' x=-77 y=2,
+12 'No1208S' x=-34 y=-19,
+13 'No0912S' x=-25 y=-16,
+14 'No1103S' x=11 y=4,
+117 'No1007S' x=-37 y=-18,
+123 'No0909S' x=-31 y=-24,
+;
+EDGES
+1 1 2 s=5 w=0.006068427,
+2 15 1 s=10 w=0.0030639141,
+3 16 15 s=9 w=3.1608884E-5,
+4 17 1 s=4 w=8.927283E-5,
+5 18 15 s=4 w=8.927283E-5,
+6 18 17 s=10 w=0.0030639141,
+7 19 16 s=4 w=8.927283E-5,
+8 19 18 s=9 w=3.1608884E-5,
+9 20 19 s=23 w=1.3156666E-4,
+10 21 16 s=23 w=1.3156666E-4,
+11 21 20 s=4 w=8.927283E-5,
+12 22 15 s=23 w=1.3156666E-4,
+13 22 21 s=9 w=3.1608884E-5,
+14 23 20 s=22 w=8.6808155E-5,
+15 24 21 s=22 w=8.6808155E-5,
+16 24 23 s=4 w=8.927283E-5,
+17 25 19 s=8 w=0.0018286711,
+18 26 20 s=8 w=0.0018286711,
+19 26 25 s=23 w=1.3156666E-4,
+20 27 23 s=8 w=0.0018286711,
+21 27 26 s=22 w=8.6808155E-5,
+22 28 17 s=3 w=3.0405898E-4,
+23 29 18 s=3 w=3.0405898E-4,
+24 29 28 s=10 w=0.0030639141,
+25 30 19 s=3 w=3.0405898E-4,
+26 30 29 s=9 w=3.1608884E-5,
+27 31 25 s=3 w=3.0405898E-4,
+28 31 30 s=8 w=0.0018286711,
+29 32 26 s=3 w=3.0405898E-4,
+30 32 31 s=23 w=1.3156666E-4,
+31 33 27 s=3 w=3.0405898E-4,
+32 33 32 s=22 w=8.6808155E-5,
+33 34 31 s=17 w=6.0168037E-5,
+34 35 32 s=17 w=6.0168037E-5,
+35 35 34 s=23 w=1.3156666E-4,
+36 36 33 s=17 w=6.0168037E-5,
+37 36 35 s=22 w=8.6808155E-5,
+38 37 27 s=17 w=6.0168037E-5,
+39 37 36 s=3 w=3.0405898E-4,
+40 38 34 s=16 w=1.0719955E-4,
+41 39 35 s=16 w=1.0719955E-4,
+42 39 38 s=23 w=1.3156666E-4,
+43 40 36 s=16 w=1.0719955E-4,
+44 40 39 s=22 w=8.6808155E-5,
+45 41 37 s=16 w=1.0719955E-4,
+46 41 40 s=3 w=3.0405898E-4,
+47 42 23 s=35 w=0.0010072162,
+48 43 24 s=35 w=0.0010072162,
+49 43 42 s=4 w=8.927283E-5,
+50 44 21 s=35 w=0.0010072162,
+51 44 43 s=22 w=8.6808155E-5,
+52 45 22 s=35 w=0.0010072162,
+53 45 44 s=9 w=3.1608884E-5,
+54 46 28 s=2 w=9.67039E-4,
+55 46 3 s=1 w=0.007878401,
+56 47 29 s=2 w=9.67039E-4,
+57 47 46 s=10 w=0.0030639141,
+58 48 30 s=2 w=9.67039E-4,
+59 48 47 s=9 w=3.1608884E-5,
+60 49 31 s=2 w=9.67039E-4,
+61 49 48 s=8 w=0.0018286711,
+62 50 34 s=2 w=9.67039E-4,
+63 50 49 s=17 w=6.0168037E-5,
+64 51 38 s=2 w=9.67039E-4,
+65 51 50 s=16 w=1.0719955E-4,
+66 52 51 s=15 w=7.542655E-4,
+67 53 38 s=15 w=7.542655E-4,
+68 53 52 s=2 w=9.67039E-4,
+69 54 39 s=15 w=7.542655E-4,
+70 54 53 s=23 w=1.3156666E-4,
+71 55 40 s=15 w=7.542655E-4,
+72 55 54 s=22 w=8.6808155E-5,
+73 56 55 s=21 w=7.577939E-4,
+74 57 40 s=21 w=7.577939E-4,
+75 57 56 s=15 w=7.542655E-4,
+76 58 41 s=21 w=7.577939E-4,
+77 58 57 s=3 w=3.0405898E-4,
+78 59 56 s=26 w=1.458757E-4,
+79 60 57 s=26 w=1.458757E-4,
+80 60 59 s=15 w=7.542655E-4,
+81 61 58 s=26 w=1.458757E-4,
+82 61 60 s=3 w=3.0405898E-4,
+83 62 41 s=26 w=1.458757E-4,
+84 62 61 s=21 w=7.577939E-4,
+85 63 37 s=26 w=1.458757E-4,
+86 63 62 s=16 w=1.0719955E-4,
+87 64 42 s=34 w=6.061471E-6,
+88 65 43 s=34 w=6.061471E-6,
+89 65 64 s=4 w=8.927283E-5,
+90 66 64 s=38 w=2.1973468E-5,
+91 67 65 s=38 w=2.1973468E-5,
+92 67 66 s=4 w=8.927283E-5,
+93 68 43 s=38 w=2.1973468E-5,
+94 68 67 s=34 w=6.061471E-6,
+95 69 44 s=38 w=2.1973468E-5,
+96 69 68 s=22 w=8.6808155E-5,
+97 70 45 s=38 w=2.1973468E-5,
+98 70 69 s=9 w=3.1608884E-5,
+99 71 49 s=7 w=6.354771E-4,
+100 71 4 s=6 w=4.1818016E-4,
+101 72 50 s=7 w=6.354771E-4,
+102 72 71 s=17 w=6.0168037E-5,
+103 73 51 s=7 w=6.354771E-4,
+104 73 72 s=16 w=1.0719955E-4,
+105 74 52 s=7 w=6.354771E-4,
+106 74 73 s=15 w=7.542655E-4,
+107 75 74 s=14 w=9.066461E-4,
+108 76 52 s=14 w=9.066461E-4,
+109 76 75 s=7 w=6.354771E-4,
+110 77 53 s=14 w=9.066461E-4,
+111 77 76 s=2 w=9.67039E-4,
+112 78 54 s=14 w=9.066461E-4,
+113 78 77 s=23 w=1.3156666E-4,
+114 79 55 s=14 w=9.066461E-4,
+115 79 78 s=22 w=8.6808155E-5,
+116 80 56 s=14 w=9.066461E-4,
+117 80 79 s=21 w=7.577939E-4,
+118 81 59 s=14 w=9.066461E-4,
+119 81 80 s=26 w=1.458757E-4,
+120 82 80 s=20 w=3.7099395E-5,
+121 83 81 s=20 w=3.7099395E-5,
+122 83 82 s=26 w=1.458757E-4,
+123 84 59 s=20 w=3.7099395E-5,
+124 84 83 s=14 w=9.066461E-4,
+125 85 83 s=25 w=1.0902213E-4,
+126 86 84 s=25 w=1.0902213E-4,
+127 86 85 s=14 w=9.066461E-4,
+128 87 59 s=25 w=1.0902213E-4,
+129 87 86 s=20 w=3.7099395E-5,
+130 88 60 s=25 w=1.0902213E-4,
+131 88 87 s=15 w=7.542655E-4,
+132 89 61 s=25 w=1.0902213E-4,
+133 89 88 s=3 w=3.0405898E-4,
+134 90 86 s=28 w=1.40733355E-5,
+135 90 9 s=27 w=0.0051963497,
+136 91 87 s=28 w=1.40733355E-5,
+137 91 90 s=20 w=3.7099395E-5,
+138 92 88 s=28 w=1.40733355E-5,
+139 92 91 s=15 w=7.542655E-4,
+140 93 89 s=28 w=1.40733355E-5,
+141 93 92 s=3 w=3.0405898E-4,
+142 94 61 s=28 w=1.40733355E-5,
+143 94 93 s=25 w=1.0902213E-4,
+144 95 62 s=28 w=1.40733355E-5,
+145 95 94 s=21 w=7.577939E-4,
+146 96 63 s=28 w=1.40733355E-5,
+147 96 95 s=16 w=1.0719955E-4,
+148 97 64 s=33 w=0.0051881927,
+149 98 66 s=33 w=0.0051881927,
+150 98 97 s=38 w=2.1973468E-5,
+151 99 67 s=33 w=0.0051881927,
+152 99 98 s=4 w=8.927283E-5,
+153 100 99 s=40 w=7.4452415E-5,
+154 101 67 s=40 w=7.4452415E-5,
+155 101 100 s=33 w=0.0051881927,
+156 102 68 s=40 w=7.4452415E-5,
+157 102 101 s=34 w=6.061471E-6,
+158 103 69 s=40 w=7.4452415E-5,
+159 103 102 s=22 w=8.6808155E-5,
+160 104 70 s=40 w=7.4452415E-5,
+161 104 103 s=9 w=3.1608884E-5,
+162 105 71 s=12 w=0.0022168073,
+163 105 5 s=11 w=0.0020751753,
+164 106 72 s=12 w=0.0022168073,
+165 106 105 s=17 w=6.0168037E-5,
+166 107 73 s=12 w=0.0022168073,
+167 107 106 s=16 w=1.0719955E-4,
+168 108 74 s=12 w=0.0022168073,
+169 108 107 s=15 w=7.542655E-4,
+170 109 75 s=12 w=0.0022168073,
+171 109 108 s=14 w=9.066461E-4,
+172 109 6 s=13 w=0.0012816527,
+173 110 82 s=19 w=0.0011441667,
+174 110 7 s=18 w=7.864587E-4,
+175 111 83 s=19 w=0.0011441667,
+176 111 110 s=26 w=1.458757E-4,
+177 112 85 s=19 w=0.0011441667,
+178 112 111 s=25 w=1.0902213E-4,
+179 112 8 s=24 w=0.0020897626,
+180 113 93 s=30 w=0.0010121305,
+181 113 10 s=29 w=0.004156471,
+182 114 94 s=30 w=0.0010121305,
+183 114 113 s=25 w=1.0902213E-4,
+184 115 95 s=30 w=0.0010121305,
+185 115 114 s=21 w=7.577939E-4,
+186 116 96 s=30 w=0.0010121305,
+187 116 115 s=16 w=1.0719955E-4,
+188 116 11 s=31 w=0.004199673,
+189 117 97 s=32 w=8.544509E-4,
+190 118 98 s=32 w=8.544509E-4,
+191 118 117 s=38 w=2.1973468E-5,
+192 119 118 s=37 w=0.0010670845,
+193 119 12 s=36 w=0.0010342944,
+194 120 98 s=37 w=0.0010670845,
+195 120 119 s=32 w=8.544509E-4,
+196 121 99 s=37 w=0.0010670845,
+197 121 120 s=4 w=8.927283E-5,
+198 122 100 s=37 w=0.0010670845,
+199 122 121 s=40 w=7.4452415E-5,
+200 123 122 s=39 w=3.0782125E-5,
+201 124 100 s=39 w=3.0782125E-5,
+202 124 123 s=37 w=0.0010670845,
+203 125 101 s=39 w=3.0782125E-5,
+204 125 124 s=33 w=0.0051881927,
+205 126 125 s=42 w=0.0010669535,
+206 126 13 s=41 w=0.0030889313,
+207 127 101 s=42 w=0.0010669535,
+208 127 126 s=39 w=3.0782125E-5,
+209 128 102 s=42 w=0.0010669535,
+210 128 127 s=34 w=6.061471E-6,
+211 129 103 s=42 w=0.0010669535,
+212 129 128 s=22 w=8.6808155E-5,
+213 130 104 s=42 w=0.0010669535,
+214 130 129 s=9 w=3.1608884E-5,
+215 130 14 s=43 w=9.133177E-4,
+;
+END; [Network]
+
+BEGIN st_Assumptions;
+uptodate;
+chartransform=Uncorrected_P;
+disttransform=NeighborNet;
+splitstransform=EqualAngle;
+SplitsPostProcess filter=dimension value=4;
+ exclude  no missing;
+autolayoutnodelabels;
+END; [st_Assumptions]
diff --git a/man/Ancestors.Rd b/man/Ancestors.Rd
index 364c39a..ffca5c9 100644
--- a/man/Ancestors.Rd
+++ b/man/Ancestors.Rd
@@ -4,6 +4,7 @@
 \alias{Descendants}
 \alias{Siblings}
 \alias{mrca.phylo}
+%\alias{mrca}
 \title{tree utility function}
 \description{
 Functions for describing relationships among phylogenetic nodes.
@@ -13,8 +14,9 @@ Ancestors(x, node, type=c("all","parent"))
 Children(x, node)
 Siblings(x, node, include.self=FALSE)
 Descendants(x, node, type=c("tips","children","all"))
-mrca.phylo(x, node)
+mrca.phylo(x, node=NULL)
 }
+%mrca(x)
 \arguments{
   \item{x}{a tree (a phylo object).}
   \item{node}{an integer or a vector of integers corresponding to a node ID}
@@ -29,11 +31,12 @@ The nodes are the indices as given in edge matrix of an phylo object.
 From taxon labels these indices can be easily derived matching against the \code{tip.label}
 argument of an phylo object, see example below. 
 All the functions allow \code{node} to be either a scalar or vector.  
+\code{mrca} is a faster version of the mrca in ape, in phangorn only because of dependencies. 
 }
 \value{
    a vector or a list containing the indices of the nodes. 
 }
-\seealso{\code{treewalk}, \code{phylo}}
+\seealso{\code{treewalk}, \code{\link[ape]{phylo}}, \code{\link[ape]{nodelabels}} }
 \examples{
 tree = rtree(10)
 plot(tree, show.tip.label = FALSE)
@@ -45,5 +48,7 @@ Descendants(tree, 11, "tips")
 Siblings(tree, 3)
 mrca.phylo(tree, 1:3)
 mrca.phylo(tree, match(c("t1", "t2", "t3"), tree$tip))
+mrca.phylo(tree)
+# same as mrca(tree), but faster for large trees
 }
 \keyword{misc}
diff --git a/man/addConfidences.Rd b/man/addConfidences.Rd
new file mode 100644
index 0000000..b2a23e0
--- /dev/null
+++ b/man/addConfidences.Rd
@@ -0,0 +1,73 @@
+\name{addConfidences}
+\alias{addConfidences}
+\alias{presenceAbsence}
+\alias{createLabel}
+%- Also NEED an '\alias' for EACH other topic documented here.
+\title{
+Compare splits and add support values to an object
+}
+\description{
+Add support values to a \code{splits}, \code{phylo} or \code{networx} object. 
+}
+\usage{
+addConfidences(x, y, ...)
+presenceAbsence(x, y)
+createLabel(x, y, label_y, type = "edge", nomatch = NA)
+}
+%- maybe also 'usage' for other objects documented here.
+\arguments{
+  \item{x}{
+an object of class \code{splits}, \code{phylo} or \code{networx}
+}
+  \item{y}{
+an object of class \code{splits}, \code{phylo}, \code{multiPhylo} or \code{networx}
+}
+  \item{...}{
+  Further arguments passed to or from other methods.
+  }
+  \item{label_y}{
+  label of y matched on x. Will be usually of length(as.splits(x)). 
+  }
+  \item{type}{
+  should labels returned for edges (in \code{networx}) or splits. 
+  }
+  \item{nomatch}{
+  default value if no match between x and y is found. 
+  }
+}
+%%\details{
+%%  ~~ If necessary, more details than the description above ~~
+%%}
+\value{
+The object \code{x} with added bootstrap / MCMC support values. 
+}
+\author{Klaus Schliep \email{klaus.schliep at gmail.com}}
+%%\note{
+%%  ~~further notes~~
+%%}
+
+%% ~Make other sections like Warning with \section{Warning }{....} ~
+
+\seealso{
+\code{\link{as.splits}}, \code{\link{as.networx}}, \code{\link{RF.dist}}, \code{\link{plot.phylo}}
+}
+\examples{
+data(woodmouse)
+woodmouse <- phyDat(woodmouse)
+tmpfile <- normalizePath(system.file("extdata/trees/RAxML_bootstrap.woodmouse", package="phangorn"))
+boot_trees <- read.tree(tmpfile)
+
+dm <- dist.ml(woodmouse)
+tree <- upgma(dm)
+nnet <- neighborNet(dm)
+
+tree <- addConfidences(tree, boot_trees)
+nnet <- addConfidences(nnet, boot_trees)
+
+plot(tree, show.node.label=TRUE)
+plot(nnet, "2D", show.edge.label=TRUE)
+}
+% Add one or more standard keywords, see file 'KEYWORDS' in the
+% R documentation directory.
+\keyword{ cluster }
+%%\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line
diff --git a/man/allTrees.Rd b/man/allTrees.Rd
index ea7d655..fbc82cb 100644
--- a/man/allTrees.Rd
+++ b/man/allTrees.Rd
@@ -1,30 +1,30 @@
-\name{allTrees}
-\alias{allTrees}
-%- Also NEED an '\alias' for EACH other topic documented here.
-\title{ Compute all trees topologies.}
-\description{
-\code{allTrees} computes all tree topologies for rooted or unrooted trees with up to 10 tips. \code{allTrees}  returns bifurcating trees.
-}
-\usage{
-allTrees(n, rooted = FALSE, tip.label = NULL)
-}
-%- maybe also 'usage' for other objects documented here.
-\arguments{
-  \item{n}{Number of tips (<=10).}
-  \item{rooted}{Rooted or unrooted trees (default: rooted).  }
-  \item{tip.label}{Tip labels.}
-}
-\value{
-   an object of class multiPhylo. 
-}
-\author{ Klaus Schliep \email{klaus.schliep at gmail.com} }
-
-% \seealso{}
-\examples{
-trees <- allTrees(5)
-par(mfrow = c(3,5))
-for(i in 1:15)plot(trees[[i]])
-}
-% Add one or more standard keywords, see file 'KEYWORDS' in the
-% R documentation directory.
-\keyword{ cluster }
+\name{allTrees}
+\alias{allTrees}
+%- Also NEED an '\alias' for EACH other topic documented here.
+\title{ Compute all trees topologies.}
+\description{
+\code{allTrees} computes all tree topologies for rooted or unrooted trees with up to 10 tips. \code{allTrees}  returns bifurcating trees.
+}
+\usage{
+allTrees(n, rooted = FALSE, tip.label = NULL)
+}
+%- maybe also 'usage' for other objects documented here.
+\arguments{
+  \item{n}{Number of tips (<=10).}
+  \item{rooted}{Rooted or unrooted trees (default: rooted).  }
+  \item{tip.label}{Tip labels.}
+}
+\value{
+   an object of class \code{multiPhylo}. 
+}
+\author{ Klaus Schliep \email{klaus.schliep at gmail.com} }
+
+\seealso{\code{\link[ape]{rtree}}, \code{\link{nni}}}
+\examples{
+trees <- allTrees(5)
+par(mfrow = c(3,5))
+for(i in 1:15)plot(trees[[i]])
+}
+% Add one or more standard keywords, see file 'KEYWORDS' in the
+% R documentation directory.
+\keyword{ cluster }
diff --git a/man/ancestral.pml.Rd b/man/ancestral.pml.Rd
index a2a840a..cf475c1 100644
--- a/man/ancestral.pml.Rd
+++ b/man/ancestral.pml.Rd
@@ -26,7 +26,7 @@ plotAnc(tree, data, i, col=NULL, cex.pie=par("cex"), pos="bottomright", ...)
   \item{i}{plots the i-th character of the \code{data}.}
   \item{col}{a vector containing the colors for all possible states.}
   \item{cex.pie}{a numeric defining the size of the pie graphs}
-  \item{pos}{a character string defining the positiond of the legend}
+  \item{pos}{a character string defining the position of the legend}
   \item{cost}{A cost matrix for the transitions between two states.} 
   \item{\dots}{Further arguments passed to or from other methods.}
 }
@@ -52,7 +52,7 @@ Yang, Z. (2006). \emph{Computational Molecular evolution}. Oxford University Pre
 }
 \author{Klaus Schliep \email{klaus.schliep at gmail.com}}
 \seealso{
-\code{pml}, \code{parsimony}, \code{ace}, \code{root}
+\code{\link{pml}}, \code{\link{parsimony}}, \code{\link[ape]{ace}}, \code{\link[ape]{root}} 
 }
 \examples{
 example(NJ)
diff --git a/man/as.splits.Rd b/man/as.splits.Rd
index 7f7ee2e..60e75f5 100644
--- a/man/as.splits.Rd
+++ b/man/as.splits.Rd
@@ -14,10 +14,9 @@
 \alias{write.nexus.splits}
 \alias{read.nexus.splits}
 \alias{as.phylo.splits}
-\alias{addConfidences}
 \alias{countCycles}
-\alias{presenceAbsence}
 \alias{addTrivialSplits}
+\alias{matchSplits}
 %- Also NEED an '\alias' for EACH other topic documented here.
 \title{
 Splits representation of graphs and trees.
@@ -34,16 +33,13 @@ as.splits(x, ...)
 \method{as.prop.part}{splits}(x, ...)    
 compatible(obj)
 allSplits(k, labels = NULL)
-write.nexus.splits(obj, file="", weights=NULL)
+write.nexus.splits(obj, file = "", weights=NULL, taxa=TRUE, append=FALSE)
 read.nexus.splits(file)
-addConfidences(obj, phy)
-presenceAbsence(x, y)
 addTrivialSplits(obj)
 }
 %- maybe also 'usage' for other objects documented here.
 \arguments{
   \item{x}{An object of class phylo or multiPhylo.}
-  \item{y}{An object of class splits.}
   \item{maxp}{integer, default from \code{options(max.print)}, influences how many entries of large matrices are printed at all.} 
   \item{zero.print}{character which should be printed for zeroes.} 
   \item{one.print}{character which should be printed for ones.} 
@@ -53,10 +49,15 @@ addTrivialSplits(obj)
   \item{labels}{names of taxa.}   
   \item{file}{ a file name.}
   \item{weights}{ Edge weights.}
-  \item{phy}{An object of class phylo or multiPhylo.}
+  \item{taxa}{logical. If TRUE a taxa block is added}
+  \item{append}{logical. If TRUE the nexus blocks will be added to a file.}
 }
 \value{
 \code{as.splits} returns an object of class splits, which is mainly a list of splits and some attributes.
+Often a \code{splits} object will contain attributes \code{confidences} for bootstrap or Bayesian support values and 
+\code{weight} storing edge weights. \code{read.nexus.splits} and \code{write.nexus.splits} allow to exchange a
+\code{splits} object with other software like Splitstree.
+
 \code{compatible} return a lower triangular matrix where an 1 indicates that two splits are incompatible.   
 }
 \author{Klaus Schliep \email{klaus.schliep at gmail.com}}
diff --git a/man/bootstrap.pml.Rd b/man/bootstrap.pml.Rd
index 89b74c9..b4ef2ec 100644
--- a/man/bootstrap.pml.Rd
+++ b/man/bootstrap.pml.Rd
@@ -9,9 +9,9 @@ Bootstrap }
 \description{
 \code{bootstrap.pml} performs (non-parametric) bootstrap analysis and \code{bootstrap.phyDat} produces a list of bootstrapped data sets. \code{plotBS} plots a phylogenetic tree with the with the bootstrap values assigned to the (internal) edges.}
 \usage{
-bootstrap.pml(x, bs = 100, trees = TRUE, multicore=FALSE, ...)
-bootstrap.phyDat(x, FUN, bs = 100, mc.cores = 1L, ...)
-plotBS(tree, BStrees, type="unrooted", bs.col="black", bs.adj=NULL, p=80, ...)
+bootstrap.pml(x, bs = 100, trees = TRUE, multicore=FALSE, mc.cores = NULL, ...)
+bootstrap.phyDat(x, FUN, bs = 100, multicore=FALSE, mc.cores = NULL, jumble = TRUE, ...)
+plotBS(tree, BStrees, type="unrooted", bs.col="black", bs.adj=NULL, p=50, frame=none, ...)
 }
 \arguments{
   \item{x}{
@@ -23,12 +23,14 @@ number of bootstrap samples.
   \item{trees}{
 return trees only (default) or whole \code{pml} objects.  
 }
-  \item{multicore}{
-logical, if TRUE analysis is performed in parallel (see details).
-}
+%  \item{multicore}{
+%logical, if TRUE analysis is performed in parallel (see details).
+%}
+\item{multicore}{logical, whether models should estimated in parallel.}
   \item{mc.cores}{
 The number of cores to use during bootstrap. Only supported on UNIX-alike systems.
 }
+\item{jumble}{logical, jumble the order of the sequences.}
   \item{\dots}{
 further parameters used by \code{optim.pml} or \code{plot.phylo}.
 }
@@ -53,6 +55,9 @@ one or two numeric values specifying the horizontal and vertical justification o
   \item{p}{ 
 only plot support values higher than this percentage number (default is 80).
 }
+  \item{frame}{
+     a character string specifying the kind of frame to be printed around the bootstrap values. This must be one of "none" (the default), "rect" or "circle".
+  }
 }
 \details{
 It is possible that the bootstrap is performed in parallel, with help of the multicore package.
@@ -61,7 +66,7 @@ However it will speed up nicely from the command line ("X11").
 }
 \value{
 \code{bootstrap.pml} returns an object of class \code{multi.phylo} or a list where each 
-element is an object of class \code{pml}. \code{plotBS} returns silently a tree, i.e. an object of class \code{multi.phylo} with the bootstrap values as node labels.
+element is an object of class \code{pml}. \code{plotBS} returns silently a tree, i.e. an object of class \code{phylo} with the bootstrap values as node labels. The argument \code{BStrees} is optional and if not supplied the tree with labels supplied in the \code{node.label} slot. 
 }
 \references{
 Felsenstein J. (1985) Confidence limits on phylogenies. An approach using the bootstrap. \emph{Evolution} \bold{39}, 783--791
@@ -74,22 +79,26 @@ Penny D. and Hendy M.D. (1986) Estimating the reliability of evolutionary trees.
 Klaus Schliep \email{klaus.schliep at gmail.com}
 }
 \seealso{
-\code{\link{optim.pml}}, \code{\link{pml}}, \code{\link{plot.phylo}}, \code{\link{consensusNet}}
+\code{\link{optim.pml}}, \code{\link{pml}}, \code{\link{plot.phylo}}, \code{\link{nodelabels}},\code{\link{consensusNet}} and \code{\link{SOWH.test}} for parametric bootstrap
 }
 \examples{
 \dontrun{
 data(Laurasiatherian)
 dm <- dist.logDet(Laurasiatherian)
 tree <- NJ(dm)
-fit=pml(tree,Laurasiatherian)
-fit = optim.pml(fit,TRUE)
+# NJ
+set.seed(123)
+NJtrees <- bootstrap.phyDat(Laurasiatherian, FUN=function(x)NJ(dist.logDet(x)), bs=100)
+treeNJ <- plotBS(tree, NJtrees, "phylogram")
 
+# Maximum likelihood
+fit <- pml(tree, Laurasiatherian)
+fit <- optim.pml(fit, rearrangements="NNI")
 set.seed(123)
 bs <- bootstrap.pml(fit, bs=100, optNni=TRUE)
 treeBS <- plotBS(fit$tree,bs)
 
-
-
+# Maximum parsimony
 treeMP <- pratchet(Laurasiatherian)
 treeMP <- acctran(treeMP, Laurasiatherian)
 set.seed(123)
@@ -105,3 +114,4 @@ add.scale.bar()
 % R documentation directory.
 \keyword{cluster}
 
+
diff --git a/man/consensusNet.Rd b/man/consensusNet.Rd
index 345328b..9bdaed1 100644
--- a/man/consensusNet.Rd
+++ b/man/consensusNet.Rd
@@ -33,7 +33,7 @@ This is just an intermediate to plot phylogenetic networks with igraph.
 Holland B.R., Huber K.T., Moulton V., Lockhart P.J. (2004) Using consensus networks to visualize contradictory evidence for species phylogeny. \emph{Molecular Biology and Evolution}, \bold{21}, 1459--61
 }
 \seealso{
-\code{\link{splitsNetwork}}, \code{\link{neighborNet}}, \code{\link{lento}}, \code{\link{distanceHadamard}}, \code{\link{plot.networx}}
+\code{\link{splitsNetwork}}, \code{\link{neighborNet}}, \code{\link{lento}}, \code{\link{distanceHadamard}}, \code{\link{plot.networx}}, \code{\link{maxCladeCred}}
 }
 \examples{
 data(Laurasiatherian)
@@ -48,6 +48,11 @@ library(rgl)
 open3d()
 plot(cnet, show.tip.label=FALSE, show.nodes=TRUE)
 plot(cnet, type = "2D", show.edge.label=TRUE)
+
+tmpfile <- normalizePath(system.file("extdata/trees/RAxML_bootstrap.woodmouse", package="phangorn"))
+trees <- read.tree(tmpfile)
+cnet_woodmouse = consensusNet(trees, .3)
+plot(cnet_woodmouse, type = "2D", show.edge.label=TRUE)
 }
 }
 % Add one or more standard keywords, see file 'KEYWORDS' in the
diff --git a/man/cophenetic.networx.Rd b/man/cophenetic.networx.Rd
new file mode 100644
index 0000000..09fb985
--- /dev/null
+++ b/man/cophenetic.networx.Rd
@@ -0,0 +1,25 @@
+\name{cophenetic.networx}
+\alias{cophenetic.networx}
+\alias{cophenetic.splits}
+\title{Pairwise Distances from a Phylogenetic Network}
+\usage{
+\method{cophenetic}{networx}(x)
+\method{cophenetic}{splits}(x)
+}
+\arguments{
+  \item{x}{an object of class \code{"networx"}.}
+}
+\description{
+  \code{cophenetic.networx} computes the pairwise distances between the 
+  pairs of tips from a phylogenetic network using its branch lengths.
+}
+\value{
+  an object of class \code{dist}, names are set according to the 
+  tip labels (as given by the element \code{tip.label} of the argument \code{x}).
+}
+\author{Klaus Schliep}
+\seealso{
+  \code{\link[stats]{cophenetic}} for the generic function, 
+  \code{neighborNet} to construct a network from a distance matrix
+}
+\keyword{manip}
diff --git a/man/delta.score.Rd b/man/delta.score.Rd
new file mode 100644
index 0000000..0e8f72e
--- /dev/null
+++ b/man/delta.score.Rd
@@ -0,0 +1,57 @@
+\name{delta.score}
+\alias{delta.score}
+
+\title{
+Computes the \eqn{\delta} score
+}
+\description{
+Computes the treelikeness  
+}
+\usage{
+delta.score(x, arg = "mean", ...)
+}
+%- maybe also 'usage' for other objects documented here.
+\arguments{
+  \item{x}{
+an object of class \code{phyDat}
+}
+  \item{arg}{
+Specifies the return value, one of "all", "mean" or "sd"
+}
+  \item{...}{
+     further arguments passed through \code{dist.hamming}
+}
+}
+%\details{
+%%  ~~ If necessary, more details than the description above ~~
+%}
+\value{
+A vector containing the \eqn{\delta} scores. 
+}
+\references{
+BR Holland, KT Huber, A Dress, V Moulton (2002) \eqn{\delta} Plots: a tool for analyzing phylogenetic distance data
+Russell D. Gray, David Bryant, Simon J. Greenhill (2010) On the shape and fabric of human history 
+\emph{Molecular Biology and Evolution}, \bold{19(12)} 2051--2059
+
+Russell D. Gray, David Bryant, Simon J. Greenhill (2010) On the shape and fabric of human history 
+\emph{Phil. Trans. R. Soc. B}, \bold{365} 3923--3933; DOI: 10.1098/rstb.2010.0162
+}
+\author{
+Alastair Potts and Klaus Schliep 
+}
+%\note{
+%%  ~~further notes~~
+%}
+
+%% ~Make other sections like Warning with \section{Warning }{....} ~
+
+\seealso{
+ \code{\link{dist.hamming}}
+}
+\examples{
+data(yeast)
+hist(delta.score(yeast, "all"))
+}
+% Add one or more standard keywords, see file 'KEYWORDS' in the
+% R documentation directory.
+\keyword{ cluster }
diff --git a/man/dfactorial.Rd b/man/dfactorial.Rd
index 73a7bc1..3948e6e 100644
--- a/man/dfactorial.Rd
+++ b/man/dfactorial.Rd
@@ -1,28 +1,28 @@
-\name{dfactorial}
-\alias{dfactorial}
-\alias{ldfactorial}
-%- Also NEED an '\alias' for EACH other topic documented here.
-\title{ Arithmetic Operators }
-\description{
-  double factorial function
-}
-\usage{
-dfactorial(x)
-ldfactorial(x)
-}
-\arguments{
-  \item{x}{ a numeric scalar or vector }
-}
-
-\value{
-\code{dfactorial(x)} returns the double factorial, that is \eqn{x\!\! = 1 *  3 * 5 *  \ldots * x } 
-and \code{ldfactorial(x)} is the natural logarithm of it. 
-}
-
-\author{ Klaus Schliep \email{klaus.schliep at gmail.com}  }
-
-\seealso{ \code{\link[base:Special]{factorial}} }
-\examples{
-dfactorial(1:10)
-}
-\keyword{ classif }% at least one, from doc/KEYWORDS
+\name{dfactorial}
+\alias{dfactorial}
+\alias{ldfactorial}
+%- Also NEED an '\alias' for EACH other topic documented here.
+\title{ Arithmetic Operators }
+\description{
+  double factorial function
+}
+\usage{
+dfactorial(x)
+ldfactorial(x)
+}
+\arguments{
+  \item{x}{ a numeric scalar or vector }
+}
+
+\value{
+\code{dfactorial(x)} returns the double factorial, that is \eqn{x\!\! = 1 *  3 * 5 *  \ldots * x } 
+and \code{ldfactorial(x)} is the natural logarithm of it. 
+}
+
+\author{ Klaus Schliep \email{klaus.schliep at gmail.com}  }
+
+\seealso{ \code{\link[base:Special]{factorial}}, \code{\link[ape]{howmanytrees}} }
+\examples{
+dfactorial(1:10)
+}
+\keyword{ classif }% at least one, from doc/KEYWORDS
diff --git a/man/dist.hamming.Rd b/man/dist.hamming.Rd
index df3dcce..78b9c35 100644
--- a/man/dist.hamming.Rd
+++ b/man/dist.hamming.Rd
@@ -7,24 +7,26 @@
 %- Also NEED an '\alias' for EACH other topic documented here.
 \title{Pairwise Distances from Sequences}
 \description{
-\code{dist.hamming} and \code{dist.logDet} compute pairwise distances 
-for an object of class \code{phyDat}. \code{dist.ml} fits distances
-for nucleotide and amino acid models.
+\code{dist.hamming}, \code{dist.ml} and \code{dist.logDet} compute pairwise distances 
+for an object of class \code{phyDat}. 
+\code{dist.ml} uses DNA / AA sequences to compute distances under different substitution models. 
 }
 \usage{
 dist.hamming(x, ratio = TRUE, exclude="none")
 dist.logDet(x)
-dist.ml(x, model="JC69", exclude="none", bf=NULL, Q=NULL, ...)
+dist.ml(x, model="JC69", exclude="none", bf=NULL, Q=NULL, k = 1L, shape = 1, ...)
 readDist(file)
 writeDist(dm, file="")
 }
 \arguments{
   \item{x}{An object of class \code{phyDat}}
   \item{ratio}{Compute uncorrected ('p') distance or character difference.}
-  \item{model}{One of "JC69" or one of 17 amino acid models see details.}
-  \item{exclude}{One of "none", "all", "pairwise" indicating whether to delete the sites with missing data (or ambigious states). The default is handle missing data as in pml.}
+  \item{model}{One of "JC69", "F81" or one of 17 amino acid models see details.}
+  \item{exclude}{One of "none", "all", "pairwise" indicating whether to delete the sites with missing data (or ambiguous states). The default is handle missing data as in pml.}
   \item{bf}{A vector of base frequencies.}
   \item{Q}{A vector containing the lower triangular part of the rate matrix.} 
+  \item{k}{Number of intervals of the discrete gamma distribution.}
+  \item{shape}{Shape parameter of the gamma distribution.}
   \item{\dots}{Further arguments passed to or from other methods.}
   \item{file}{A file name.}
   \item{dm}{A \code{dist} object.}
@@ -33,16 +35,20 @@ writeDist(dm, file="")
   an object of class \code{dist}
 }
 \details{
-So far 17 amino acid models are supported ("WAG", "JTT", "LG", "Dayhoff", "cpREV", "mtmam", "mtArt", "MtZoa", "mtREV24", "VT","RtREV", "HIVw", "HIVb", "FLU", "Blossum62", "Dayhoff_DCMut" and "JTT_DCMut") and additional rate matrices and frequences can be supplied. 
+So far 17 amino acid models are supported ("WAG", "JTT", "LG", "Dayhoff", "cpREV", "mtmam", "mtArt", "MtZoa", "mtREV24", "VT","RtREV", "HIVw", "HIVb", "FLU", "Blossum62", "Dayhoff_DCMut" and "JTT_DCMut") and additional rate matrices and frequencies can be supplied. 
+
+The "F81" model uses empirical base frequencies, the "JC69" equal base frequencies. This is even the case if the data are not nucleotides. 
 }
 \references{ 
 Lockhart, P. J., Steel, M. A., Hendy, M. D. and Penny, D. (1994)
 Recovering evolutionary trees under a more realistic model of sequence
 evolution. \emph{Molecular Biology and Evolution}, \bold{11}, 605--602.
+
+Jukes TH and Cantor CR (1969). \emph{Evolution of Protein Molecules}. New York: Academic Press. 21--132.
 }
 \author{Klaus Schliep \email{klaus.schliep at gmail.com}}
 
-\seealso{For more distance methods for nucleotide data see \code{\link[ape]{dist.dna}}}
+\seealso{For more distance methods for nucleotide data see \code{\link[ape]{dist.dna}} and \code{\link{dist.p}} for pairwise polymorphism p-distances}
 \examples{
 data(Laurasiatherian)
 dm1 <- dist.hamming(Laurasiatherian)
@@ -50,6 +56,15 @@ tree1 <- NJ(dm1)
 dm2 <- dist.logDet(Laurasiatherian)
 tree2 <- NJ(dm2)
 treedist(tree1,tree2)
+# JC model
+dm3 <- dist.ml(Laurasiatherian)
+tree3 <- NJ(dm3)
+treedist(tree1,tree3)
+# F81 + Gamma
+dm4 <- dist.ml(Laurasiatherian, model="F81", k=4, shape=.4)
+tree4 <- NJ(dm4)
+treedist(tree1,tree4)
+treedist(tree3,tree4)
 }
 
 \keyword{ cluster }
diff --git a/man/dist.p.Rd b/man/dist.p.Rd
index e8247c3..a84748e 100644
--- a/man/dist.p.Rd
+++ b/man/dist.p.Rd
@@ -12,7 +12,7 @@ dist.p(x, cost="polymorphism", ignore.indels=TRUE)
 }
 %- maybe also 'usage' for other objects documented here.
 \arguments{
-  \item{x}{a matrix cotaining DNA sequences; this must be of class
+  \item{x}{a matrix containing DNA sequences; this must be of class
  "phyDat" (use as.phyDat to convert from DNAbin objects).}
  \item{cost}{A cost matrix or "polymorphism" for a pre defined one.} 
  \item{ignore.indels}{a logical indicating whether gaps are treated
@@ -21,7 +21,7 @@ characters, so an an indel that spans a number of base positions
 would be treated as multiple character states.}
 }
 \details{
-The polymorphism p-distances (Potts et al. in press) have been 
+The polymorphism p-distances (Potts et al. 2014) have been 
 developed to analyse intra-individual variant polymorphism. For 
 example, the widely used ribosomal internal transcribed spacer (ITS) 
 region  (e.g. Alvarez and Wendel, 2003) consists of 100's to 1000's 
@@ -42,7 +42,7 @@ Bailey, C. D., T. G. Carr, S. A. Harris, and C. E. Hughes. (2003) Characterizati
 
 Goeker, M., and G. Grimm. (2008) General functions to transform associate data to host data, and their use in phylogenetic inference from sequences with intra-individual variability. \emph{BMC Evolutionary Biology}, \bold{8}:86. 
 
-Potts, A.J., T.A. Hedderson, and G.W. Grimm. (2013) Constructing phylogenies in the presence of intra-individual site polymorphisms (2ISPs) with a focus on the nuclear ribosomal cistron. \emph{Systematic Biology}, \bold{doi 10.1093/sysbio/syt052}.
+Potts, A.J., T.A. Hedderson, and G.W. Grimm. (2014) Constructing phylogenies in the presence of intra-individual site polymorphisms (2ISPs) with a focus on the nuclear ribosomal cistron. \emph{Systematic Biology}, \bold{63}, 1--16 
 }    
 \author{Klaus Schliep and Alastair Potts}
 
diff --git a/man/distanceHadamard.Rd b/man/distanceHadamard.Rd
index e8d72bb..e163a0c 100644
--- a/man/distanceHadamard.Rd
+++ b/man/distanceHadamard.Rd
@@ -22,7 +22,9 @@ If eps is positive an object of with all splits greater eps is returned.
 Data. \emph{Journal of Classification}, \bold{10}, 5-24.
 }
 \author{Klaus Schliep \email{klaus.schliep at gmail.com}, Tim White}
-\seealso{\code{\link{hadamard}}, \code{\link{lento}}, \code{\link{plot.networx}}}
+\seealso{
+\code{\link{hadamard}}, \code{\link{lento}}, \code{\link{plot.networx}}, \code{\link{neighborNet}}
+}
 
 \examples{
 data(yeast)
diff --git a/man/lento.Rd b/man/lento.Rd
index ac2ff2e..49de6ea 100644
--- a/man/lento.Rd
+++ b/man/lento.Rd
@@ -9,7 +9,7 @@ The lento plot represents support and conflict of splits/bipartitions.
 }
 \usage{
 lento(obj, xlim = NULL, ylim = NULL, main = "Lento plot", sub = NULL, xlab = NULL, 
-    ylab = NULL, bipart=TRUE, trivial=FALSE,...)
+    ylab = NULL, bipart=TRUE, trivial=FALSE, col = rgb(0, 0, 0, 0.5),...)
 }
 %- maybe also 'usage' for other objects documented here.
 \arguments{
@@ -22,6 +22,7 @@ lento(obj, xlim = NULL, ylim = NULL, main = "Lento plot", sub = NULL, xlab = NUL
   \item{ylab}{graphical parameter}
   \item{bipart}{plot bipartition information.}
   \item{trivial}{logical, whether to present trivial splits (default is FALSE).}
+  \item{col}{color for the splits / bipartition.}
   \item{\dots}{Further arguments passed to or from other methods.}
 }
 \value{
diff --git a/man/maxCladeCred.Rd b/man/maxCladeCred.Rd
new file mode 100644
index 0000000..5bfce57
--- /dev/null
+++ b/man/maxCladeCred.Rd
@@ -0,0 +1,72 @@
+\name{maxCladeCred}
+\alias{maxCladeCred}
+%- Also NEED an '\alias' for EACH other topic documented here.
+\title{
+Maximum clade credibility tree
+}
+\description{
+\code{maxCladeCred} computes the maximum clade credibility tree from a sample of trees. 
+}
+\usage{
+maxCladeCred(x, tree = TRUE, part = NULL, rooted = TRUE)
+}
+%- maybe also 'usage' for other objects documented here.
+\arguments{
+  \item{x}{
+  \code{x} is an object of class \code{multiPhylo} or \code{phylo}
+}
+  \item{tree}{
+logical indicating whether return the tree with the clade credibility (default) or 
+the clade credibility score for all trees.
+}
+  \item{rooted}{
+logical, if FALSE the tree with highest maximum bipartition credibility is returned.
+}
+  \item{part}{a list of partitions as returned by \code{prop.part}}
+}
+\details{
+So far just the best tree is returned. No annotations or transformations of edge length are performed. 
+
+If a list of partition is provided then the clade credibity is computed for the trees in x.
+}
+\value{
+a tree (an object of class \code{phylo}) with the highest clade credibility or a numeric vector of clade credibilities for each tree.
+}
+%%\references{
+%% ~put references to the literature/web site here ~
+%%}
+\author{
+Klaus Schliep \email{klaus.schliep at gmail.com} 
+}
+
+%% ~Make other sections like Warning with \section{Warning }{....} ~
+
+\seealso{
+\code{\link{consensus}}, \code{\link{consensusNet}}, \code{\link{prop.part}}
+}
+\examples{
+
+data(Laurasiatherian)
+set.seed(42)
+bs <- bootstrap.phyDat(Laurasiatherian, FUN = function(x)upgma(dist.hamming(x)), 
+    bs=100)
+class(bs) <- 'multiPhylo'
+
+strict_consensus <- consensus(bs)
+majority_consensus <- consensus(bs, p=.5)
+max_clade_cred <- maxCladeCred(bs)
+par(mfrow = c(1,3), mar = c(1,4,1,1))
+plot(strict_consensus, main="Strict consensus tree")
+plot(majority_consensus, main="Majority consensus tree")
+plot(max_clade_cred, main="Maximum clade credibility tree")
+
+# compute clade credibility for trees given a prop.part object
+pp <- prop.part(bs)
+tree <- rNNI(bs[[1]], 20)
+maxCladeCred(c(tree, bs[[1]]), tree=FALSE, part = pp)
+# first value likely be -Inf
+}
+% Add one or more standard keywords, see file 'KEYWORDS' in the
+% R documentation directory.
+\keyword{ cluster }
+
diff --git a/man/midpoint.Rd b/man/midpoint.Rd
index 2c35bca..9da9268 100644
--- a/man/midpoint.Rd
+++ b/man/midpoint.Rd
@@ -9,7 +9,7 @@
 \code{pruneTree} produces a consensus tree.
 }
 \usage{
-midpoint(tree)
+midpoint(tree, node.labels = "support")
 pruneTree(tree, ..., FUN = ">=")
 getRoot(tree)
 }
@@ -17,6 +17,7 @@ getRoot(tree)
 \arguments{
   \item{tree}{an object of class \code{phylo} }
   \item{FUN}{a function evaluated on the nodelabels, result must be logical.}
+  \item{node.labels}{are nodel labels 'support' values, 'label' or  should be 'deleted'}
   \item{\dots}{further arguments, passed to other methods.  }
 }
 \details{
diff --git a/man/modelTest.Rd b/man/modelTest.Rd
index 4ee89ac..ddb924f 100644
--- a/man/modelTest.Rd
+++ b/man/modelTest.Rd
@@ -5,32 +5,35 @@
 ModelTest
 }
 \description{
-Comparison of different substition models 
+Comparison of different nucleotide or amino acid substition models 
 }
 \usage{
 modelTest(object, tree=NULL, model = c("JC", "F81", "K80", "HKY", "SYM", "GTR"), 
-    G = TRUE, I = TRUE, k = 4, control = pml.control(epsilon = 1e-08, maxit = 10, 
-    trace = 1), multicore = FALSE)
+    G = TRUE, I = TRUE, FREQ = FALSE, k = 4, control = pml.control(epsilon = 1e-08, 
+    maxit = 10, trace = 1), multicore = FALSE, mc.cores = NULL)
 }
 %- maybe also 'usage' for other objects documented here.
 \arguments{
   \item{object}{an object of class phyDat or pml}
   \item{tree}{a phylogenetic tree.}
-  \item{model}{a vector containing the substitution models to compare with each other}
+  \item{model}{a vector containing the substitution models to compare with each other
+  or "all" to test all available models}
   \item{G}{logical, TRUE (default) if (discrete) Gamma modelshould be tested}
   \item{I}{logical, TRUE (default) if invariant sites should be tested}
+  \item{FREQ}{logical, FALSE (default) if TRUE amino acid frequencies will be estimated.}
   \item{k}{number of rate classes}
   \item{control}{A list of parameters for controlling the fitting process.}
   \item{multicore}{logical, whether models should estimated in parallel.}
+  \item{mc.cores}{The number of cores to use, i.e. at most how many child processes will be run simultaneously. Must be at least one, and parallelization requires at least two cores.}
 }
 \details{
 \code{modelTest} estimates all the specified models for a given tree and data. 
-When the multicore package is available, the computations are done in parallel.
-This is only possible without GUI interface and under linux.  
-Only nucleotide models are tested so far.  
+When the mclapply is available, the computations are done in parallel. \code{modelTest} 
+runs each model in one thread. 
+This is may not work within a GUI interface and will not work under Windows.  
 }
 \value{
-A data.frame containing the log-likelihood, AIC, AICc and BIC all tested models. 
+A data.frame containing the log-likelihood, number of estimated parameters, AIC, AICc and BIC all tested models. 
 The data.frame has an attributes "env" which is an environment which contains all the trees, the data and the calls to allow get the estimated models, e.g. as a starting point for further analysis (see example).
 }
 \references{
@@ -47,7 +50,7 @@ Darriba D., Taboada G.L., Doallo R and Posada D. (2011) ProtTest 3: fast selecti
 %% ~Make other sections like Warning with \section{Warning }{....} ~
 
 \seealso{
-\code{\link{pml}}, \code{\link{anova}}
+\code{\link{pml}}, \code{\link{anova}}, \code{\link[stats]{AIC}}
 }
 \examples{
 \dontrun{    
@@ -62,6 +65,9 @@ eval(F81, env=env)
 
 data(chloroplast)
 (mTAA <- modelTest(chloroplast, model=c("JTT", "WAG", "LG")))
+
+# test all available amino acid models
+(mTAA_all <- modelTest(chloroplast, model="all", multicore=TRUE, mc.cores=2))
 }
 }
 % Add one or more standard keywords, see file 'KEYWORDS' in the
diff --git a/man/neighborNet.Rd b/man/neighborNet.Rd
index 145b158..8354e8f 100644
--- a/man/neighborNet.Rd
+++ b/man/neighborNet.Rd
@@ -28,7 +28,7 @@ neighborNet(x, ord = NULL)
 Bryant, D. & Moulton, V. (2004) Neighbor-Net: An Agglomerative Method for the Construction of Phylogenetic Networks. \emph{Molecular Biology and Evolution}, 2004, \bold{21}, 255-265
 }
 \seealso{
-\code{\link{splitsNetwork}}, \code{\link{consensusNet}}, \code{\link{plot.networx}}, \code{\link{lento}}
+\code{\link{splitsNetwork}}, \code{\link{consensusNet}}, \code{\link{plot.networx}}, \code{\link{lento}}, \code{\link{cophenetic.networx}}, \code{\link{distanceHadamard}}
 }
 \examples{
 data(yeast)
diff --git a/man/nni.Rd b/man/nni.Rd
index 0197d36..a2ceb48 100644
--- a/man/nni.Rd
+++ b/man/nni.Rd
@@ -25,7 +25,7 @@ rNNI(tree, moves=1, n=length(moves))
 }
 \author{ Klaus Schliep \email{klaus.schliep at gmail.com} }
 
-% \seealso{ }
+\seealso{\code{\link{allTrees}}}
 \examples{
 tree = unroot(rtree(20))
 trees1 <- nni(tree)
diff --git a/man/parsimony.Rd b/man/parsimony.Rd
index fc5180d..f1b7b9c 100644
--- a/man/parsimony.Rd
+++ b/man/parsimony.Rd
@@ -26,8 +26,8 @@ pratchet(data, start=NULL, method="fitch", maxit=1000, k=10, trace=1, all=FALSE,
 fitch(tree, data, site = "pscore")
 sankoff(tree, data, cost = NULL, site = "pscore")
 random.addition(data, method="fitch")
-CI(tree, data, cost = NULL)
-RI(tree, data, cost = NULL)
+CI(tree, data, cost = NULL, sitewise=FALSE)
+RI(tree, data, cost = NULL, sitewise=FALSE)
 acctran(tree, data)
 }
 %- maybe also 'usage' for other objects documented here.
@@ -44,6 +44,7 @@ acctran(tree, data)
   \item{k}{number of rounds ratchet is stopped, when there is no improvement.}
   \item{all}{return all equally good trees or just one of them.} 
   \item{...}{Further arguments passed to or from other methods (e.g. model="sankoff" and cost matrix).} 
+  \item{sitewise}{return CI/RI for alignment or sitewise}
 }  
 \value{
   \code{parsimony} returns the maximum parsimony score (pscore). 
diff --git a/man/phangorn-package.Rd b/man/phangorn-package.Rd
index 5c3224c..0398123 100644
--- a/man/phangorn-package.Rd
+++ b/man/phangorn-package.Rd
@@ -1,41 +1,43 @@
-\name{phangorn-package}
-\alias{phangorn-package}
-\alias{phangorn}
-\docType{package}
-\title{
-Phylogenetic analysis in R
-}
-\description{
-Phylogenetic analysis in R (Estimation of phylogenetic
-trees and networks using Maximum Likelihood, Maximum Parsimony,
-Distance methods & Hadamard conjugation)
-
-The complete list of functions can be displayed with \code{library(help = phangorn)}. 
-
-
-Further information is available in two vignettes.  
-\tabular{ll}{
-\code{Trees} \tab Constructing phylogenetic trees (source, pdf) \cr
-\code{phangorn-specials} \tab Advanced features (source, pdf) \cr
-\code{Ancestral} \tab Ancestral sequence reconstruction (source, pdf) \cr
-}
-The first vignette (to display type \code{vignette('Trees')}) gives an introduction in phylogenetic analysis with phangorn, and 
-the second vignette covers more advanced feature like defining special character spaces. 
-}
-\author{
-Klaus Schliep
-
-Maintainer: Klaus Schliep <klaus.schliep at gmail.com>
-}
-\references{
-  Schliep K.P. (2011) phangorn: Phylogenetic analysis in R.
-  \emph{Bioinformatics}, 27(4) 592-593
-}
-\keyword{ package }
-%\seealso{
-%~~ Optional links to other man pages, e.g. ~~
-%~~ \code{\link[<pkg>:<pkg>-package]{<pkg>}} ~~
-%}
-%\examples{
-%~~ simple examples of the most important functions ~~
-%}
+\name{phangorn-package}
+\alias{phangorn-package}
+\alias{phangorn}
+\docType{package}
+\title{
+Phylogenetic analysis in R
+}
+\description{
+Phylogenetic analysis in R (Estimation of phylogenetic
+trees and networks using Maximum Likelihood, Maximum Parsimony,
+Distance methods & Hadamard conjugation)
+
+The complete list of functions can be displayed with \code{library(help = phangorn)}. 
+
+
+Further information is available in several vignettes. To show the available 
+vignettes in an HTML browser type \code{browseVignettes("phangorn")}. 
+\tabular{ll}{
+\code{Trees} \tab Constructing phylogenetic trees (source, pdf) \cr
+\code{phangorn-specials} \tab Advanced features (source, pdf) \cr
+\code{Ancestral} \tab Ancestral sequence reconstruction (source, pdf) \cr
+\code{Networx} \tab Splits and Networx (source, html) \cr
+}
+The first vignette (to display type \code{vignette('Trees')}) gives an introduction in phylogenetic analysis with phangorn. The second vignette (phangorn-special) covers more advanced feature like defining special character spaces and things which fit nowhere else. 
+More information on \bold{phangorn} can be found on \url{http://www.phangorn.org}. 
+}
+\author{
+Klaus Schliep
+
+Maintainer: Klaus Schliep <klaus.schliep at gmail.com>
+}
+\references{
+  Schliep K.P. (2011) phangorn: Phylogenetic analysis in R.
+  \emph{Bioinformatics}, 27(4) 592-593
+}
+\keyword{ package }
+%\seealso{
+%~~ Optional links to other man pages, e.g. ~~
+%~~ \code{\link[<pkg>:<pkg>-package]{<pkg>}} ~~
+%}
+%\examples{
+%~~ simple examples of the most important functions ~~
+%}
diff --git a/man/phyDat.Rd b/man/phyDat.Rd
index dacd2d5..75aeb0a 100644
--- a/man/phyDat.Rd
+++ b/man/phyDat.Rd
@@ -1,7 +1,10 @@
 \name{phyDat}
 \alias{phyDat}
+\alias{as.AAbin.phyDat}
 \alias{as.phyDat.DNAbin}
 \alias{as.phyDat.alignment}
+\alias{as.phyDat.MultipleAlignment}
+\alias{as.MultipleAlignment.phyDat}
 \alias{as.data.frame.phyDat}
 \alias{as.character.phyDat}
 \alias{as.DNAbin.phyDat}
@@ -14,7 +17,11 @@
 \alias{baseFreq}
 \alias{cbind.phyDat}
 \alias{c.phyDat}
+\alias{unique.phyDat}
+\alias{removeUndeterminedSites}
 \alias{phyDat2alignment}
+\alias{phyDat2MultipleAlignment}
+\alias{image.phyDat}
 \title{Conversion among Sequence Formats}
 \description{
 These functions transform several DNA formats into the \code{phyDat} format. 
@@ -26,14 +33,17 @@ read.phyDat(file, format="phylip", type="DNA", ...)
 write.phyDat(x, file, format="phylip",...)
 \method{as.phyDat}{DNAbin}(x, ...)
 \method{as.phyDat}{alignment}(x, type="DNA", ...)
+\method{as.phyDat}{MultipleAlignment}(x, ...)
+%\method{as.AAbin}{phyDat}(x, ...)
 \method{as.character}{phyDat}(x, allLevels = TRUE, ...)
 \method{as.data.frame}{phyDat}(x, ...)
 \method{as.DNAbin}{phyDat}(x, ...)
 \method{subset}{phyDat}(x, subset, select, site.pattern = TRUE, ...)
+\method{unique}{phyDat}(x, incomparables = FALSE, identical = TRUE, ...)
 phyDat2alignment(x)
 allSitePattern(n, levels=c("a","c","g","t"), names=NULL)
 acgt2ry(obj)
-baseFreq(obj, freq=FALSE, drop.unused.levels=FALSE)
+baseFreq(obj, freq=FALSE, all=FALSE, drop.unused.levels=FALSE)
 }
 %- maybe also 'usage' for other objects documented here.
 \arguments{
@@ -43,7 +53,9 @@ baseFreq(obj, freq=FALSE, drop.unused.levels=FALSE)
   \item{levels}{Level attributes.}
   \item{return.index}{If TRUE returns a index of the site patterns.}
   \item{file}{A file name.}
-  \item{format}{File format of the sequence alignment (see details).}
+  \item{format}{File format of the sequence alignment (see details).
+  Several popular formats are supported: "phylip", "interleaved", "sequential", "clustal", "fasta" or "nexus", or any unambiguous abbreviation of these. 
+  }
   \item{n}{Number of sequences.}
   \item{names}{Names of sequences.}
   \item{subset}{a subset of taxa.}
@@ -52,7 +64,11 @@ baseFreq(obj, freq=FALSE, drop.unused.levels=FALSE)
   \item{allLevels}{return original data.} 
   \item{obj}{as object of class phyDat}
   \item{freq}{logical, if 'TRUE', frequencies or counts are returned otherwise proportions}
+  \item{all}{all a logical; if all = TRUE, all counts of bases, ambiguous codes, missing data, and alignment gaps are returned as defined in the contrast.}
   \item{drop.unused.levels}{logical, drop unused levels}  
+  \item{incomparables}{for compatability with unique.}
+  \item{identical}{if TRUE (default) sequences have to be identical, if FALSE sequences are considered 
+  duplicates if distance between sequences is zero (happens frequently with ambiguous sites).}
   \item{...}{further arguments passed to or from other methods.}
 }
 \details{
@@ -93,6 +109,7 @@ data(Laurasiatherian)
 class(Laurasiatherian)
 Laurasiatherian
 baseFreq(Laurasiatherian)
+baseFreq(Laurasiatherian, all=TRUE)
 subset(Laurasiatherian, subset=1:5)
 # transform into old ape format
 LauraChar <- as.character(Laurasiatherian)
diff --git a/man/plot.networx.Rd b/man/plot.networx.Rd
index faf69f7..6ec1337 100644
--- a/man/plot.networx.Rd
+++ b/man/plot.networx.Rd
@@ -2,6 +2,9 @@
 \alias{plot.networx}
 \alias{as.networx}
 \alias{as.networx.splits}
+\alias{as.networx.phylo}
+\alias{write.nexus.networx}
+\alias{read.nexus.networx}
 %\alias{reorder.networx}
 %- Also NEED an '\alias' for EACH other topic documented here.
 \title{
@@ -13,12 +16,17 @@ Phylogenetic networks
 }
 \usage{
 as.networx(x, ...)
-\method{as.networx}{splits}(x, planar = FALSE, ...)
+\method{as.networx}{splits}(x, planar = FALSE, coord = c("none", "2D", "3D"), ...)
 \method{plot}{networx}(x, type="3D", use.edge.length = TRUE, show.tip.label=TRUE, 
      show.edge.label=FALSE, edge.label = NULL, show.node.label=FALSE, 
-     node.label = NULL, show.nodes=FALSE, tip.color="blue", 
-     edge.color="grey", edge.width=3, edge.lty=1, font=3, 
-     cex=1, ...)
+     node.label = NULL, show.nodes=FALSE, tip.color="black", 
+     edge.color="black", edge.width=3, edge.lty=1, 
+     split.color=NULL, split.width=NULL, split.lty=NULL,
+     font = 3, cex = par("cex"), 
+     cex.node.label=cex, cex.edge.label=cex,
+     col.node.label = tip.color, col.edge.label = tip.color, 
+     font.node.label = font, font.edge.label = font,
+     ...)
 }
 %- maybe also 'usage' for other objects documented here.
 \arguments{
@@ -29,6 +37,7 @@ an object of class \code{"splits"} (as.networx) or \code{"networx"} (plot)
 logical whether to produce a planar graph from only cyclic splits 
 (may excludes splits). 
 }
+\item{coord}{add coordinates of the nodes, allows to reproduce the plot.}
 \item{type}{
 "3D" to plot using rgl or "2D" in the normal device. 
 }
@@ -67,12 +76,37 @@ the width used to draw edges.
 \item{edge.lty}{
 a vector of line types.
 }
+\item{split.color}{
+the colors used to draw edges.
+}
+\item{split.width}{
+the width used to draw edges.
+}
+\item{split.lty}{
+a vector of line types.
+}
 \item{font}{
 an integer specifying the type of font for the labels: 1 (plain text), 
 2 (bold), 3 (italic, the default), or 4 (bold italic).
 }
 \item{cex}{
 a numeric value giving the factor scaling of the labels.}
+\item{cex.node.label}{
+a numeric value giving the factor scaling of the node labels.}
+\item{cex.edge.label}{
+a numeric value giving the factor scaling of the edge labels.}
+\item{col.node.label}{
+the colors used for the node labels.
+}
+\item{col.edge.label}{
+the colors used for the edge labels.
+}
+\item{font.node.label}{
+the font used for the node labels.
+}
+\item{font.edge.label}{
+the font used for the edge labels.
+}
 \item{\dots}{
 Further arguments passed to or from other methods.
 }
@@ -85,6 +119,9 @@ The argument planar = FALSE will create a planar split graph based on a
 cyclic ordering. These objects can be nicely plotted in "2D".
 So far not all parameters behave the same on the the rgl "3D"
 and basic graphic "2D" device. 
+
+Often it is easier (and safer) to supply vectors of graphial parameters for splits (e.g. splits.color). 
+These overwrite values edge.color. 
 }
 \note{
 The internal representation is likely to change. 
@@ -97,7 +134,7 @@ Klaus Schliep \email{klaus.schliep at gmail.com}
 }
 \seealso{
 \code{\link{consensusNet}}, \code{\link{neighborNet}}, \code{\link{splitsNetwork}}, \code{\link{hadamard}}, 
-\code{\link{distanceHadamard}}, \code{\link{layout.kamada.kawai}}, 
+\code{\link{distanceHadamard}}, \code{\link{layout_with_kk}}, 
 \code{\link[ape]{evonet}}, \code{\link[ape]{as.igraph}}, \code{\link{densiTree}}
 }
 \examples{
diff --git a/man/pml.Rd b/man/pml.Rd
index dcf23cf..dbf5196 100644
--- a/man/pml.Rd
+++ b/man/pml.Rd
@@ -11,8 +11,10 @@ different model parameters.
 \usage{
 pml(tree, data, bf=NULL, Q=NULL, inv=0, k=1, shape=1, rate=1, model="", ...)     
 optim.pml(object, optNni=FALSE, optBf=FALSE, optQ=FALSE, optInv=FALSE, optGamma=FALSE,
-    optEdge=TRUE, optRate=FALSE, optRooted=FALSE, control = pml.control(epsilon=1e-08, 
-    maxit=10, trace=1), model = NULL, subs = NULL, ...)  
+    optEdge=TRUE, optRate=FALSE, optRooted=FALSE, 
+    control = pml.control(epsilon=1e-08, maxit=10, trace=1), model = NULL, 
+    rearrangement = ifelse(optNni, "NNI","none"), subs = NULL, 
+    ratchet.par = list(iter = 20L, maxit = 100L, prop = 1/3),...)  
 pml.control(epsilon = 1e-08, maxit = 10, trace = 1)
 }
 \arguments{
@@ -34,18 +36,22 @@ pml.control(epsilon = 1e-08, maxit = 10, trace = 1)
   \item{optEdge}{Logical value indicating the edge lengths gets optimized.}
   \item{optRate}{Logical value indicating the overall rate gets optimized.}
   \item{optRooted}{Logical value indicating if the edge lengths of a rooted tree get optimized.}
+%  \item{optRatchet}{Stochastic tree search.}
+  \item{ratchet.par}{search parameter for stochastic search}
+  \item{rearrangement}{type of tree tree rearrangements to perform, one of
+      "none", "NNI", "stochastic" or "ratchet"}
   \item{control}{A list of parameters for controlling the fitting process.}
   \item{subs}{A (integer) vector same length as Q to specify the optimization of Q}
   \item{\dots}{Further arguments passed to or from other methods.}
   \item{epsilon}{Stop criterion for optimisation (see details).} 
   \item{maxit}{Maximum number of iterations (see details).}  
-  \item{trace}{Show output during otimization (see details).}    
+  \item{trace}{Show output during optimization (see details).}    
 }
 \details{
 The topology search uses a nearest neighbor interchange (NNI) 
 and the implementation is similar to phyML. 
 The option model in pml is only used for amino acid models. 
-The option model defines the nucleotide model which is getting optmised, 
+The option model defines the nucleotide model which is getting optimised, 
 all models which are included in modeltest can be chosen. Setting this option 
 (e.g. "K81" or "GTR") overrules options optBf and optQ.  
 Here is a overview how to estimate different phylogenetic models 
@@ -62,7 +68,9 @@ JC, F81, K80, HKY, TrNe, TrN, TPM1, K81, TPM1u, TPM2, TPM2u, TPM3, TPM3u,
 TIM1e, TIM1, TIM2e, TIM2, TIM3e, TIM3, TVMe, TVM, SYM and GTR. 
 These models are specified as in Posada (2008).
 
-So far 17 amino acid models are supported ("WAG", "JTT", "LG", "Dayhoff", "cpREV", "mtmam", "mtArt", "MtZoa", "mtREV24", "VT","RtREV", "HIVw", "HIVb", "FLU", "Blossum62", "Dayhoff_DCMut" and "JTT_DCMut") and additionally rate matrices and amino acid frequences can be supplied. 
+So far 17 amino acid models are supported ("WAG", "JTT", "LG", "Dayhoff", "cpREV", "mtmam", "mtArt", "MtZoa", "mtREV24", "VT","RtREV", "HIVw", "HIVb", "FLU", "Blossum62", "Dayhoff_DCMut" and "JTT_DCMut") and additionally rate matrices and amino acid frequencies can be supplied. 
+
+It is also possible to estimate codon models (e.g. YN98), for details see also the chapter in vignette("phangorn-specials"). 
 
 If the option 'optRooted' is set to TRUE than the edge lengths of rooted tree are optimized.
 The tree has to be rooted and by now ultrametric! Optimising rooted trees is generally much slower.
@@ -70,19 +78,24 @@ The tree has to be rooted and by now ultrametric! Optimising rooted trees is gen
 \code{pml.control} controls the fitting process. \code{epsilon} and \code{maxit} are only defined 
 for the most outer loop, this affects \code{pmlCluster}, \code{pmlPart} and \code{pmlMix}. 
 \code{epsilon} is defined as (logLik(k)-logLik(k+1))/logLik(k+1), this seems to be a good 
-heuristics which works reasonalby for small and large trees or alignments. 
+heuristics which works reasonably for small and large trees or alignments. 
 If \code{trace} is set to zero than no out put is shown, if functions are called internally 
 than the trace is decreased by one, so a higher of trace produces more feedback. 
+
+If \code{rearrangement} is set to \code{stochastic} a stochastic search algorithm similar to Nguyen et al. (2015).
+and for \code{ratchet} the likelihood ratchet as in Vos (2003). 
+This should helps often to find better tree topologies, especially for larger trees.   
 }
 \value{
-Returns a list of class \code{ll.phylo}
-  \item{logLik}{Log likelihood of the tree.}
-  \item{siteLik}{Site log likelihoods.}
-  \item{root}{likelihood in the root node.}
+\code{pml} or \code{optim.pml} return a list of class \code{pml}, some are useful for further computations like 
+  \item{tree}{the phylogenetic tree.}
+  \item{data}{the alignment.}
+  \item{logLik}{Log-likelihood of the tree.}
+  \item{siteLik}{Site log-likelihoods.}
   \item{weight}{Weight of the site patterns.}
 }
 \references{ 
-Felsenstein, J. (1981) Evolutionary trees from DNA sequences: a maxumum
+Felsenstein, J. (1981) Evolutionary trees from DNA sequences: a maximum
 likelihood approach. \emph{Journal of Molecular Evolution}, \bold{17}, 368--376. 
 
 Felsenstein, J. (2004). \emph{Inferring Phylogenies}. Sinauer Associates, Sunderland.
@@ -112,6 +125,12 @@ replacement for Arthropoda. \emph{Molecular Biology and Evolution}, \bold{24}, 1
 
 Kosiol, C, and Goldman, N (2005) Different versions of the Dayhoff rate matrix -                               
 \emph{Molecular Biology and Evolution}, \bold{22}, 193--199 
+
+L.-T. Nguyen, H.A. Schmidt, A. von Haeseler, and B.Q. Minh (2015) IQ-TREE: A fast and effective stochastic algorithm for estimating maximum likelihood phylogenies. \emph{Molecular Biology and Evolution}, \bold{32}, 268--274.
+
+Vos, R. A. (2003) Accelerated Likelihood Surface Exploration: The Likelihood Ratchet. \emph{Systematic Biology}, \bold{52(3)}, 368--373
+
+Yang, Z., and R. Nielsen (1998) Synonymous and nonsynonymous rate variation in nuclear genes of mammals. \emph{Journal of Molecular Evolution}, \bold{46}, 409-418.
 }
 \author{Klaus Schliep \email{klaus.schliep at gmail.com}}
 \seealso{
@@ -137,7 +156,8 @@ Kosiol, C, and Goldman, N (2005) Different versions of the Dayhoff rate matrix -
 # optimize shape parameter + proportion of invariant sites     
   fitJC_GI <- optim.pml(fitJC_GI, optGamma=TRUE, optInv=TRUE)
 # GTR + Gamma + I - model
-  fitGTR <- optim.pml(fitJC_GI, optNni=TRUE, optGamma=TRUE, optInv=TRUE, model="GTR") 
+  fitGTR <- optim.pml(fitJC_GI, rearrangement = "stochastic", 
+      optGamma=TRUE, optInv=TRUE, model="GTR") 
 }
 
 
diff --git a/man/pml.fit.Rd b/man/pml.fit.Rd
index 4c88e66..e19952f 100644
--- a/man/pml.fit.Rd
+++ b/man/pml.fit.Rd
@@ -10,7 +10,7 @@
 Internal maximum likelihood functions.   
 }
 \description{
-These functions are internally used for the liklihood computations in \code{pml} or \code{optim.pml}. 
+These functions are internally used for the likelihood computations in \code{pml} or \code{optim.pml}. 
 }
 \usage{
 pml.fit(tree, data, bf=rep(1/length(levels), length(levels)), shape=1, k=1,
@@ -61,13 +61,13 @@ discrete.gamma(alpha, k)
 }
 }
 \details{
-These functions are exported to be used in different packages so far only in the package coalescentMCMC, but are not intended for end user. Most of the functions call C code. 
+These functions are exported to be used in different packages so far only in the package coalescentMCMC, but are not intended for end user. Most of the functions call C code and are far less forgiving if the import is not what they expect than \code{pml}. 
 }
 \value{
-\code{pml.fit} returns the logliklihood. 
+\code{pml.fit} returns the log-likelihood. 
 }
 \references{
-Felsenstein, J. (1981) Evolutionary trees from DNA sequences: a maxumum
+Felsenstein, J. (1981) Evolutionary trees from DNA sequences: a maximum
 likelihood approach. \emph{Journal of Molecular Evolution}, \bold{17}, 368--376. 
 }
 \author{
diff --git a/man/simSeq.Rd b/man/simSeq.Rd
index 6579c36..25e990b 100644
--- a/man/simSeq.Rd
+++ b/man/simSeq.Rd
@@ -60,7 +60,7 @@ data = simSeq(tree, l = 10, type="DNA", bf=c(.1,.2,.3,.4), Q=1:6)
 as.character(data)
 
 # Example to simulate discrete Gamma rate variation
-rates = phangorn:::discrete.gamma(1,4)
+rates = discrete.gamma(1,4)
 data1 = simSeq(tree, l = 100, type="AA", model="WAG", rate=rates[1])
 data2 = simSeq(tree, l = 100, type="AA", model="WAG", rate=rates[2])
 data3 = simSeq(tree, l = 100, type="AA", model="WAG", rate=rates[3])
diff --git a/man/superTree.Rd b/man/superTree.Rd
index aa73553..f920dab 100644
--- a/man/superTree.Rd
+++ b/man/superTree.Rd
@@ -8,7 +8,7 @@ Super Tree and Species Tree methods
 \description{
 These function \code{superTree} allows the estimation of a rooted supertree from a set of rooted trees using Matrix representation parsimony.  \code{coalSpeciesTree} estimates species trees and can multiple individuals per species.}
 \usage{
-superTree(tree, method = "optim.parsimony", rooted=TRUE, ...)
+superTree(tree, method = "pratchet", rooted=TRUE, ...)
 coalSpeciesTree(tree, X, sTree = NULL)
 }
 %- maybe also 'usage' for other objects documented here.
diff --git a/man/treedist.Rd b/man/treedist.Rd
index 3fab22d..109f462 100644
--- a/man/treedist.Rd
+++ b/man/treedist.Rd
@@ -1,21 +1,29 @@
 \name{treedist}
 \alias{treedist}
 \alias{RF.dist}
+\alias{wRF.dist}
+\alias{KF.dist}
+\alias{path.dist}
 %\alias{print.treedist}
 \title{ Distances between trees }
 \description{
-  \code{treedist} computes different tree distance methods and \code{RF.dist} the Robinson-Foulds or symmetric distance.
+  \code{treedist} computes different tree distance methods and \code{RF.dist} the Robinson-Foulds or symmetric distance. 
 }
 \usage{
 treedist(tree1, tree2, check.labels = TRUE)
-RF.dist(tree1, tree2=NULL, check.labels=TRUE, rooted=FALSE)
+RF.dist(tree1, tree2=NULL, normalize=FALSE, check.labels=TRUE, rooted=FALSE)
+wRF.dist(tree1, tree2=NULL, normalize=FALSE, check.labels=TRUE, rooted=FALSE)
+KF.dist(tree1, tree2=NULL, check.labels=TRUE, rooted=FALSE)
+path.dist(tree1, tree2=NULL, check.labels=TRUE, use.weight=FALSE)
 }
 \arguments{
   \item{tree1}{ A phylogenetic tree (class \code{phylo})
   or vector of trees (an object of class \code{multiPhylo}). See details }
   \item{tree2}{ A phylogenetic tree. }
+  \item{normalize}{compute normalized RF-distance, see details. }
   \item{check.labels}{compares labels of the trees.}
   \item{rooted}{take bipartitions for rooted trees into account, default is unrooting the trees.}
+  \item{use.weight}{use edge.length argument or just count number of edges on the path (default)}
 }
 \value{
   \code{treedist} returns a vector containing the following tree distance methods
@@ -25,19 +33,43 @@ RF.dist(tree1, tree2=NULL, check.labels=TRUE, rooted=FALSE)
   \item{weighted.path.difference}{weighted.path.difference}
 }
 \details{
-The Robinson-Foulds distance is well defined only for bifurcating trees. 
+The Robinson-Foulds distance between two trees \eqn{T_1} and \eqn{T_2} with \eqn{n} tips is defined as (following the notation Steel & Penny 1993): 
+\deqn{d(T_1, T_2) = i(T_1) + i(T_2) - 2v_s(T_1, T_2)}
+where \eqn{i(T_1)} denotes the number of internal edges and \eqn{v_s(T_1, T_2)} denotes the number of internal splits shared by the two trees. The normalized Robinson-Foulds distance is derived by dividing \eqn{d(T_1, T_2)} by the maximal possible distance \eqn{i(T_1) + i(T_2)}. If both trees are unrooted and binary this value is \eqn{2n-6}. 
 
-RF.dist returns the Robinson-Foulds distance between either 2 trees or computes 
-a matrix of all pairwise distances if a \code{multiPhylo} object is given. 
-For large number of trees RF.dist can use a lot of memory!
+% The weighted Robinson-Foulds distance makes use of edge weights. Let \eqn{E_1} and \eqn{E_2} the set of edges of \eqn{d(T_1, T_2)} and \eqn{w(e), e \in E_1} the weight of an edge in \eqn{E_1}
+%\deqn{d(T_1, T_2) = \sum_{e \in E \setminus E_1}w(e) + \sum_{e \in E_1\cap E_2}|w(e_1) - w(e_2) + \sum_{e \in E\setminus E_2}w(e) }
+% where \eqn{E = E_1\cup E_2}
+
+%The Kuhner-Felsenstein difference (Kuhner & Felsenstein 1994) is closely related with the weighted Robinson-Foulds distance. 
+
+%Instead of the absolute values between edges are squared 
+% 0-norm RF
+% 1-norm wRF
+% 2-norm KF 
+ 
+\code{RF.dist} returns the Robinson-Foulds distance (Robinson & Foulds 1981) between either 2 trees or computes a matrix of all pairwise distances if a \code{multiPhylo} object is given. The Robinson-Foulds distance only depends on the toplogy of the trees. 
+If edge weights should be considered \code{wRF.dist} calculates the weighted RF distance (Robinson & Foulds 1981). and \code{KF.dist} calculates the branch score distance (Kuhner & Felsenstein 1994). 
+\code{path.dist} computes the path difference metric as described in Steel and Penny 1993).
+
+For large number of trees the distance functions can use a lot of memory!
 
 % The function used internally is 2 * (nt - m) where nt is the number of tips and 
 % m is the number of shared bipartitions. When there are multifurcations the 
 % distance is therefore increasing!! This may be different to other implementations!
 
 }
-\references{Steel M. A. and Penny P. (1993) \emph{Distributions of tree comparison metrics - some new results}, Syst. Biol.,42(2), 126-141}
+\references{
+Steel M. A. and Penny P. (1993) \emph{Distributions of tree comparison metrics - some new results}, Syst. Biol., \bold{42(2)}, 126--141
+
+Kuhner, M. K. and Felsenstein, J. (1994) \emph{A simulation comparison of phylogeny algorithms under equal and unequal evolutionary rates}, Molecular Biology and Evolution, \bold{11(3)}, 459--468
+
+D.F. Robinson and L.R. Foulds (1981) \emph{Comparison of phylogenetic trees}, Mathematical Biosciences, \bold{53(1)}, 131--147
+
+D.F. Robinson and L.R. Foulds (1979) Comparison of weighted labelled trees. In Horadam, A. F. and Wallis, W. D. (Eds.), \emph{Combinatorial Mathematics VI: Proceedings of the Sixth Australian Conference on Combinatorial Mathematics, Armidale, Australia}, 119--126
+}
 \author{ Klaus P. Schliep \email{klaus.schliep at gmail.com}} 
+\seealso{\code{\link[ape]{dist.topo}}}
 \examples{
 tree1 <- rtree(100, rooted=FALSE)
 tree2 <- rSPR(tree1, 3)
diff --git a/src/Makevars b/src/Makevars
index b6b6fa5..7cf7e42 100644
--- a/src/Makevars
+++ b/src/Makevars
@@ -1,3 +1 @@
-PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)  $(SHLIB_OPENMP_CFLAGS)
-PKG_CFLAGS = $(SHLIB_OPENMP_CFLAGS)
-
+PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)  
diff --git a/src/dist.c b/src/dist.c
index 1eb0bd6..8577ec2 100644
--- a/src/dist.c
+++ b/src/dist.c
@@ -1,7 +1,7 @@
 /* 
  * dist.c
  *
- * (c) 2008-2015 Klaus Schliep (klaus.schliep at gmail.com)
+ * (c) 2008-2016 Klaus Schliep (klaus.schliep at gmail.com)
  * 
  * 
  * This code may be distributed under the GNU GPL
diff --git a/src/fitch.c b/src/fitch.c
index e34c8cb..ca4e0d6 100644
--- a/src/fitch.c
+++ b/src/fitch.c
@@ -77,6 +77,21 @@ SEXP AddOne(SEXP edge, SEXP tip, SEXP ind, SEXP l, SEXP m){
 }
 
 
+SEXP AddOnes(SEXP edge, SEXP tip, SEXP ind, SEXP l, SEXP m){
+    R_len_t n = length(ind); 
+    SEXP result, res;
+    PROTECT(res = allocVector(VECSXP, n));
+    for(int i=0; i<n; i++){
+        PROTECT(result = allocMatrix(INTSXP, INTEGER(l)[0]+2L, 2L));
+        addOne(INTEGER(edge), INTEGER(tip), &INTEGER(ind)[i], INTEGER(l), INTEGER(m), INTEGER(result));
+        SET_VECTOR_ELT(res, i, result);
+        UNPROTECT(1);
+    }
+    UNPROTECT(1);
+    return(res);
+}
+
+
 void fitch43(int *dat1, int *dat2, int *nr, int *pars, double *weight, double *w){
     int k, tmp;
     for(k = 0; k < (*nr); k++){
@@ -130,7 +145,9 @@ void fitch54(int *res, int *dat1, int *dat2, int *nr, double *weight, double *w)
     } 
 }
 
-
+// FNALL5(SEXP nrx, SEXP node, SEXP edge, SEXP l, SEXP mx, SEXP my, SEXP root) 
+// nrx, edge,   score (result von FNALL5) 
+// root berechnen
 SEXP FITCHTRIP3(SEXP DAT3, SEXP nrx, SEXP edge, SEXP score, SEXP PS){ 
     R_len_t i, m = length(edge);  
     int nr=INTEGER(nrx)[0], k, tmp, ei, *edges=INTEGER(edge); 
@@ -141,18 +158,9 @@ SEXP FITCHTRIP3(SEXP DAT3, SEXP nrx, SEXP edge, SEXP score, SEXP PS){
     PROTECT(pvec = allocVector(REALSXP, m));
     pvtmp = REAL(pvec);
     for(i=0; i<m; i++) pvtmp[i] = REAL(score)[i]; 
-/*    
-#ifdef _OPENMP
-if(*nthreads <= 1){ *nthreads=1; }else{ *nthreads=(*nthreads < omp_get_max_threads()) ? (*nthreads) : (omp_get_max_threads()); }
-#endif
-
-#ifdef SUPPORT_OPENMP    
-#pragma omp parallel for private(i, ei, k, tmp) shared(edges, data1, data2, d3, nr, weight, ps, pvtmp)
-#endif
-*/
     for(i=0; i<m; i++){
         ei = edges[i] - 1L;
-//      pvtmp[i] = REAL(score)[ei];
+//      pvtmp[i] = REAL(score)[ei]; -1L
         for(k = 0; k < nr; k++){
             tmp = data1[k + ei*nr] & data2[k + ei*nr];
             if(!tmp){
@@ -504,7 +512,7 @@ void fitchTripletACC4(int *root, int *dat1, int *dat2, int *dat3, int *nr, doubl
 }
 
 
-
+// eleganter in Rcpp
 SEXP FITCH345(SEXP nrx, SEXP node, SEXP edge, SEXP l, SEXP mx, SEXP ps){   
     int *nr=INTEGER(nrx), m=INTEGER(mx)[0], i;  
     double *pvtmp;  
@@ -630,7 +638,7 @@ SEXP FNALL_NNI(SEXP nrx, SEXP node, SEXP edge, SEXP l, SEXP mx, SEXP my, SEXP ro
     return(res); 
 }
 
-// mpr2 fnodesNew5
+// mpr2 fnodesNew5  , my = 2*n, n=length(node), root=node-1L
 SEXP FNALL5(SEXP nrx, SEXP node, SEXP edge, SEXP l, SEXP mx, SEXP my, SEXP root){   
     int *nr=INTEGER(nrx), m=INTEGER(mx)[0], i,  *n=INTEGER(l);  //*pars,
     double *pvtmp, *pvtmp2, pscore=0.0;  
@@ -661,6 +669,38 @@ SEXP FNALL5(SEXP nrx, SEXP node, SEXP edge, SEXP l, SEXP mx, SEXP my, SEXP root)
     return(pvec); 
 }
 
+// .Call("FNALL5", as.integer(nr), node, edge, as.integer(n), as.integer(m), 
+//      as.integer(m2), as.integer(root0), PACKAGE="phangorn")
+SEXP FNALL6(SEXP nrx, SEXP node, SEXP edge, SEXP mx){   
+    int *nr=INTEGER(nrx), m=INTEGER(mx)[0], i;  //*pars,
+    int n =length(node);
+    int root=INTEGER(node)[n-1L], my=2L*n;
+    double *pvtmp, *pvtmp2, pscore=0.0;  
+    SEXP pvec; 
+    int *pc, *edge2, *node2;
+    /* edge2, node2, pc ausserhalb definieren? */        
+    edge2 = (int *) R_alloc(2L * n, sizeof(int));
+    node2 = (int *) R_alloc(2L * n, sizeof(int));
+    pc = (int *) R_alloc(2L * n, sizeof(int));
+    
+    pvtmp2 = (double *) R_alloc(m, sizeof(double));
+    PROTECT(pvec = allocVector(REALSXP, m));    
+    pvtmp = REAL(pvec);
+    
+    for(i=0; i<m; i++){
+        pvtmp[i] = 0.0;
+        pvtmp2[i] = 0.0;
+    }
+    fnhelp(INTEGER(node), INTEGER(edge), &n, &m, &root, edge2, node2, pc);
+    fitch9(data1, nr, INTEGER(node), INTEGER(edge), &n, weight, pvtmp, &pscore); 
+    FN4(data1, data2, nr, node2, edge2, &my, pc, weight, pvtmp, pvtmp2); 
+    for(i=0; i<m; i++) pvtmp[i] += pvtmp2[i];
+    // return(pvtmp[edge])??    
+    UNPROTECT(1);
+    return(pvec); 
+}
+
+
 // inside optNNI Ziel 3* schneller  , double best
 void fitchquartet(int *dat1, int *dat2, int *dat3, int *dat4, int *nr, double *weight, double *pars){   
     int k, tmp1, tmp2;  
diff --git a/src/ml.c b/src/ml.c
index 3c20579..d46bf5c 100644
--- a/src/ml.c
+++ b/src/ml.c
@@ -1,7 +1,7 @@
 /* 
  * ml.c
  *
- * (c) 2008-2015  Klaus Schliep (klaus.schliep at gmail.com)
+ * (c) 2008-2016  Klaus Schliep (klaus.schliep at gmail.com)
  * 
  * 
  * This code may be distributed under the GNU GPL
@@ -21,7 +21,7 @@
 // index for LL
 #define LINDEX2(i, k) (i - *ntips - 1L) * (*nr* *nc) + k * *ntips * (*nr * *nc)
 // index for scaling matrix SCM
-#define LINDEX3(i, j) (i - *ntips - 1L) * *nr + j * *ntips * *nr
+#define LINDEX3(i, j) (i - *ntips - 1L) * *nr + j * *ntips * *nr  //nr statt *nr
 
 char *transa = "N", *transb = "N";
 double one = 1.0, zero = 0.0;
@@ -45,6 +45,10 @@ void ll_free(){
 LL likelihood for internal edges  
 SCM scaling coefficients 
 nNodes, nTips, kmax
+ 
+SC = (int *) R_alloc(nr * k, sizeof(int));
+sc = (int *) R_alloc(nr, sizeof(int));
+tmp = (double *) R_alloc(nr * k, sizeof(double)); 
 */
 void ll_init(int *nr, int *nTips, int *nc, int *k)
 {   
@@ -74,6 +78,14 @@ void ll_init2(int *data, int *weights, int *nr, int *nTips, int *nc, int *k)
 }
 
 
+int edgeLengthIndex(int child, int parent, int nTips){
+    if(child <= nTips) return(child-1L);
+    else{
+        if(child < parent) return(parent-1L);
+        return(child -1L);
+    }
+}
+
 
 void matm(int *x, double *contrast, int *nr, int *nc, int *nco, double *result){
     int i, j;
@@ -117,13 +129,25 @@ void matp(int *x, double *contrast, double *P, int *nr, int *nc, int *nrs, doubl
     int i, j;
     double *tmp; 
     tmp = (double *) R_alloc((*nc) *(*nrs), sizeof(double)); 
-//    matprod(contrast, (*nrs), (*nc), P, (*nc), (*nc), tmp);  
     F77_CALL(dgemm)(transa, transb, nrs, nc, nc, &one, contrast, nrs, P, nc, &zero, tmp, nrs);
     for(i = 0; i < (*nr); i++){ 
         for(j = 0; j < (*nc); j++) result[i + j*(*nr)] = tmp[x[i] - 1L + j*(*nrs)];  
     }
 }
 
+
+void rowMinScale(int *dat, int n,  int k, int *res){
+    int i, h;  
+    int tmp;
+    for(i = 0; i < n; i++){
+        tmp = dat[i];
+        for(h = 1; h< k; h++) {if(dat[i + h*n] < tmp) tmp=dat[i + h*n];}
+        if(tmp>0L){for(h = 0; h< k; h++) dat[i + h*n] -= tmp;}
+        res[i] = tmp;               
+    }        
+}
+
+
 static R_INLINE void getP(double *eva, double *ev, double *evi, int m, double el, double w, double *result){
     int i, j, h;
     double tmp[m], res;
@@ -138,7 +162,6 @@ static R_INLINE void getP(double *eva, double *ev, double *evi, int m, double el
 }
 
 
-
 SEXP getPM(SEXP eig, SEXP nc, SEXP el, SEXP w){
     R_len_t i, j, nel, nw, k;
     int m=INTEGER(nc)[0], l=0;
@@ -204,7 +227,6 @@ void lll(SEXP dlist, double *eva, double *eve, double *evei, double *el, double
 
  
 // neue Version: keine SEXP (dlist) 
-//  Ziel: openMP fuer Gamma (4 mal schneller)
 void lll0(int *X, double *eva, double *eve, double *evei, double *el, double g, int *nr, int *nc, int *node, int *edge, int nTips, double *contrast, int nco, int n, int *scaleTmp, double *bf, double *TMP, double *ans){
     int  ni, ei, j, i, rc; //    R_len_t i, n = length(node);
     double *rtmp, *P;
@@ -276,14 +298,12 @@ void lll3(SEXP dlist, double *eva, double *eve, double *evei, double *el, double
     F77_CALL(dgemv)(transa, nr, nc, &one, &ans[ni * rc], nr, bf, &ONE, &zero, TMP, &ONE);
 }
 
-// ohne openMP
-SEXP PML_NEW2(SEXP EL, SEXP W, SEXP G, SEXP NR, SEXP NC, SEXP K, SEXP eig, SEXP bf, SEXP node, SEXP edge, SEXP NTips, SEXP root, SEXP nco, SEXP contrast, SEXP N){
+
+SEXP PML_NEW2(SEXP EL, SEXP W, SEXP G, SEXP NR, SEXP NC, SEXP K, SEXP eig, SEXP bf, SEXP node, SEXP edge, SEXP NTips, SEXP nco, SEXP contrast, SEXP N){
     int nr=INTEGER(NR)[0], nc=INTEGER(NC)[0], k=INTEGER(K)[0], i, indLL; 
     int nTips = INTEGER(NTips)[0], *SC;
-//    int *nodes=INTEGER(node), 
     double *g=REAL(G), *tmp, logScaleEPS;
     SEXP TMP;
-    
     double *eva, *eve, *evei;
  
     eva = REAL(VECTOR_ELT(eig, 0));
@@ -307,8 +327,8 @@ SEXP PML_NEW2(SEXP EL, SEXP W, SEXP G, SEXP NR, SEXP NC, SEXP K, SEXP eig, SEXP
     return TMP;     
 }
 
-// mit openMP
-SEXP PML_NEW(SEXP EL, SEXP W, SEXP G, SEXP NR, SEXP NC, SEXP K, SEXP eig, SEXP bf, SEXP node, SEXP edge, SEXP NTips, SEXP root, SEXP nco, SEXP contrast, SEXP N){
+// TODO: parallelize
+SEXP PML_NEW(SEXP EL, SEXP W, SEXP G, SEXP NR, SEXP NC, SEXP K, SEXP eig, SEXP bf, SEXP node, SEXP edge, SEXP NTips, SEXP nco, SEXP contrast, SEXP N){
     int nr=INTEGER(NR)[0], nc=INTEGER(NC)[0], k=INTEGER(K)[0], i, indLL, n=INTEGER(N)[0], ncontr=INTEGER(nco)[0]; 
     int nTips = INTEGER(NTips)[0], *SC;
     int *nodes=INTEGER(node), *edges=INTEGER(edge);
@@ -324,15 +344,6 @@ SEXP PML_NEW(SEXP EL, SEXP W, SEXP G, SEXP NR, SEXP NC, SEXP K, SEXP eig, SEXP b
     tmp=REAL(TMP);
     for(i=0; i<(k*nr); i++)tmp[i]=0.0;
     indLL = nr * nc * nTips;
-/*  
-#ifdef _OPENMP
-if(*nthreads <= 1){ *nthreads=1; }else{ *nthreads=(*nthreads < omp_get_max_threads()) ? (*nthreads) : (omp_get_max_threads()); }
-#endif
-
-#ifdef SUPPORT_OPENMP     
-#pragma omp parallel for private(i)
-#endif
-*/
     for(i=0; i<k; i++){                  
         lll0(XXX, eva, eve, evei, el, g[i], &nr, &nc, nodes, edges, nTips, contr, ncontr, n, &SC[nr * i], bfreq, &tmp[i*nr], &LL[indLL *i]);           
      } 
@@ -343,8 +354,8 @@ if(*nthreads <= 1){ *nthreads=1; }else{ *nthreads=(*nthreads < omp_get_max_threa
     return TMP;     
 }
 
-
-SEXP PML3(SEXP dlist, SEXP EL, SEXP W, SEXP G, SEXP NR, SEXP NC, SEXP K, SEXP eig, SEXP bf, SEXP node, SEXP edge, SEXP NTips, SEXP root, SEXP nco, SEXP contrast, SEXP N){
+// in pml.move inside optimRooted
+SEXP PML3(SEXP dlist, SEXP EL, SEXP W, SEXP G, SEXP NR, SEXP NC, SEXP K, SEXP eig, SEXP bf, SEXP node, SEXP edge, SEXP NTips, SEXP nco, SEXP contrast, SEXP N){
     int nr=INTEGER(NR)[0], nc=INTEGER(NC)[0], k=INTEGER(K)[0], i, indLL; 
     int nTips = INTEGER(NTips)[0], *SC;
     double *g=REAL(G), *tmp, logScaleEPS;
@@ -368,7 +379,7 @@ SEXP PML3(SEXP dlist, SEXP EL, SEXP W, SEXP G, SEXP NR, SEXP NC, SEXP K, SEXP ei
 }
 
 
-SEXP PML0(SEXP dlist, SEXP EL, SEXP W, SEXP G, SEXP NR, SEXP NC, SEXP K, SEXP eig, SEXP bf, SEXP node, SEXP edge, SEXP NTips, SEXP root, SEXP nco, SEXP contrast, SEXP N){
+SEXP PML0(SEXP dlist, SEXP EL, SEXP W, SEXP G, SEXP NR, SEXP NC, SEXP K, SEXP eig, SEXP bf, SEXP node, SEXP edge, SEXP NTips, SEXP nco, SEXP contrast, SEXP N){
     int nr=INTEGER(NR)[0], nc=INTEGER(NC)[0], k=INTEGER(K)[0], i, indLL; 
     int nTips = INTEGER(NTips)[0], *SC;
     double *g=REAL(G), *tmp, logScaleEPS;
@@ -402,36 +413,14 @@ void moveLL5(double *LL, double *child, double *P, int *nr, int *nc, double *tmp
 } 
 
 
-SEXP moveloli(SEXP CH, SEXP PA, SEXP eig, SEXP EL, SEXP W, SEXP G, 
-    SEXP NR, SEXP NC, SEXP NTIPS){
-    int i, k=length(W);
-    int nc=INTEGER(NC)[0], nr=INTEGER(NR)[0], ntips=INTEGER(NTIPS)[0]; //, blub
-    int pa=INTEGER(PA)[0], ch=INTEGER(CH)[0];
-    double  *g=REAL(G); //*w=REAL(W),
-    double el=REAL(EL)[0];
-    double *eva, *eve, *evei, *tmp, *P;
-    tmp = (double *) R_alloc(nr * nc, sizeof(double));
-    P = (double *) R_alloc(nc * nc, sizeof(double));    
-
-    eva = REAL(VECTOR_ELT(eig, 0));
-    eve = REAL(VECTOR_ELT(eig, 1));
-    evei = REAL(VECTOR_ELT(eig, 2));
-
-    for(i = 0; i < k; i++){
-        getP(eva, eve, evei, nc, el, g[i], P);
-        moveLL5(&LL[LINDEX(ch, i)], &LL[LINDEX(pa, i)], P, &nr, &nc, tmp);
-    }
-    return ScalarReal(1L);
-}
-
 // dad / child * P 
 void helpDADI(double *dad, double *child, double *P, int nr, int nc, double *res){
     F77_CALL(dgemm)(transa, transb, &nr, &nc, &nc, &one, child, &nr, P, &nc, &zero, res, &nr);
     for(int j=0; j<(nc * nr); j++) dad[j]/=res[j];    
 } 
 
+
 // braucht Addition skalierte Werte 
-// 
 void helpPrep(double *dad, double *child, double *eve, double *evi, int nr, int nc, double *tmp, double *res){
     F77_CALL(dgemm)(transa, transb, &nr, &nc, &nc, &one, child, &nr, eve, &nc, &zero, res, &nr);
     F77_CALL(dgemm)(transa, transb, &nr, &nc, &nc, &one, dad, &nr, evi, &nc, &zero, tmp, &nr);
@@ -444,6 +433,7 @@ void helpDAD2(double *dad, int *child, double *contrast, double *P, int nr, int
     for(int j=0; j<(nc * nr); j++) res[j]=dad[j]/res[j];               
 } 
 
+
 void helpDAD5(double *dad, int *child, double *contrast, double *P, int nr, int nc, int nco, double *res){
     matp(child, contrast, P, &nr, &nc, &nco, res); 
     for(int j=0; j<(nc * nr); j++) dad[j]/=res[j];               
@@ -463,8 +453,7 @@ SEXP getDAD2(SEXP dad, SEXP child, SEXP contrast, SEXP P, SEXP nr, SEXP nc, SEXP
         }
     UNPROTECT(1); //RESULT    
     return(RESULT);    
-    }
-
+}
 
 
 void helpPrep2(double *dad, int *child, double *contrast, double *evi, int nr, int nc, int nrs, double *res){
@@ -547,26 +536,17 @@ void goUp(double *dad, int *child, double *contrast, double *P, int nr, int nc,
     for(int j=0; j<(nc * nr); j++) dad[j]*=res[j];               
 } 
 
-// in optimEdgeOld
-SEXP updateLL(SEXP dlist, SEXP PA, SEXP CH, SEXP eig, SEXP EL, SEXP W, SEXP G, SEXP NR,
-    SEXP NC, SEXP NTIPS, SEXP CONTRAST, SEXP NCO){    
-    int i, k=length(W);
-    int nc=INTEGER(NC)[0], nr=INTEGER(NR)[0], ntips=INTEGER(NTIPS)[0]; //, j, blub
-    int pa=INTEGER(PA)[0], ch=INTEGER(CH)[0], nco =INTEGER(NCO)[0];
-    double  *g=REAL(G), *contrast=REAL(CONTRAST); //*w=REAL(W),
-    double el=REAL(EL)[0];
-    double *eva, *eve, *evei, *tmp, *P;
-    tmp = (double *) R_alloc(nr * nc, sizeof(double));
-    P = (double *) R_alloc(nc * nc, sizeof(double));    
 
-    eva = REAL(VECTOR_ELT(eig, 0));
-    eve = REAL(VECTOR_ELT(eig, 1));
-    evei = REAL(VECTOR_ELT(eig, 2));
+void updateLLQ(SEXP dlist, int pa, int ch, double *eva, double *eve, double*evei,
+               double el, double *w, double *g, int nr,
+               int nc, int ntips, double *contrast, int nco, int k,
+               double *tmp, double *P){
+    int i; 
     if(ch>ntips){
         for(i = 0; i < k; i++){
             getP(eva, eve, evei, nc, el, g[i], P);
-            goDown(&LL[LINDEX(pa, i)], &LL[LINDEX(ch, i)], P, nr, nc, tmp);
-         }
+            goDown(&LL[LINDEX(ch, i)], &LL[LINDEX(pa, i)], P, nr, nc, tmp);
+        }
     }
     else{
         for(i = 0; i < k; i++){
@@ -574,10 +554,10 @@ SEXP updateLL(SEXP dlist, SEXP PA, SEXP CH, SEXP eig, SEXP EL, SEXP W, SEXP G, S
             goUp(&LL[LINDEX(pa, i)], INTEGER(VECTOR_ELT(dlist, ch-1L)), contrast, P, nr, nc, nco, tmp); 
         }
     }
-    return ScalarReal(1L);
 }
 
 
+
 void updateLL2(SEXP dlist, int pa, int ch, double *eva, double *eve, double*evei,
     double el, double *w, double *g, int nr,
     int nc, int ntips, double *contrast, int nco, int k,
@@ -599,39 +579,20 @@ void updateLL2(SEXP dlist, int pa, int ch, double *eva, double *eve, double*evei
 }
 
 
-SEXP extractI(SEXP CH, SEXP W, SEXP G, SEXP NR, SEXP NC, SEXP NTIPS){
-    int i, k=length(W);
-    int nc=INTEGER(NC)[0], nr=INTEGER(NR)[0], ntips=INTEGER(NTIPS)[0], j, blub;
-    int ch=INTEGER(CH)[0];
-//    double *w=REAL(W), *g=REAL(G);
-    
-    SEXP X, RESULT;
-    PROTECT(RESULT = allocVector(VECSXP, k));
-
-    for(i = 0; i < k; i++){
-        PROTECT(X = allocMatrix(REALSXP, nr, nc));
-        blub = LINDEX(ch, i);
-        for(j=0; j< (nr*nc); j++) REAL(X)[j] = LL[blub+j];
-        SET_VECTOR_ELT(RESULT, i, X);
-        UNPROTECT(1);
-    }
-    UNPROTECT(1); //RESULT    
-    return(RESULT);    
-}
-
-
-SEXP extractScale(SEXP CH, SEXP W, SEXP G, SEXP NR, SEXP NC, SEXP NTIPS){
-    int i, k=length(W);
-    int *nr=INTEGER(NR), *ntips=INTEGER(NTIPS), j, blub;
-    int ch=INTEGER(CH)[0];
-    SEXP RESULT;
-    PROTECT(RESULT = allocMatrix(REALSXP, *nr, k));
+void ExtractScale(int ch, int k, int *nr, int *ntips, double *res){
+    int i;
+    int j, blub, tmp;
     for(i = 0; i < k; i++){
         blub = LINDEX3(ch, i);
-        for(j=0; j< (*nr); j++) REAL(RESULT)[j +i * *nr] = SCM[blub+j];
+        for(j=0; j< *nr; j++) res[j +i * *nr] = SCM[blub+j];
+    }
+    for(i = 0; i< *nr; i++){
+        tmp = res[i];
+        for(j = 1; j<k; j++){
+            if(res[i+j * *nr]<tmp)tmp = res[i+j * *nr];
+        }    
+        for(j=0; j<k; j++) res[i+j * *nr] = pow(ScaleEPS, (res[i+j * *nr] - tmp));        
     }
-    UNPROTECT(1); //RESULT    
-    return(RESULT);    
 }
 
 
@@ -657,20 +618,6 @@ SEXP getDAD(SEXP dad, SEXP child, SEXP P, SEXP nr, SEXP nc){
     return(RESULT);    
     }
 
-/*
-// SEXP mixture of prepFS, prepFS & getPrep 
-void prepFS(double *XX, int ch, int pa, double *eva, double *eve, double *evi, double el, double *g, int nr, int nc, int ntips, int k){    
-    int i;
-    double *P, *tmp; 
-    tmp = (double *) R_alloc(nr * nc, sizeof(double));
-    P = (double *) R_alloc(nc * nc, sizeof(double)); 
-    for(i=0; i<k; i++){
-        getP(eva, eve, evi, nc, el, g[i], P);
-        helpDAD(&LL[LINDEX(pa, i)], &LL[LINDEX(ch, i)], P, nr, nc, tmp); //&LL[LINDEX(pa, i)]
-        helpPrep(&LL[LINDEX(ch, i)], &LL[LINDEX(pa, i)], eve, evi, nr, nc, tmp, &XX[i*nr*nc]);
-        }
-}        
-*/
 
 SEXP getPrep(SEXP dad, SEXP child, SEXP eve, SEXP evi, SEXP nr, SEXP nc){
     R_len_t i, n=length(dad);
@@ -689,38 +636,6 @@ SEXP getPrep(SEXP dad, SEXP child, SEXP eve, SEXP evi, SEXP nr, SEXP nc){
     return(RESULT);    
     }
 
-/*
-void prepFSE(double *XX, int *ch, int pa, double *eva, double *eve, double *evi, double el, double *g, int nr, int nc, int ntips, int k, double *contrast, double *contrast2, int ncs){    
-    int i;
-    double *P; //, *tmp 
-    P = (double *) R_alloc(nc * nc, sizeof(double)); 
-    for(i=0; i<k; i++){
-        getP(eva, eve, evi, nc, el, g[i], P);
-        helpDAD2(&ROOT[i * nr * nc], ch, contrast, P, nr, nc, ncs, &LL[LINDEX(pa, i)]);
-        helpPrep2(&LL[LINDEX(pa, i)], ch, contrast2,  evi, nr, nc, ncs, &XX[i*nr*nc]);
-        }
-}        
-*/
-
-SEXP getSCM(SEXP kk, SEXP nrx, SEXP nTips){
-    int j, nr = INTEGER(nrx)[0], ntips = INTEGER(nTips)[0], k = INTEGER(kk)[0]-1L;
-    SEXP RES;
-    PROTECT(RES = allocMatrix(INTSXP, nr, ntips));
-    for(j=0; j< (nr * ntips); j++) INTEGER(RES)[j] = SCM[j + k * nr *ntips];
-    UNPROTECT(1);
-    return(RES);
-}
-
-
-SEXP getLL(SEXP ax, SEXP bx, SEXP nrx, SEXP ncx, SEXP nTips){
-    int j, nc = INTEGER(ncx)[0], nr = INTEGER(nrx)[0], ntips = INTEGER(nTips)[0],  a = INTEGER(ax)[0], b = INTEGER(bx)[0];
-    SEXP RES;
-    PROTECT(RES = allocMatrix(REALSXP, nr, nc));
-    for(j=0; j<(nr*nc); j++) REAL(RES)[j] = LL[j + LINDEX(a, b)];
-    UNPROTECT(1);
-    return(RES);
-}
-
 
 void NR55(double *eva, int nc, double el, double *w, double *g, SEXP X, int ld, int nr, double *f, double *res){
     int i, j, k; 
@@ -765,9 +680,7 @@ void NR66(double *eva, int nc, double el, double *w, double *g, SEXP X, int ld,
 } 
 
 
-
-//void NR55(double *eva, int nc, double el, double *w, double *g,    SEXP X, int ld, int nr, double *f, double *res)
-  void NR77(double *eva, int nc, double el, double *w, double *g, double *X, int ld, int nr, double *f, double *res){
+void NR77(double *eva, int nc, double el, double *w, double *g, double *X, int ld, int nr, double *f, double *res){
     int i, j, k; 
     double *tmp;  
     tmp = (double *) R_alloc(nc, sizeof(double));
@@ -781,7 +694,7 @@ void NR66(double *eva, int nc, double el, double *w, double *g, SEXP X, int ld,
     
 } 
 
-//void NR66(double *eva, int nc, double el, double *w, double *g,  SEXP X, int ld, int nr, double *res) 
+
 void NR88(double *eva, int nc, double el, double *w, double *g, double *X, int ld, int nr, double *res){
     int i, j;   
     double *tmp; //*res,  *dF,
@@ -794,7 +707,7 @@ void NR88(double *eva, int nc, double el, double *w, double *g, double *X, int l
 }  
 
 
-// in ancestral.pml
+// in ancestral.pml and rnodes
 SEXP LogLik2(SEXP dlist, SEXP P, SEXP nr, SEXP nc, SEXP node, SEXP edge, SEXP nTips, SEXP mNodes, SEXP contrast, SEXP nco){
     R_len_t i, n = length(node);
     int nrx=INTEGER(nr)[0], ncx=INTEGER(nc)[0], nt=INTEGER(nTips)[0], mn=INTEGER(mNodes)[0];
@@ -836,7 +749,7 @@ SEXP LogLik2(SEXP dlist, SEXP P, SEXP nr, SEXP nc, SEXP node, SEXP edge, SEXP nT
     return(ans);
 }
 
-//raus
+
 static R_INLINE void matprod(double *x, int nrx, int ncx, double *y, int nry, int ncy, double *z)
 {
     F77_CALL(dgemm)(transa, transb, &nrx, &ncy, &ncx, &one, x, &nrx, y, &nry, &zero, z, &nrx);
@@ -1064,7 +977,7 @@ void fs3(double *eva, int nc, double el, double *w, double *g, double *X, int ld
 SEXP optE(SEXP PARENT, SEXP CHILD, SEXP ANC, SEXP eig, SEXP EVI, SEXP EL, 
                   SEXP W, SEXP G, SEXP NR, SEXP NC, SEXP NTIPS, SEXP CONTRAST, 
                   SEXP CONTRAST2, SEXP NCO, 
-                  SEXP BLUB, SEXP dlist, SEXP WEIGHT, SEXP F0){
+                  SEXP dlist, SEXP WEIGHT, SEXP F0){
     int i, k=length(W), h, j, n=length(PARENT), m, lEL=length(EL);
     int nc=INTEGER(NC)[0], nr=INTEGER(NR)[0], ntips=INTEGER(NTIPS)[0]; 
     int *parent=INTEGER(PARENT), *child=INTEGER(CHILD), *anc=INTEGER(ANC); //
@@ -1073,7 +986,8 @@ SEXP optE(SEXP PARENT, SEXP CHILD, SEXP ANC, SEXP eig, SEXP EVI, SEXP EL,
     double *g=REAL(G), *evi=REAL(EVI), *contrast=REAL(CONTRAST), *contrast2=REAL(CONTRAST2);
     double *el; //=REAL(EL);
     double *eva, *eve, *evei, *tmp, *P;
-    double *blub=REAL(BLUB), *X;
+    double  *X; // define it *blub=REAL(BLUB), 
+    double *blub = (double *) R_alloc(nr * nc, sizeof(double));
     double oldel; //=el[ch-1L]
     int ancloli, pa, ch; //=anc[loli]
     double *res = (double *) R_alloc(3L, sizeof(double));
@@ -1081,6 +995,8 @@ SEXP optE(SEXP PARENT, SEXP CHILD, SEXP ANC, SEXP eig, SEXP EVI, SEXP EL,
     P = (double *) R_alloc(nc * nc, sizeof(double));        
     X = (double *) R_alloc(k * nr * nc, sizeof(double));
 
+    ExtractScale(parent[0], k, &nr, &ntips, blub);
+    
     SEXP RESULT;
     PROTECT(RESULT = allocVector(REALSXP, lEL));
     el=REAL(RESULT);     
@@ -1094,12 +1010,12 @@ SEXP optE(SEXP PARENT, SEXP CHILD, SEXP ANC, SEXP eig, SEXP EVI, SEXP EL,
     for(m = 0; m < n; m++){
         pa = parent[m]; 
         ch = child[m];
-        oldel=el[ch-1L];
+        oldel=el[ch-1L]; //edgeLengthIndex
     
     while(loli != pa){    
         ancloli=anc[loli]; 
         for(i = 0; i < k; i++){
-            getP(eva, eve, evei, nc, el[loli-1L], g[i], P);
+            getP(eva, eve, evei, nc, el[loli-1L], g[i], P); //edgeLengthIndex
             moveLL5(&LL[LINDEX(loli, i)], &LL[LINDEX(ancloli, i)], P, &nr, &nc, tmp);
         }   
         loli = ancloli;
@@ -1132,7 +1048,7 @@ SEXP optE(SEXP PARENT, SEXP CHILD, SEXP ANC, SEXP eig, SEXP EVI, SEXP EL,
     fs3(eva, nc, oldel, w, g, X, k, nr, weight, f0, res);    
     updateLL2(dlist, pa, ch, eva, eve, evei, res[0], w, g, nr,
         nc, ntips, contrast, nco, k, tmp, P);
-        el[ch-1L] = res[0]; 
+        el[ch-1L] = res[0]; //edgeLengthIndex
         if (ch > ntips) loli  = ch;
         else loli = pa;
     }
@@ -1141,20 +1057,81 @@ SEXP optE(SEXP PARENT, SEXP CHILD, SEXP ANC, SEXP eig, SEXP EVI, SEXP EL,
 }
 
 
+SEXP optQrtt(SEXP PARENT, SEXP CHILD, SEXP eig, SEXP EVI, SEXP EL, 
+          SEXP W, SEXP G, SEXP NR, SEXP NC, SEXP NTIPS, SEXP CONTRAST, 
+          SEXP CONTRAST2, SEXP NCO, 
+          SEXP dlist, SEXP WEIGHT, SEXP F0){
+    int i, k=length(W), h, j, m, lEL=length(EL); 
+    int nc=INTEGER(NC)[0], nr=INTEGER(NR)[0], ntips=INTEGER(NTIPS)[0]; 
+    int *parent=INTEGER(PARENT), *child=INTEGER(CHILD), pa, ch; 
+    int nco =INTEGER(NCO)[0]; // loli, 
+    double *weight=REAL(WEIGHT), *f0=REAL(F0), *w=REAL(W);    
+    double *g=REAL(G), *evi=REAL(EVI), *contrast=REAL(CONTRAST), *contrast2=REAL(CONTRAST2);
+    double *el, *X; 
+    double *eva, *eve, *evei, *tmp, *P;
+    double *blub = (double *) R_alloc(nr * nc, sizeof(double));
+    double oldel; 
+    double *res = (double *) R_alloc(3L, sizeof(double));
+    tmp = (double *) R_alloc(nr * nc, sizeof(double));
+    P = (double *) R_alloc(nc * nc, sizeof(double));        
+    X = (double *) R_alloc(k * nr * nc, sizeof(double));
+    
+    ExtractScale(parent[0], k, &nr, &ntips, blub);
+    
+    SEXP RESULT;
+    PROTECT(RESULT = allocVector(REALSXP, lEL));
+    el=REAL(RESULT);     
+    for(i = 0; i < lEL; i++) el[i] = REAL(EL)[i];
+    eva = REAL(VECTOR_ELT(eig, 0));
+    eve = REAL(VECTOR_ELT(eig, 1));
+    evei = REAL(VECTOR_ELT(eig, 2));
 
-void rowMinScale(int *dat, int n,  int k, int *res){
-    int i, h;  
-    int tmp;
-    for(i = 0; i < n; i++){
-        tmp = dat[i];
-        for(h = 1; h< k; h++) {if(dat[i + h*n] < tmp) tmp=dat[i + h*n];}
-        if(tmp>0L){for(h = 0; h< k; h++) dat[i + h*n] -= tmp;}
-        res[i] = tmp;               
-    }        
+    for(m = 4L; m > -1L; m--){
+        pa = parent[m]; 
+        ch = child[m];
+        oldel=el[m];      
+        // moveDad        
+        if(ch>ntips){
+            for(i = 0; i < k; i++){
+                getP(eva, eve, evei, nc, oldel, g[i], P);
+                helpDADI(&LL[LINDEX(pa, i)], &LL[LINDEX(ch, i)], P, nr, nc, tmp);
+                helpPrep(&LL[LINDEX(pa, i)], &LL[LINDEX(ch, i)], eve, evi, nr, nc, tmp, &X[i*nr*nc]);
+                for(h = 0; h < nc; h++){
+                    for(j = 0; j < nr; j++){
+                        X[j+h*nr + i*nr*nc] *= blub[j+i*nr];
+                    } 
+                }
+            }
+        }
+        else{
+            for(i = 0; i < k; i++){
+                getP(eva, eve, evei, nc, oldel, g[i], P);           
+                helpDAD5(&LL[LINDEX(pa, i)], INTEGER(VECTOR_ELT(dlist, ch-1L)), contrast, P, nr, nc, nco, tmp); 
+                helpPrep2(&LL[LINDEX(pa, i)], INTEGER(VECTOR_ELT(dlist, ch-1L)), contrast2, evi, nr, nc, nco, &X[i*nr*nc]); //; 
+                for(h = 0; h < nc; h++){
+                    for(j = 0; j < nr; j++){
+                        X[j+h*nr + i*nr*nc] *= blub[j+i*nr];
+                    } 
+                }
+            }
+        }
+        fs3(eva, nc, oldel, w, g, X, k, nr, weight, f0, res);    
+// go up
+// if i=2 go down 
+        
+        if(m==2)updateLLQ(dlist, ch, pa, eva, eve, evei, res[0], w, g, nr,
+                  nc, ntips, contrast, nco, k, tmp, P);
+        else updateLLQ(dlist, pa, ch, eva, eve, evei, res[0], w, g, nr,
+                  nc, ntips, contrast, nco, k, tmp, P);
+        el[m] = res[0];     
+    }
+    UNPROTECT(1); //RESULT    
+    return(RESULT);     
 }
 
 
-SEXP PML4(SEXP dlist, SEXP EL, SEXP W, SEXP G, SEXP NR, SEXP NC, SEXP K, SEXP eig, SEXP bf, SEXP node, SEXP edge, SEXP NTips, SEXP root, SEXP nco, SEXP contrast, SEXP N){
+
+SEXP PML4(SEXP dlist, SEXP EL, SEXP W, SEXP G, SEXP NR, SEXP NC, SEXP K, SEXP eig, SEXP bf, SEXP node, SEXP edge, SEXP NTips, SEXP nco, SEXP contrast, SEXP N){
     int nr=INTEGER(NR)[0], nc=INTEGER(NC)[0], k=INTEGER(K)[0], i, j, indLL; 
     int nTips = INTEGER(NTips)[0], *SC, *sc;
     double *g=REAL(G), *w=REAL(W), *tmp, *res; 
@@ -1186,34 +1163,4 @@ SEXP PML4(SEXP dlist, SEXP EL, SEXP W, SEXP G, SEXP NR, SEXP NC, SEXP K, SEXP ei
 
 
 
-SEXP PML5(SEXP dlist, SEXP EL, SEXP W, SEXP G, SEXP NR, SEXP NC, SEXP K, SEXP eig, SEXP bf, SEXP node, SEXP edge, SEXP NTips, SEXP root, SEXP nco, SEXP contrast, SEXP N){
-    int nr=INTEGER(NR)[0], nc=INTEGER(NC)[0], k=INTEGER(K)[0], i, j, indLL; 
-    int nTips = INTEGER(NTips)[0], *SC, *sc;
-    double *g=REAL(G), *w=REAL(W), *tmp, *res; 
-    SEXP TMP;
-    double *eva, *eve, *evei;
-    eva = REAL(VECTOR_ELT(eig, 0));
-    eve = REAL(VECTOR_ELT(eig, 1));
-    evei = REAL(VECTOR_ELT(eig, 2));
-    SC = (int *) R_alloc(nr * k, sizeof(int));
-    sc = (int *) R_alloc(nr, sizeof(int));
-    tmp = (double *) R_alloc(nr * k, sizeof(double));
-    PROTECT(TMP = allocVector(REALSXP, nr)); 
-    
-    res=REAL(TMP);
-    for(i=0; i<(k*nr); i++)tmp[i]=0.0;
-    indLL = nr * nc * nTips;  
-    for(i=0; i<k; i++){
-         lll(dlist, eva, eve, evei, REAL(EL), g[i], &nr, &nc, INTEGER(node), INTEGER(edge), nTips, REAL(contrast), INTEGER(nco)[0], INTEGER(N)[0], &SC[nr * i], REAL(bf), &tmp[i*nr], &LL[indLL *i]);
-    } 
-    rowMinScale(SC, nr, k, sc);
-    for(i=0; i<nr; i++){
-        res[i]=0.0;
-        for(j=0;j<k;j++)res[i] += w[j] * exp(LOG_SCALE_EPS * SC[i+j*nr]) * tmp[i+j*nr]; 
-    }     
-    UNPROTECT(1);
-    return TMP;     
-}
-
-
 
diff --git a/src/phangorn.c b/src/phangorn.c
index 9af27ca..b081fa0 100644
--- a/src/phangorn.c
+++ b/src/phangorn.c
@@ -1,7 +1,7 @@
 /* 
  * phangorn.c
  *
- * (c) 2008-2015  Klaus Schliep (klaus.schliep at gmail.com)
+ * (c) 2008-2016  Klaus Schliep (klaus.schliep at gmail.com)
  * 
  * 
  * This code may be distributed under the GNU GPL
@@ -32,25 +32,6 @@
 // index sankoff
 #define SINDEX(i) i * (nr*nc) 
 
-/* from coalescentMCMC
-void get_single_index_integer(int *x, int *val, int *index)
-{
-    int i = 0, v = *val;
-	while (x[i] != v) i++;
-	*index = i + 1;
-}
-
-void get_two_index_integer(int *x, int *val, int *index)
-{
-	int i1 = 0, i2, v = *val;
-	while (x[i1] != v) i1++;
-	i2 = i1 + 1;
-	while (x[i2] != v) i2++;
-	index[0] = i1 + 1;
-	index[1] = i2 + 1;
-}
-*/
-
 
 void countCycle(int *M, int *l, int *m, int *res){
     int j, i, tmp;
@@ -509,80 +490,14 @@ SEXP AllDesc(SEXP child, SEXP parent, SEXP M, SEXP NODE){
 }
 
 
-// combine two sorted vectors
-void crsort(double *x, double *y, int *a, int *b, double *res){
-   double xi, yi;
+// std::merge
+void cisort(int *x, int *y, int a, int b, int *res){
    int i, j, k;    
    i=0;
    j=0;
    k=0;
-   xi=x[0];
-   yi=y[0];  
-   while(k<((*a)+(*b))){
-      if(i<(*a)){
-          if( (xi<yi) | (j==((*b))) ){  //-1L
-              res[k]=xi;      
-              i++;
-              if(i<(*a))xi=x[i];   
-              k++;     
-          }
-          else{
-              j++;
-              res[k]=yi;
-              if(j<(*b))yi=y[j];  
-              k++;
-          }
-        }
-        else{
-              j++;
-              res[k]=yi;
-              if(j<(*b))yi=y[j];  
-              k++;
-          }
-    }  
-}    
-
-
-void cisort(int *x, int *y, int *a, int *b, int *res){
-   int xi, yi;
-   int i, j, k;    
-   i=0;
-   j=0;
-   k=0;
-   xi=x[0];
-   yi=y[0];  
-   while(k<((*a)+(*b))){
-      if(i<(*a)){
-          if( (xi<yi) | (j==((*b))) ){  //-1L
-              res[k]=xi;      
-              i++;
-              if(i<(*a))xi=x[i];   
-              k++;     
-          }
-          else{
-              j++;
-              res[k]=yi;
-              if(j<(*b))yi=y[j];  
-              k++;
-          }
-        }
-        else{
-              j++;
-              res[k]=yi;
-              if(j<(*b))yi=y[j];  
-              k++;
-          }
-    }
-}    
-
-void cisort2(int *x, int *y, int a, int b, int *res){
-   int xi, yi;
-   int i, j, k;    
-   i=0;
-   j=0;
-   k=0;
-   xi=x[0];
-   yi=y[0];  
+   int xi=x[0];
+   int yi=y[0];  
    while(k<((a)+(b))){
       if(i<(a)){
           if( (xi<yi) | (j==b) ){  //-1L
@@ -605,10 +520,10 @@ void cisort2(int *x, int *y, int a, int b, int *res){
               k++;
           }
     }
-}    
+}  
 
-// faster cophenetic 
 
+// faster cophenetic 
 void C_bipHelp(int *parents, int *children, int *ntips, int *mp, int *l, int *ltips, int *ptips){
    int p, k, i;
    for(i=0; i<*ntips; i++)ltips[i]=1L;
@@ -639,12 +554,12 @@ void C_bip2(int *parents, int *children, int *ntips, int *mp, int *l, int *ltips
         ci = children[i];
         if(pi==p){
              if(ci < (*ntips+1L)){
-                 cisort(&ci, tmp, &eins, &ltmp, tmp2);            
+                 cisort(&ci, tmp, eins, ltmp, tmp2);            
                  ltmp += 1L;
                  for(j=0; j<ltmp; j++) tmp[j] = tmp2[j];
              }
              else{
-                 cisort(&tips[ptips[ci-1L]], tmp, &(ltips[ci-1L]), &ltmp, tmp2);                       
+                 cisort(&tips[ptips[ci-1L]], tmp, (ltips[ci-1L]), ltmp, tmp2);                       
                  ltmp += ltips[ci-1L]; //  lch[ci]; 
 //               ltmp +=   lch[ci];
                  for(j=0; j<ltmp; j++) tmp[j] = tmp2[j];                                
@@ -760,12 +675,12 @@ SEXP C_bip(SEXP parent, SEXP child, SEXP nTips, SEXP maxP){ //, SEXP Nnode){
         ci = INTEGER(child)[i];
         if(pi==p){
              if(ci < (nt+1L)){
-                 cisort(&ci, tmp, &eins, &ltmp, tmp2);            
+                 cisort(&ci, tmp, eins, ltmp, tmp2);            
                  ltmp += 1L;
                  for(j=0; j<ltmp; j++) tmp[j] = tmp2[j];
              }
              else{
-                 cisort(INTEGER(VECTOR_ELT(ans, ci-1L)), tmp, &(lch[ci]), &ltmp, tmp2);                       
+                 cisort(INTEGER(VECTOR_ELT(ans, ci-1L)), tmp, (lch[ci]), ltmp, tmp2);                       
                  ltmp += lch[ci]; 
                  for(j=0; j<ltmp; j++) tmp[j] = tmp2[j];                                
              }
@@ -824,12 +739,12 @@ SEXP C_bipart(SEXP parent, SEXP child, SEXP nTips, SEXP maxP){ //, SEXP Nnode){
         ci = INTEGER(child)[i];
         if(pi==p){
              if(ci < (nt+1L)){
-                 cisort(&ci, tmp, &eins, &ltmp, tmp2);            
+                 cisort(&ci, tmp, eins, ltmp, tmp2);            
                  ltmp += 1L;
                  for(j=0; j<ltmp; j++) tmp[j] = tmp2[j];
              }
              else{
-                 cisort(INTEGER(VECTOR_ELT(ans, kl[ci])), tmp, &(lch[ci]), &ltmp, tmp2);                       
+                 cisort(INTEGER(VECTOR_ELT(ans, kl[ci])), tmp, lch[ci], ltmp, tmp2);                       
                  ltmp += lch[ci]; 
                  for(j=0; j<ltmp; j++) tmp[j] = tmp2[j];                                
              }
diff --git a/src/sankoff.c b/src/sankoff.c
index 0a22f23..2f5f953 100644
--- a/src/sankoff.c
+++ b/src/sankoff.c
@@ -1,7 +1,7 @@
 /* 
  * dist.c
  *
- * (c) 2008-2015  Klaus Schliep (klaus.schliep at gmail.com)
+ * (c) 2008-2016  Klaus Schliep (klaus.schliep at gmail.com)
  * 
  * 
  * This code may be distributed under the GNU GPL
diff --git a/tests/testthat/test_distances.R b/tests/testthat/test_distances.R
new file mode 100644
index 0000000..f1ac117
--- /dev/null
+++ b/tests/testthat/test_distances.R
@@ -0,0 +1,18 @@
+context("distances")
+
+X <- allSitePattern(5)
+tree <- read.tree(text = "((t1:0.3,t2:0.3):0.1,(t3:0.3,t4:0.3):0.1,t5:0.5);")
+fit <- pml(tree,X, k=4, shape=0.5)
+
+weights <- as.vector(1000*exp(fit$site)) 
+attr(X, "weight") <- weights
+dm <- cophenetic(tree)
+
+
+test_that("dist.ml works properly", {
+    skip_on_cran()
+    expect_that(dist.logDet(X), is_a("dist"))
+    expect_that(dist.hamming(X), is_a("dist"))
+    expect_that(dist.ml(X), is_a("dist"))
+    all.equal(as.matrix(dist.ml(X, k=4, shape=.5)), dm)
+})
\ No newline at end of file
diff --git a/tests/testthat/test_parsimony.R b/tests/testthat/test_parsimony.R
index 6b30c56..ee2ac27 100644
--- a/tests/testthat/test_parsimony.R
+++ b/tests/testthat/test_parsimony.R
@@ -2,16 +2,19 @@ context("parsimony")
 
 tree1 = read.tree(text = "((t1,t2),t3,t4);")
 tree2 = read.tree(text = "((t1,t3),t2,t4);")
+trees = .compressTipLabel(c(tree1, tree2))
 dat <- phyDat(c(t1="a", t2="a",t3="t",t4="t"), type="USER", levels=c("a","c","g","t"))
 #tr_acctran = acctran(tree1, dat)
 #tr_ratchet = pratchet(dat, trace=0)
 #bab(dat)
 test_that("parsimony works properly", {
-    skip_on_cran()
+##    skip_on_cran()
     expect_that(fitch(tree1, dat), equals(1))
     expect_that(fitch(tree2, dat), equals(2))
+    expect_that(fitch(trees, dat), equals(c(1,2)))
     expect_that(sankoff(tree1, dat), equals(1))
     expect_that(sankoff(tree2, dat), equals(2))
+    
     expect_that(parsimony(tree1, dat), equals(1))
 })
 
diff --git a/tests/testthat/test_pml.R b/tests/testthat/test_pml.R
new file mode 100644
index 0000000..949c4c0
--- /dev/null
+++ b/tests/testthat/test_pml.R
@@ -0,0 +1,61 @@
+context("likelihood")
+
+treeU1 = read.tree(text = "((t1:.1,t2:.1):.1,t3:.2,(t4:.1,t5:.1):.3);")
+treeU2 = read.tree(text = "((t1:.15,t2:.15):.05,t3:.2,(t4:.1,t5:.1):.3);") # edge length changed
+treeU3 = read.tree(text = "((t1:.1,t3:.1):.1,t2:.2,(t4:.1,t5:.1):.3);") # 1 NNI move
+
+treeR1 = read.tree(text = "(((t1:.1,t2:.1):.1,t3:.2):.1,(t4:.1,t5:.1):.2);")
+treeR2 = read.tree(text = "(((t1:.15,t2:.15):.05,t3:.2):.1,(t4:.1,t5:.1):.2);") # edge length changed
+treeR3 = read.tree(text = "(((t1:.1,t3:.1):.1,t2:.2):.1,(t4:.1,t5:.1):.2);") # 1 NNI move
+
+
+# dat <- phyDat(c(t1="a", t2="a",t3="t",t4="t"), type="USER", levels=c("a","c","g","t"))
+#tree2 = read.tree(text = "((t1,t3),t2,t4);")
+
+dat = allSitePattern(5)
+weights = as.vector(1000 * exp(pml(treeR1, dat)$siteLik))
+attr(dat, "weight") = weights
+
+bf = c(.1,.2,.3,.4)
+Q = c(6:1)
+
+
+pmlU1 = pml(treeU1, dat)
+pmlU2 = pml(treeU2, dat)
+pmlU2.fitted = optim.pml(pmlU2, control = pml.control(trace=0))
+pmlU3 = pml(treeU3, dat)
+pmlU3.fitted = optim.pml(pmlU3, TRUE, control = pml.control(trace=0))
+
+pmlR1 = pml(treeR1, dat)
+pmlR2 = pml(treeR2, dat)
+pmlR2.fitted = optim.pml(pmlR2, optRooted = TRUE, control = pml.control(epsilon=1e-10, trace=0))
+pmlR3 = pml(treeR3, dat)
+pmlR3.fitted = optim.pml(pmlR3, TRUE, optRooted = TRUE,  control = pml.control(epsilon=1e-10, trace=0))
+
+
+
+# optim.pml:
+# bf F81
+# Q  Sym
+# Gamma
+# Inv
+
+
+#tr_acctran = acctran(tree1, dat)
+#tr_ratchet = pratchet(dat, trace=0)
+#bab(dat)
+test_that("edge length optimisation works properly", {
+    skip_on_cran()
+    expect_equal(logLik(pmlU2.fitted), logLik(pmlU1))
+    expect_equal(logLik(pmlR2.fitted), logLik(pmlR1))  
+    expect_equal(pmlU2.fitted$tree, pmlU1$tree, tolerance=1e-6)
+#    expect_equal(pmlR2.fitted$tree, pmlR1$tree, tolerance=5e-5)
+})
+
+test_that("NNI optimisation works properly", {
+    skip_on_cran()
+    expect_equal(logLik(pmlU3.fitted), logLik(pmlU1))
+    expect_equal(logLik(pmlR3.fitted), logLik(pmlR1))
+    expect_equal(pmlU3.fitted$tree, pmlU1$tree, tolerance=1e-6)
+#    expect_equal(pmlR3.fitted$tree, pmlR1$tree, tolerance=5e-6)
+})
diff --git a/tests/testthat/test_splits.R b/tests/testthat/test_splits.R
new file mode 100644
index 0000000..1f2e20e
--- /dev/null
+++ b/tests/testthat/test_splits.R
@@ -0,0 +1,23 @@
+context("Test conversions")
+
+## generate data
+set.seed(1)
+tree <- rtree(10, FALSE) 
+tree2spl <- as.splits(tree)
+spl2tree <- as.phylo(tree2spl)
+dm <- cophenetic(tree2spl)
+mat <- as.matrix(tree2spl)
+Mat <- as.Matrix(tree2spl)
+
+test_that("splits ", {
+    ## skip on CRAN
+    skip_on_cran()
+    
+    ## check classes
+    expect_is(tree2spl, "splits")
+    expect_is(spl2tree,"phylo")
+    expect_is(dm,"dist")
+    expect_is(mat, "matrix")
+    expect_is(Mat, "Matrix")
+    expect_equal(spl2tree , tree)
+})
diff --git a/tests/testthat/test_treeManipulation.R b/tests/testthat/test_treeManipulation.R
new file mode 100644
index 0000000..006d785
--- /dev/null
+++ b/tests/testthat/test_treeManipulation.R
@@ -0,0 +1,35 @@
+context("treeManipulation")
+
+set.seed(42)
+tree <- rtree(100)
+
+#Ancestors(x, node, type=c("all","parent"))
+#Children(x, node)
+#Siblings(x, node, include.self=FALSE)
+#Descendants(x, node, type=c("tips","children","all"))
+#Siblings(tree, 3)
+#mrca.phylo(tree, 1:3)
+#midpoint
+
+
+desc_108 <- Descendants(tree, 108)[[1]]
+node_108 <- mrca.phylo(tree, node=desc_108)
+
+test_that("ancestor, mrca, descendants", {
+    ## check RF.dist and tree dist
+    expect_equal(mrca.phylo(tree, node=desc_108), 108)
+})
+
+test_that("allTrees, nni", {
+    ## allTrees
+    expect_is(allTrees(6), "multiPhylo")
+    expect_true(all(RF.dist(allTrees(6))>0))
+    ## nni
+    expect_is(nni(tree), "multiPhylo")
+    expect_true(all(RF.dist(nni(tree), tree)>0))
+})
+
+
+
+
+
diff --git a/tests/testthat/test_treedist.R b/tests/testthat/test_treedist.R
index 62d1b88..2f776ef 100644
--- a/tests/testthat/test_treedist.R
+++ b/tests/testthat/test_treedist.R
@@ -1,14 +1,77 @@
 context("treedist")
 
+## generate data
+set.seed(42)
+tree <- rtree(10, FALSE)
+trees <- nni(tree)
+tree1 <- read.tree(text="(t5:1.0,(t4:1.0,t3:1.0):1.0,(t1:1.0,t2:1.0):1.0);")
+tree2 <- read.tree(text="(t4:1.0,(t5:1.0,t3:1.0):1.0,(t1:1.0,t2:1.0):1.0);")
+tree3 <- read.tree(text="(t5:1.0,t4:1.0,t3:1.0,(t1:1.0,t2:1.0):1.0);")
+
 test_that("Robinson-Foulds distance", {
-    skip_on_cran()
-    tree1 = read.tree(text="(t5:1.0,(t4:1.0,t3:1.0):1.0,(t1:1.0,t2:1.0):1.0);")
-    tree2 = read.tree(text="(t4:1.0,(t5:1.0,t3:1.0):1.0,(t1:1.0,t2:1.0):1.0);")
-    tree3 = read.tree(text="(t5:1.0,t4:1.0,t3:1.0,(t1:1.0,t2:1.0):1.0);")
+    ## check RF.dist and tree dist
     expect_that(RF.dist(tree1, tree1), is_equivalent_to(0))
     expect_that(RF.dist(tree1, tree2), is_equivalent_to(2))
     expect_that(RF.dist(tree1, tree3), is_equivalent_to(1))
+    
+    expect_true( all(RF.dist(tree, trees)==2) ) 
+    expect_is(RF.dist(trees),"dist")
+    
     expect_that(treedist(tree1, tree1)[1], is_equivalent_to(0))
     expect_that(treedist(tree1, tree2)[1], is_equivalent_to(2))
     expect_that(treedist(tree1, tree3)[1], is_equivalent_to(1))
-})
\ No newline at end of file
+})
+
+test_that("Kuhner-Felsenstein distance (branch score difference)", {
+    ## check RF.dist and tree dist
+    expect_that(KF.dist(tree1, tree1), is_equivalent_to(0))
+    expect_that(KF.dist(tree1, tree2), is_equivalent_to(sqrt(2)))
+    expect_that(KF.dist(tree1, tree3), is_equivalent_to(1))
+    
+    expect_is(KF.dist(trees),"dist")
+    
+    expect_that(treedist(tree1, tree1)[2], is_equivalent_to(0))
+    expect_that(treedist(tree1, tree2)[2], is_equivalent_to(sqrt(2)))
+    expect_that(treedist(tree1, tree3)[2], is_equivalent_to(1))
+})
+
+test_that("path distance", {
+    ## check path dist
+    expect_that(path.dist(tree1, tree1), is_equivalent_to(0))
+    expect_is(path.dist(trees),"dist")
+})
+
+
+############################
+# new tests from Michelle 
+############################
+
+# make simple trees with one pair of unmatched edges, unit branch lengths
+tr1 <- read.tree(text="((A:1,B:1):1,C:1,(D:1,E:1):1);")
+tr2 <- read.tree(text="((A:1,C:1):1,B:1,(D:1,E:1):1);")
+
+# make a tree with same topology as tr1 but varied branch lengths
+tr3 <- read.tree(text="((A:2,B:1):3,C:1,(D:1,E:2):1);")
+
+test_that("Distance between known trees matches calculation by hand", {
+    expect_equal(wRF.dist(tr1,tr2),2) # one pair of unmatched edges, unit branch lengths
+    expect_equal(RF.dist(tr1,tr2),2) # one pair of unmatched edges (branch lengths irrelevant)
+    expect_equal(wRF.dist(tr1,tr3),4) # same topology, different branch lengths
+    expect_equal(RF.dist(tr1,tr3),0) # same topology (branch lengths irrelevant)
+    expect_equal(wRF.dist(tr2,tr3),6) # one pair of unmatched edges, varied branch lengths
+})
+
+############################
+# test that RF and wRF give same values for trees with every edge = 1
+############################
+test_that("When each tree has unit branch lengths, RF = wRF", {
+    skip_on_cran()
+    expect_equal(
+        max(
+            sapply(sample(10:500,50), function(x) { # test some random numbers of tips between 10 and 500
+                trees <- rmtree(20, x, rooted=FALSE, br=1) # generate 20 unrooted trees with the given number of tips and unit branch lengths
+                max(abs(RF.dist(trees) - wRF.dist(trees))) # find maximum abs difference between RF and wRF distance (expect 0)
+            })), # find max of all these
+        0) # expect equal to 0
+})
+
diff --git a/vignettes/Ancestral.Rnw b/vignettes/Ancestral.Rnw
index 09473be..8b29ab7 100644
--- a/vignettes/Ancestral.Rnw
+++ b/vignettes/Ancestral.Rnw
@@ -43,6 +43,7 @@
 
 <<echo=FALSE>>=
 options(width=70)
+options("show.signif.stars" = FALSE)
 foo <- packageDescription("phangorn")
 @
 
diff --git a/vignettes/IntertwiningTreesAndNetworks.Rmd b/vignettes/IntertwiningTreesAndNetworks.Rmd
new file mode 100644
index 0000000..53a147a
--- /dev/null
+++ b/vignettes/IntertwiningTreesAndNetworks.Rmd
@@ -0,0 +1,190 @@
+---
+title: 'Intertwining phylogenetic trees and networks: R Example Script'
+author: "Klaus Schliep, Alastair Potts, David Morrison and Guido Grimm"
+date: "`r format(Sys.time(), '%B %d, %Y')`"
+output: rmarkdown::html_vignette
+vignette: >
+   %\VignetteIndexEntry{IntertwiningTreesAndNetworks}
+   %\VignetteEngine{knitr::rmarkdown}
+   %\usepackage[utf8]{inputenc}
+---
+
+
+```{r setup, echo=FALSE}
+# set global chunk options: images will be bigger
+knitr::opts_chunk$set(fig.width=7, fig.height=7) 
+options(digits = 4)
+```
+
+
+*Description:* This script provides examples of the new functions available in the phangorn library to 'intertwine' trees and networks, i.e. compare trees and networks and data transferrance. It also provides a step-by-step guide for users new to R. 
+
+*Methodological advancement:* The major advancement in this phangorn update is the introduction of a generic network object with a wide range of related transfer and analysis functions. These new functions provide the first means to directly transfer information amongst a wide range of phylogenetic trees and networks, as well as means to visualise and further analyse this information. This should provide a platform for individuals to easily conduct tree-network comparisons and stimulate  [...]
+
+*What next?:* By implementing full network handling compatibility in R, and providing exemplar scripts (such as this) and [support](https://github.com/KlausVigo/phangorn), the scientific community now has an easy means to analyse and compare the results of phylogenetic trees vs. network approaches. We hope this will open a largely unexplored world to the general phylogenetic audience. 
+
+
+### Installing R                                                 
+1. Download R                                                     
+ Select the nearest mirror to your location at https://cran.r-project.org/mirrors.html                          
+2. Select your operating system and download the relevant installation file.                                             
+3. Install R following the instructions.                          
+
+### Installing the phangorn library                                 
+Open R and run the two lines of code below in the command line.   
+(You will need to select a region from which to download the library)                       
+```{r, eval=FALSE}
+install.packages("phangorn", dependencies=TRUE)
+# install latest development version needs devtools
+install.packages("devtools", dependencies=TRUE)
+library(devtools)
+install_github("KlausVigo/phangorn")
+```
+
+
+### Getting started                                                  
+```{r}
+library(phangorn)    # load the phangorn library
+```
+
+### Set the working directory
+This is often a major stumbling block for new R users. You need to specify where in your folder structure you wish to work. i.e, where are the files stored that you wish to input?
+
+This is done using the setwd() function, e.g. setwd("C:/TreesNetworks/Example Files").
+
+We now set it to the folder of the phangorn package, which contains the files we want to load for this example.
+
+### Read in the example file datasets:
+This example files are based on the woodmouse dataset available in the ape library. Ultimately, this dataset is from this study: Michaux, J. R., Magnanou, E., Paradis, E., Nieberding, C. and Libois, R. (2003) 
+Mitochondrial phylogeography of the Woodmouse (*Apodemus sylvaticus*) in the Western 
+Palearctic region. Molecular Ecology, 12, 685-697.)
+ 
+```{r} 
+## automatically set the correct working directory for the examples below
+# setwd(system.file("extdata/trees", package = "phangorn"))
+# for this vignette we create a path to the files we want to load 
+fdir <- system.file("extdata/trees", package = "phangorn")
+## in your case it may look something like this...
+# setwd("C:/TreesNetworks/Example Files")
+
+##DNA Matrix, maybe not needed 
+woodmouse <- read.phyDat(file.path(fdir, "woodmouse.fasta"),format="fasta") 
+## RAxML best-known tree with bipartition support (from previous analysis)
+raxml.tree <- read.tree(file.path(fdir,"RAxML_bipartitions.woodmouse"))
+## RAxML bootstrap trees (from previous analysis)
+raxml.bootstrap <- read.tree(file.path(fdir,"RAxML_bootstrap.woodmouse"))
+## MrBayes consensus tree (50% majority rule) (from previous analysis)
+mrbayes.tree <- read.nexus(file.path(fdir,"woodmouse.mrbayes.nex.con"))
+## MrBayes sample runs 1 and 2 (from previous analysis)
+run1 <- read.nexus(file.path(fdir,"woodmouse.mrbayes.nex.run1.t"))
+run2 <- read.nexus(file.path(fdir,"woodmouse.mrbayes.nex.run2.t"))
+## How many trees are in the MrBayes tree sample?
+run1
+run2
+## Combining the two runs and removing 25% burn-in
+mrbayes.trees <- c(run1[251:1001],run2[251:1001])
+## NeigbourNet Nexus file generated by SplitsTree (from previous analysis)
+Nnet <- read.nexus.networx(file.path(fdir,"woodmouse.nxs"))
+```
+All example files read into R.
+
+### Viewing the data   
+```{r}
+par(mfrow=c(1,2), mar=c(2,2,2,2)) # Setting plot parameters
+### Plotting trees with support values:
+##  RAxML
+plot(raxml.tree)
+nodelabels(raxml.tree$node.label, adj = c(1, 0), frame = "none")
+##  MrBayes
+plot(mrbayes.tree)
+nodelabels(mrbayes.tree$node.label, adj = c(1, 0), frame = "none")
+
+par(mfrow=c(1,1)) # Setting plot parameters
+# NeighbourNet
+plot.networx(Nnet,"2D")
+## alternatively,
+# plot(Nnet,"2D")
+
+```
+
+### Interwining trees and network functions                         
+### 1A: 
+Identification of edge bundles (in black) in a neighbour-net (NN) network that correspond to branches (labelled 1-12) in a tree (a maximum likelihood tree, in this case). 
+
+```{r} 
+# create a vector of labels for the network corresponding to edges in the tree
+edge.lab <- createLabel(Nnet, raxml.tree, raxml.tree$edge[,2], "edge")
+# could be also 1:27 instead of raxml.tree$edge[,2]
+
+# Show the correspondingly labelled tree and network in R
+par(mfrow=c(1,2), mar=c(1,1,1,1))
+#plotBS(raxml.tree, rotate.tree = 180) 
+plot(raxml.tree, "u", rotate.tree = 180) 
+edgelabels(raxml.tree$edge[,2],col="blue", frame="none")
+
+# find edges that are in the network but not in the tree
+edge.col <- rep("black", nrow(Nnet$edge))
+edge.col[ is.na(edge.lab) ] <- "red"
+# or a simpler alternative...
+edge.col <- createLabel(Nnet, raxml.tree, "black", nomatch="red")
+
+x <- plot.networx(Nnet, edge.label = edge.lab, show.edge.label = T, "2D", edge.color = edge.col,
+                  col.edge.label = "blue")
+# the above plot function returns an invisible networx object and this object also  
+# contains the colors for the edges.
+
+```
+
+
+### 1B: 
+Bootstrap support for all branches (branch labels) in the ML tree mapped on the corresponding edge bundles of the NN network. The edges in the network which are not found as ML tree branches are highlighted in red.
+```{r}   
+x <- addConfidences(Nnet,raxml.tree)
+# find splits that are in the network but not in the tree
+split.col <- rep("black", length(x$splits))
+split.col[ !matchSplits(as.splits(x), as.splits(raxml.tree)) ] <- "red"
+
+# simpler alternative...
+split.col2 <- createLabel(x, raxml.tree, label="black", "split", nomatch="red")
+
+# Plotting in R
+par(mfrow=c(1,1))
+out.x <- plot.networx(x,"2D",show.edge.label=TRUE, split.color=split.col, col.edge.label = "blue")
+```
+Again we can write to SplitsTree for viewing...
+```{r}
+# write.nexus.networx(out.x,"woodmouse.tree.support.nxs")
+## or we can also export the splits alone (for usage in software other than SplitsTree)
+# write.nexus.splits(as.splits(out.x),"woodmouse.splits.support.nxs")
+```
+
+### 1C: 
+Frequencies of bipartitions found in the bootstrap pseudoreplicates mapped on the corresponding edge bundles of the NN network using a threshold of 10% (i.e. any edge is labelled that occurs in at least 
+100 of the 1000 ML-BS pseudoreplicates). Edge bundles not found in the ML tree are labelled using grey edges.
+
+```{r}
+y <- addConfidences(Nnet, as.splits(raxml.bootstrap))
+edge.col <- createLabel(y, raxml.tree, label="black", "edge", nomatch="grey")
+
+y <- plot(y,"2D",show.edge.label=TRUE, edge.color=edge.col)
+
+## Write to SplitsTree for viewing
+# write.nexus.networx(y,"NN.with.bs.support.nxs")
+```
+
+### Extras...
+We can also compare the neighborNet with a consensusNet (Holland BR, Huber KT, Moulton V, Lockhart PJ,2004, Using consensus networks to visualize contradictory evidence for species phylogeny. Molecular Biology and Evolution, 21, 1459-1461). Furthermore, we can extract the support values from the consensus network, and place these on to the NeighbourNet (this is similar to the process explained in 1C above).
+```{r}
+cnet <- consensusNet(raxml.bootstrap,prob=0.10)
+edge.col <- createLabel(cnet, Nnet, label="black", "edge", nomatch="grey")
+cnet <- plot.networx(cnet, "2D", show.edge.label = TRUE, edge.color=edge.col)
+
+edge.col <- createLabel(Nnet, cnet, label="black", "edge", nomatch="grey")
+z <- plot.networx(Nnet, "2D", show.edge.label = TRUE, edge.color=edge.col)
+
+obj <- addConfidences(Nnet,cnet)
+plot.networx(obj,"2D",show.edge.label=T, edge.color=edge.col, col.edge.label = "blue")
+
+## Write to SplitsTree for viewing
+# write.nexus.networx(obj,"Nnet.with.ML.Cnet.Bootstrap.nxs")
+```
diff --git a/vignettes/Networx.Rmd b/vignettes/Networx.Rmd
index 4086c5a..129ba78 100644
--- a/vignettes/Networx.Rmd
+++ b/vignettes/Networx.Rmd
@@ -11,10 +11,10 @@ vignette: >
 ---
 
 
-This tutorial gives a basic introduction on constructing phylogenetic networks and to add parameter to trees or networx using [phangorn](http://cran.r-project.org/package=phangorn) [@Schliep2011] in R. 
-Splits graph or phylogenetic networks are a nice way to display conflict data or summarize different trees. Here we present to popular networks, consensus networks [@Holland2004]
-and neighborNet [@Bryant2004].                                  
-Often trees or networks are missing either edge weights or support values about the edges. We show how to improve a tree/networx by adding support values or estimating edge weights using non-negative Least-Squares (nnls).
+This tutorial gives a basic introduction for constructing phylogenetic networks and adding parameters to trees or networx objects using [phangorn](http://cran.r-project.org/package=phangorn) [@Schliep2011] in R. 
+Splits graphs or phylogenetic networks are a useful way to display conflicting data or to summarize different trees. Here, we present two popular networks, consensus networks [@Holland2004]
+and Neighbor-Net [@Bryant2004].                                  
+Trees or networks are often missing either edge weights or edge support values. We show how to improve a tree/networx object by adding support values or estimating edge weights using non-negative Least-Squares (nnls).
 
 We first load the phangorn package and a few data sets we use in this vignette.
 ```{r, eval=TRUE}
@@ -23,21 +23,21 @@ data(Laurasiatherian)
 data(yeast)
 ```
 ## consensusNet
-A consensusNet [@Holland2004] is a generalization of a consensus tree. Instead only representing splits with at least 50% in a bootstrap or MCMC sample one can use a lower threshold. However of important competing splits are left out. 
+A consensusNet [@Holland2004] is a generalization of a consensus tree. Instead of only representing splits (taxon bipartitions) occurring in at least 50% of the trees in a bootstrap or MCMC sample one can use a lower threshold and explore competing splits. Note that, in its basic implementation used here, the consensusNet edge lengths are proportional to the frequence of the corresponding splits in the provided list of trees. 
 
-The input for `consensusNet` is  a list of trees i.e. an object of class `multiPhylo`.
+The input for `consensusNet` is a list of trees i.e. an object of class `multiPhylo`.
 ```{r, eval=TRUE}
 set.seed(1)
 bs <- bootstrap.phyDat(yeast, FUN = function(x)nj(dist.hamming(x)), 
     bs=100)
 tree <- nj(dist.hamming(yeast))
-par("mar" = rep(2, 4))
+par("mar" = rep(1, 4))
 tree <- plotBS(tree, bs, "phylogram")
 cnet <- consensusNet(bs, .3)
 plot(cnet, "2D", show.edge.label=TRUE)
 ```
 
-Often `consensusNet` will return incompatible splits, which cannot plotted as a planar graph. A nice way to  get still a good impression of the network is to plot it in 3 dimensions. 
+In many cases, `consensusNet` will return more than two incompatible (competing) splits. This cannot be plotted as a planar (2-dimensional) graph. Such as situation requires a n-dimensional graph, where the maximum number of dimensions equals the maximum number of incompatible splits. For example, if we have three alternative incompatible splits: (A,B)|(C,D) vs. (A,C)|(B,D) vs. (A,D)|(B,C), we need a 3-dimensional graph to show all three alternatives. A nice way to get still a good impre [...]
 
 ```{r, eval=FALSE}
 plot(cnet)
@@ -53,44 +53,50 @@ which will result in a spinning graph similar to this
 
 
 ## neighborNet
-The function `neighborNet` implements the popular method of @Bryant2004. The  Neighbor-Net algorithm extends the Neighbor joining allowing again algorithm is computed in 2 parts, the first computes a circular ordering. The second step involves estimation of edge weights using non-negative Least-Squares (nnls).    
+The function `neighborNet` implements the popular method of @Bryant2004. The Neighbor-Net algorithm is essentially a 2D-version of the Neighbor joining algorithm. The Neighbour-net is computed in two steps: the first computes a circular ordering of the taxa in the data set; the second step involves the estimation of edge weights using non-negative Least-Squares (nnls).    
 
 ```{r, eval=TRUE}
 dm <- dist.hamming(yeast)
 nnet <- neighborNet(dm)
-par("mar" = rep(2, 4))
+par("mar" = rep(1, 4))
 plot(nnet, "2D")
 ```
 
-The advantage of Neighbor-Net is that it returns a circular split system which can be always displayed in a planar (2D) graph. The plots displayed in `phangorn` may not planar, but re-plotting may gives you a planar graph. This unwanted behavior will be improved in future version. 
+The advantage of Neighbor-Net is that it returns a circular split system which can be always displayed in a planar (2D) graph. The plots displayed in `phangorn` may (however) not be planar, but re-plotting can give you a planar graph. This unwanted behavior will be improved in future version. 
 The rendering of the `networx` is done using the the fantastic igraph package [@Csardi2006]. 
 
 
 ## Adding support values
 
-We can use the generic function `addConfidences` to add support values from a tree, i.e. an object of class `phylo` to a `networx`, `splits` or `phylo` object. The Neighbor-Net object we computed above contains no support values. We can add the support values fro  the tree we computed to the splits these two objects share. 
+We can use the generic function `addConfidences` to add (branch) support values from a tree, i.e. an object of class `phylo` to a `networx`, `splits` or `phylo` object. The Neighbor-Net object we computed above provides no support values. We can add the support values from the tree we computed to the splits (edges) shared by both objects. 
 ```{r, eval=TRUE}
 nnet <- addConfidences(nnet, tree)
-par("mar" = rep(2, 4))
+par("mar" = rep(1, 4))
 plot(nnet, "2D", show.edge.label=TRUE)
 ```    
 
-We can also add support values to a tree:
+Analogously, we can also add support values to a tree:
 ```{r, eval=TRUE}
 tree2 <- rNNI(tree, 2)
 tree2 <- addConfidences(tree2, tree)
 # several support values are missing
+par("mar" = rep(1, 4))
 plot(tree2, show.node.label=TRUE)
 ```   
 
 ## Estimating edge weights (nnls)
 
-Consensus networks on the other hand have information about support values corresponding to a split, but are generally without edge weights. 
-Given a distance matrix we can estimate edge weights using non-negative Least-Squares. 
+Consensus networks, on the other hand, provide primarily information about support values corresponding to a split, but no information about the actual difference between the taxon bipartitions defined by that split. For example, one may be interested how the alternative support values correspond with the actual genetic distance between the involved taxa.
+Given a distance matrix, we can estimate edge weights using non-negative Least-Squares, and plot them onto the consensusNet splits graph. 
 ```{r, eval=TRUE}
 cnet <- nnls.networx(cnet, dm)
-par("mar" = rep(2, 4))
+par("mar" = rep(1, 4))
 plot(cnet, "2D", show.edge.label=TRUE)
 ```
     
+    
+### Import and export networks, advanced functions for networx objects 
+
+The functions `read.nexus.networx` and `write.nexus.networx` can read and write nexus files for or from SplitsTree [@Huson2006]. Check-out the new vignette IntertwiningTreesAndNetworks for additional functions, examples, and advanced applications. 
+
 ## References
diff --git a/vignettes/Trees.RData b/vignettes/Trees.RData
index 59a91ab..fa09b11 100644
Binary files a/vignettes/Trees.RData and b/vignettes/Trees.RData differ
diff --git a/vignettes/Trees.Rnw b/vignettes/Trees.Rnw
index 8fba8fb..a77f5d4 100644
--- a/vignettes/Trees.Rnw
+++ b/vignettes/Trees.Rnw
@@ -9,6 +9,7 @@
 
 
 \begin{document}
+\SweaveOpts{concordance=TRUE}
 
 \newcommand{\Rfunction}[1]{{\texttt{#1}}}
 \newcommand{\Robject}[1]{{\texttt{#1}}}
@@ -48,6 +49,7 @@
 <<echo=FALSE>>=
 options(width=70)
 foo <- packageDescription("phangorn")
+options("show.signif.stars" = FALSE)
 @
 
 
@@ -58,35 +60,35 @@ foo <- packageDescription("phangorn")
 \nocite{Paradis2012}
 \section{Introduction}
 
-These notes should enable the user to estimate phylogenetic trees from alignment data with different methods using the \phangorn{} package \cite{Schliep2011}. Several functions of \phangorn{} are also described in more detail in \cite{Paradis2012}. For more theoretical background on all the methods see e.g. \cite{Felsenstein2004, Yang2006}. This document illustrates some of the \phangorn{} features to estimate phylogenetic trees using different reconstruction methods. Small adaptations t [...]
+These notes should enable the user to estimate phylogenetic trees from alignment data with different methods using the \phangorn{} package \cite{Schliep2011}. Several functions of \phangorn{} are also described in more detail in \cite{Paradis2012}. For more theoretical background on all the methods see e.g. \cite{Felsenstein2004, Yang2006}. This document illustrates some of the \phangorn{} features to estimate phylogenetic trees using different reconstruction methods. Small adaptations t [...]
 \section{Getting started}
 The first thing we have to do is to read in an alignment. Unfortunately there exists many different file formats that alignments can be stored in. The function \Rfunction{read.phyDat} is used to  read in an alignment. There are several functions to read in alignments depending on the format of the data set (nexus, phylip, fasta) and the kind of data (amino acid or nucleotides) in the \ape{} package \cite{Paradis2004} and \phangorn{}. The function \Rfunction{read.phyDat} calls these other [...]
 %When using the \Rfunction{read.dna} from \ape{} the parameter the we have to use as.character=TRUE.  
 We start our analysis loading the \phangorn{} package and then reading in an alignment.  
 <<echo=TRUE>>=
 library(phangorn)
-primates = read.phyDat("primates.dna", format="phylip", type="DNA")
+primates <- read.phyDat("primates.dna", format="phylip", 
+    type="DNA")
 @
-%require("multicore")
 \section{Distance based methods}
-After reading in the alignment we can build a first tree with distance based methods. The function dist.dna from the ape package computes distances for many DNA substitution models. To use the function dist.dna we have to transform the data to class DNAbin. For amino acids the function dist.ml offers common substitution models ("WAG", "JTT", "LG", "Dayhoff", "cpREV", "mtmam", "mtArt", "MtZoa" and "mtREV24").  
+After reading in the alignment we can build a first tree with distance based methods. The function dist.dna from the ape package computes distances for many DNA substitution models. To use the function dist.dna we have to transform the data to class DNAbin. For amino acids the function \Rfunction{dist.ml} offers common substitution models (for example "WAG", "JTT", "LG", "Dayhoff", "cpREV", "mtmam", "mtArt", "MtZoa" or "mtREV24").  
  
-After constructing a distance matrix we reconstruct a rooted tree with UPGMA and alternatively an unrooted tree using Neighbor Joining \cite{Saitou1987,Studier1988}. 
+After constructing a distance matrix we reconstruct a rooted tree with UPGMA and alternatively an unrooted tree using Neighbor Joining \cite{Saitou1987,Studier1988}. More distance methods like fastme are available in the \Rpackage{ape} package.
 <<echo=TRUE>>=
-dm = dist.ml(primates)
-treeUPGMA = upgma(dm)
-treeNJ = NJ(dm)
+dm  <- dist.ml(primates)
+treeUPGMA  <- upgma(dm)
+treeNJ  <- NJ(dm)
 @
 We can plot the trees treeUPGMA and treeNJ (figure \ref{fig:NJ}) with the commands:
 <<label=plotNJ,include=FALSE>>=
 layout(matrix(c(1,2), 2, 1), height=c(1,2))
-par(mar = c(.1,.1,.1,.1))
+par(mar = c(0,0,2,0)+ 0.1)
 plot(treeUPGMA, main="UPGMA")
 plot(treeNJ, "unrooted", main="NJ")
 @
 \begin{figure}
 \begin{center}
-<<label=figNJ,fig=TRUE,echo=FALSE>>=
+<<label=figNJ,fig=TRUE,echo=FALSE, height=8>>=
 <<plotNJ>>
 @
 \end{center}
@@ -101,10 +103,10 @@ The function parsimony returns the parsimony score, that is the number of change
 parsimony(treeUPGMA, primates)
 parsimony(treeNJ, primates)
 @
-The function optim.parsimony performs tree rearrangements to find trees with a lower parsimony score. So far the only tree rearrangement implemented is nearest-neighbor interchanges (NNI). However is also a version of the parsimony ratchet \cite{Nixon1999} implemented, which is likely to find better trees than just doing NNI rearrangements. 
+The function optim.parsimony performs tree rearrangements to find trees with a lower parsimony score. The tree rearrangement implemented are  nearest-neighbor interchanges (NNI) and subtree pruning and regrafting (SPR). The later one only works so far with the fitch algorithm. However is also a version of the parsimony ratchet \cite{Nixon1999} implemented, which is likely to find better trees than just doing NNI / SPR rearrangements. 
 <<echo=TRUE>>=
-treePars = optim.parsimony(treeUPGMA, primates)
-treeRatchet = pratchet(primates, trace = 0)
+treePars  <- optim.parsimony(treeUPGMA, primates)
+treeRatchet  <- pratchet(primates, trace = 0)
 parsimony(c(treePars, treeRatchet), primates)
 @
 For small data sets it is also possible to find all most parsimonious trees using a branch and bound algorithm \cite{Hendy1982}. For data sets with more than 10 taxa this can take a long time and depends strongly on how tree like the data are.  
@@ -119,47 +121,58 @@ We can easily compute the likelihood for a tree given the data
 fit = pml(treeNJ, data=primates)
 fit
 @
-The function pml returns an object of class pml. This object contains the data, the tree and many different parameters of the model like the likelihood etc. There are many generic functions for the class pml available, which allow the handling of these objects.
+The function \Rfunction{pml} returns an object of class \Robject{pml}. This object contains the data, the tree and many different parameters of the model like the likelihood. There are many generic functions for the class Robject{pml} available, which allow the handling of these objects.
 <<echo=TRUE>>=
 methods(class="pml")
 @ 
-The object fit just estimated the likelihood for the tree it got supplied, but the branch length are not optimized for the Jukes-Cantor model yet, which can be done with the function optim.pml. 
+The object fit just estimated the likelihood for the tree it got supplied, but the branch length are not optimized for the Jukes-Cantor model yet, which can be done with the function \Rfunction{optim.pml}. 
 <<echo=TRUE, results=hide>>=
-fitJC = optim.pml(fit, TRUE)
+fitJC  <- optim.pml(fit, TRUE)
 logLik(fitJC)
 @
 With the default values \Rfunction{pml} will estimate a Jukes-Cantor model. The function \Rfunction{update.pml} allows to change parameters. We will change the model to the GTR + $\Gamma(4)$ + I model and then optimize all the parameters. 
 <<echo=TRUE>>=
-fitGTR = update(fit, k=4, inv=0.2) 
-fitGTR = optim.pml(fitGTR, TRUE,TRUE, TRUE, TRUE, TRUE, 
-    control = pml.control(trace = 0))
+fitGTR <- update(fit, k=4, inv=0.2) 
+fitGTR <- optim.pml(fitGTR, model="GTR", optInv=TRUE, optGamma=TRUE, 
+    rearrangement = "NNI", control = pml.control(trace = 0))
 fitGTR 
 @
-We can compare the objects for the JC and GTR + $\Gamma(4)$ + I model using likelihood ratio statistic
+With the control parameters the threshols for the fitting process can be changed. Here we want just to supress output during the fitting process. For larger trees the NNI rearrangements often get stuck in local maxima. We added two stochatic algorithm to improve topology search. The first (set rearrangement="stochastic") performs stochastic rearrangements similar as in \cite{Nguyen2015}, which makes random NNI permuation to the tree, which than gets optimised to escape local optima. The  [...]
+
+While these algorithms may find better trees they will also take more time.      
 <<echo=TRUE>>=
-anova(fitJC, fitGTR) 
+fitGTR <- optim.pml(fitGTR, model="GTR", optInv=TRUE, optGamma=TRUE, 
+    rearrangement = "stochastic", control = pml.control(trace = 0))
+fitGTR 
 @
-with the AIC
+\subsection{Model selection}
+We can compare nested models for the JC and GTR + $\Gamma(4)$ + I model using likelihood ratio statistic
 <<echo=TRUE>>=
-AIC(fitGTR) 
-AIC(fitJC)
+anova(fitJC, fitGTR) 
 @
-or the Shimodaira-Hasegawa test.
+with the Shimodaira-Hasegawa \cite{Shimodaira1999} test
 <<echo=TRUE>>=
 SH.test(fitGTR, fitJC) 
 @
-An alternative is to use the function \Rfunction{modelTest}  to compare different models the AIC or BIC, similar to popular program of \cite{Posada1998, Posada2008}.  
+or with the AIC
+<<echo=TRUE>>=
+AIC(fitJC)
+AIC(fitGTR) 
+AICc(fitGTR) 
+BIC(fitGTR) 
+@
+An alternative is to use the function \Rfunction{modelTest}  to compare different nucleotide or protein models the AIC, AICc or BIC, similar to popular programs ModelTest and ProtTest \cite{Posada1998, Posada2008, Abascal2005}.  
 <<echo=FALSE>>=
 load("Trees.RData")
 @
 <<echo=TRUE, eval=FALSE>>=
 mt = modelTest(primates)
 @
-The results of is illustrated in table \ref{tab:modelTest}
+The results of \Rfunction{modelTest} is illustrated in table \ref{tab:modelTest}
 \begin{center}
 <<echo=FALSE,results=tex>>=
 library(xtable)
-xtable(mt, caption="Summary table of modelTest", label="tab:modelTest")
+print(xtable(mt, caption="Summary table of modelTest", label="tab:modelTest"), include.rownames=FALSE)
 @
 \end{center}
 The thresholds for the optimization in  \Rfunction{modelTest} are not as strict as for \Rfunction{optim.pml} and no tree rearrangements are performed. As \Rfunction{modelTest} computes and optimizes a lot of models it would be a waste of computer time not to save these results. The results are saved as call together with the optimized trees in an environment and this call can be evaluated to get a "pml" object back to use for further optimization or analysis.
@@ -168,7 +181,6 @@ env <- attr(mt, "env")
 ls(envir=env)
 (fit <- eval(get("HKY+G+I", env), env))
 @
-
 At last we may want to apply bootstrap to test how well the edges of the tree are supported: %, results=hide
 <<echo=TRUE, eval=FALSE>>=
 bs = bootstrap.pml(fitJC, bs=100, optNni=TRUE, 
@@ -176,74 +188,100 @@ bs = bootstrap.pml(fitJC, bs=100, optNni=TRUE,
 @
    
 %$
-Now we can plot the tree with the bootstrap support values on the edges
+Now we can plot the tree with the bootstrap support values on the edges and also look at consensusNet to identify potential conflict. 
 <<label=plotBS,include=FALSE>>=
-par(mar=c(.1,.1,.1,.1))
-plotBS(fitJC$tree, bs)
+par(mfrow=c(2,1))
+par(mar=c(1,1,3,1))
+plotBS(midpoint(fitJC$tree), bs, p = 50, type="p")
+title("a)")
+cnet <- consensusNet(bs, p=0.2)
+plot(cnet, "2D", show.edge.label=TRUE)
+title("b)")
 @
 %$
 \begin{figure}
 \begin{center}
-<<label=figBS,fig=TRUE,echo=FALSE>>=
+<<label=figBS,fig=TRUE,echo=FALSE, height=9>>=
 <<plotBS>>
 @
 \end{center}
-\caption{Unrooted tree with bootstrap support values}
+\caption{a) Unrooted tree (midpoint rooted) with bootstrap support values. b) ConsensusNet from the bootstrap sample}
 \label{fig:BS}
 \end{figure}
 
 Several analyses, e.g. \Rfunction{bootstrap} and  \Rfunction{modelTest}, can be computationally demanding, but as nowadays most computers have several cores one can distribute the computations using the  \multicore{} package. However it is only possible to use this approach if R is running from command line ("X11"), but not using  a GUI (for example "Aqua" on Macs) and unfortunately the \multicore{} package does not work at all under Windows. 
-\section{Appendix: Standard scripts for nucleotide or amino acid analysis}\label{sec:Appendix}
+
+\newpage
+\section{Appendix: Standard scripts for nucleotide analysis}\label{sec:Appendix1}
 Here we provide two standard scripts which can be adapted for the most common tasks. 
-Most likely the arguments for \Rfunction{read.phyDat} have to be adapted to accommodate your file format. Both scripts assume that the \multicore{} package, see comments above. 
+Most likely the arguments for \Rfunction{read.phyDat} have to be adapted to accommodate your file format. Both scripts assume that the \multicore{} package works on your platform, see comments above. 
 <<echo=FALSE>>=
 options(prompt=" ")
 options(continue="  ")
 @
 <<eval=FALSE>>=
-library(parallel) # supports parallel computing
 library(phangorn)
 file="myfile"
 dat = read.phyDat(file)
-dm = dist.ml(dat)
+dm = dist.ml(dat, "F81")
 tree = NJ(dm)
 # as alternative for a starting tree:
-tree <- pratchet(dat) 
+tree <- pratchet(dat)          # parsimony tree 
+tree <- nnls.phylo(tree, dm)   # need edge weights
+
 
-# 1. alternative: estimate an GTR model
-fitStart = pml(tree, dat, k=4, inv=.2)
-fit = optim.pml(fitStart, TRUE, TRUE, TRUE, TRUE, TRUE) 
+# 1. alternative: quick and dirty: GTR + G 
+fitStart = pml(tree, dat, k=4)
+fit = optim.pml(fitStart, model="GTR", optGamma=TRUE, rearrangement="stochastic") 
  
-# 2. alternative: modelTest  
-(mt <- modelTest(dat, multicore=TRUE)) 
-mt$Model[which.min(mt$BIC)]
-# choose best model from the table, assume now GTR+G+I
+# 2. alternative: preper with modelTest  
+mt <- modelTest(dat, tree=tree, multicore=TRUE)
+mt[order(mt$AICc),]
+# choose best model from the table according to AICc
+bestmodel <- mt$Model[which.min(mt$AICc)]
+
 env = attr(mt, "env")
 fitStart = eval(get("GTR+G+I", env), env) 
-fitStart = eval(get(mt$Model[which.min(mt$BIC)], env), env) 
-fit = optim.pml(fitStart, optNni=TRUE, optGamma=TRUE, optInv=TRUE, 
-    model="GTR")
+
+# or let R search the table
+fitStart = eval(get(bestmodel, env), env) 
+# equivalent to:   fitStart = eval(get("GTR+G+I", env), env) 
+fit = optim.pml(fitStart, rearrangement = "stochastic", 
+    optGamma=TRUE, optInv=TRUE, model="GTR")
 bs = bootstrap.pml(fit, bs=100, optNni=TRUE, multicore=TRUE)
 @
 
-You can specify different several models build in which you can specify, e.g. "WAG", "JTT", "Dayhoff", "LG". Optimizing the rate matrix for amino acids is possible, but would take a long, a very long time. So make sure to set optBf=FALSE and optQ=FALSE in the function \Rfunction{optim.pml}, which is also the default.
+\newpage
+\section{Appendix 2: Standard scripts for amino acid analysis}%\label{sec:Appendix2}
+You can specify different several models build in which you can specify, e.g. "WAG", "JTT", "Dayhoff", "LG". Optimizing the rate matrix for amino acids is possible, but would take a long, a very long time and you will need to have a large alignement to estimate all the parameters. So make sure to set optBf=FALSE and optQ=FALSE in the function \Rfunction{optim.pml}, which is also the default.
 <<eval=FALSE>>=
-library(parallel) # supports parallel computing
 library(phangorn)
 file="myfile"
 dat = read.phyDat(file, type = "AA")
 dm = dist.ml(dat, model="JTT")
 tree = NJ(dm)
 
-(mt <- modelTest(dat, model=c("JTT", "LG", "WAG"), multicore=TRUE)) 
+# parallel will only work safely from command line 
+# and not at all windows
+(mt <- modelTest(dat, model=c("JTT", "LG", "WAG"), 
+    multicore=TRUE)) 
+# run all available amino acid models
+(mt <- modelTest(dat, model="all", multicore=TRUE))
+
 fitStart = eval(get(mt$Model[which.min(mt$BIC)], env), env) 
 
 fitNJ = pml(tree, dat, model="JTT", k=4, inv=.2)
-fit = optim.pml(fitNJ, optNni=TRUE, optInv=TRUE, optGamma=TRUE)
+fit = optim.pml(fitNJ, rearrangement = "stochastic", 
+    optInv=TRUE, optGamma=TRUE)
 fit
+
 bs = bootstrap.pml(fit, bs=100, optNni=TRUE, multicore=TRUE)
 @
 
+\newpage
+
+% \cite{Sugiura1978}
+
 \bibliographystyle{plain}
 \bibliography{phangorn}
 
diff --git a/vignettes/phangorn-specials.Rnw b/vignettes/phangorn-specials.Rnw
index 9d33093..53b99b4 100644
--- a/vignettes/phangorn-specials.Rnw
+++ b/vignettes/phangorn-specials.Rnw
@@ -8,6 +8,7 @@
 % tools::texi2dvi("phangorn-specials.tex", pdf=TRUE)
 \usepackage{times}
 \usepackage{hyperref}
+\usepackage{amsmath}
 
 \newcommand{\Rfunction}[1]{{\texttt{#1}}}
 \newcommand{\Robject}[1]{{\texttt{#1}}}
@@ -35,6 +36,7 @@
 
 
 \begin{document}
+\SweaveOpts{concordance=TRUE}
 
 % Ross Ihakas extenstion for nicer representation 
 \DefineVerbatimEnvironment{Sinput}{Verbatim} {xleftmargin=2em}
@@ -45,6 +47,7 @@
 
 <<echo=FALSE>>=
 options(width=70)
+options("show.signif.stars" = FALSE)
 foo <- packageDescription("phangorn")
 @
 
@@ -110,6 +113,30 @@ Here we defined "n" as a state which can be any nucleotide but not a gap "-" and
 These data can be used in all functions available in \phangorn{} to compute distance matrices or perform parsimony and maximum likelihood analysis.  
 
 
+\section{Markov models of character evolution}
+To model nucleotide substitutions across the edges of a tree T we can assign a transition matrix. In the case of nucleotides, with four character states, each 4 $\times$ 4 transition matrix has, at most, 12 free parameters.
+
+Time-reversible Markov models are used to describe how characters change over time, and use fewer parameters. Time-reversible means that these models need not be directed in time, and the Markov property states that these models depend only on the current state. These models are used in analysis of phylogenies using maximum likelihood and MCMC, computing pairwise distances, as well in simulating sequence evolution.
+
+We will now describe the General Time-Reversible (GTR) model \cite{Tavare1986}. The parameters
+of the GTR model are the equilibrium frequencies $\pi = (\pi_A ,\pi_C ,\pi_G ,\pi_T)$ and a rate
+matrix $Q$ which has the form
+\begin{equation}\label{eq:GTR}
+Q = 
+\begin{pmatrix}
+\ast  & \alpha\pi_C & \beta\pi_G & \gamma\pi_T \\
+\alpha\pi_A & \ast & \delta\pi_G & \epsilon\pi_T \\
+\beta\pi_A & \delta\pi_C & \ast & \eta\pi_T \\
+\gamma\pi_A &  \epsilon\pi_C & \eta\pi_G & \ast \\
+\end{pmatrix}
+\end{equation}
+where we need to assign 6 paramters $\alpha, \dots, \eta$. The elements on the diagonal are chosen so that the rows sum to zero. The Jukes-Cantor (JC) \cite{Jukes1969} model can be derived as special case from the GTR model, for equal equilibrium frequencies $\pi_A = \pi_C = \pi_G = \pi_T = 0.25$ and equal rates set to $\alpha = \beta = \gamma = \delta = \eta$. Table \ref{models} lists all built-in nucleotide models in \phangorn. 
+The transition probabilities which describe the probabilities of change from character $i$ to $j$ in time $t$, are given by the corresponding entries of the matrix exponential
+\[
+P(t) = (p_{ij}(t)) = e^{Qt}, \qquad \sum_j p_{ij}=1
+\]
+where $P(t)$ is the transition matrix spanning a period of time $t$.
+
 \section{Estimation of non-standard transition rate matrices}
 In the last section \ref{sec:USER} we described how to set up user defined data formats. Now we describe how to estimate transition matrices with pml. 
 
@@ -132,8 +159,9 @@ We will now show how to estimate a rate matrix with different transition ($\alph
    \caption{Rate matrix K to optimise. }\label{gaps} 
 \end{table}
 
-
-The parameters subs accepts a vector of consecutive integers and at least one element has to be zero (these gets the reference rate of 1).
+If we want to fit a non-standard transition rate matrices, we have to tell \Rfunction{optim.pml}, which transitions in Q get the same rate. 
+The parameter vector subs accepts a vector of consecutive integers and at least one element has to be zero (these gets the reference rate of 1).
+Negative values indicate that there is no direct transition is possible and the rate is set to zero. 
 <<>>=
 tree = unroot(rtree(3))
 fit = pml(tree, gapsdata3)
@@ -180,11 +208,11 @@ If optQ=TRUE and neither a model or subs are supplied than a symmetric (optBf=FA
          GTR & TRUE & TRUE & $c(1, 2, 3, 4, 5, 0)$ & 8 \\
          \hline
    \end{tabular}
-   \caption{DNA models available in phangorn, how they are defined and number of parameters to estimate. }\label{models} 
+   \caption{DNA models available in phangorn, how they are defined and number of parameters to estimate. The elements of the vector subs correspond to $\alpha, \dots, \eta$ in equation (\ref{eq:GTR})}\label{models} 
 \end{table}
 
 \section{Codon substitution models}
-A special case of the transition rates are codon models. \phangorn{} now offers the possibility to estimate the $d_N/d_S$ ratio (sometimes called ka/ks), for an overview see \cite{Yang2006}. These functions extend the option to estimates the $d_N/d_S$ ratio for pairwise sequence comparison as it is available through the function \Rfunction{kaks} in \Rpackage{seqinr}. The transition rate between between codon $i$ and $j$ is defined as follows:
+A special case of the transition rates are codon models. \phangorn{} now offers the possibility to estimate the $d_N/d_S$ ratio (sometimes called ka/ks), for an overview see \cite{Yang2014}. These functions extend the option to estimates the $d_N/d_S$ ratio for pairwise sequence comparison as it is available through the function \Rfunction{kaks} in \Rpackage{seqinr}. The transition rate between between codon $i$ and $j$ is defined as follows:
 \begin{eqnarray}
 q_{ij}=\left\{ 
     \begin{array}{l@{\quad}l}
@@ -215,6 +243,7 @@ fit3 <- optim.pml(fit, model="codon3", control=pml.control(trace=0))
 anova(fit0, fit2, fit3, fit1)
 @
 The models described here all assume equal frequencies for each codon (=1/61). One can optimise the codon frequencies setting the option to optBf=TRUE. As the convergence of the 61 parameters the convergence is likely slow set the maximal iterations to a higher value than the default (e.g. control = pml.control(maxit=50)).  
+The "YN98" model \cite{Yang98} is similar to the "codon1", but addional optimises the codon frequencies.   
 
 \section{Generating trees}
 \phangorn{} has several functions to generate tree topologies, which may are interesting for simulation studies. \Rfunction{allTrees} computes all possible bifurcating tree topologies either rooted or unrooted for up to 10 taxa. One has to keep in mind that the number of trees is growing exponentially, use \Rfunction(howmanytrees) from \ape{} as a reminder. 
diff --git a/vignettes/phangorn.bib b/vignettes/phangorn.bib
index c6167e3..2e6c227 100644
--- a/vignettes/phangorn.bib
+++ b/vignettes/phangorn.bib
@@ -1,3 +1,115 @@
+ at article{Abascal2005,
+    author = {Abascal, Federico and Zardoya, Rafael and Posada, David}, 
+    title = {ProtTest: selection of best-fit models of protein evolution},
+    volume = {21}, 
+    number = {9}, 
+    pages = {2104-2105}, 
+    year = {2005}, 
+    doi = {10.1093/bioinformatics/bti263}, 
+    URL = {http://bioinformatics.oxfordjournals.org/content/21/9/2104.abstract}, 
+    eprint = {http://bioinformatics.oxfordjournals.org/content/21/9/2104.full.pdf+html}, 
+    journal = {Bioinformatics} 
+}
+
+
+ at article{Schwarz1978,
+    author = "Schwarz, Gideon",
+    doi = "10.1214/aos/1176344136",
+    fjournal = "The Annals of Statistics",
+    journal = "Ann. Statist.",
+    month = "03",
+    number = "2",
+    pages = "461--464",
+    publisher = "The Institute of Mathematical Statistics",
+    title = "Estimating the Dimension of a Model",
+    url = "http://dx.doi.org/10.1214/aos/1176344136",
+    volume = "6",
+    year = "1978"
+}
+
+ at incollection{Jukes1969,
+    title = "\{CHAPTER\} 24 - Evolution of Protein Molecules ",
+    editor = "Munro, H.N. ",
+    booktitle = "Mammalian Protein Metabolism",
+    publisher = "Academic Press",
+    year = "1969",
+    pages = "21--132",
+    author = "Thomas H. Jukes and Charles R. Cantor"
+}
+
+ at Article{Tavare1986,
+    author = {Tavar\'{e}, Simon},
+    title = {Some probabilistic and statistical problems in the analysis of DNA sequences}, 
+    journal= {Lectures on Mathematics in the Life Sciences}, 
+    number = {17}, 
+    pages = {57--86}, 
+    year = {1986},
+    publisher = {American Mathematical Society} 
+}
+
+ at Article{Sugiura1978,
+  Title                    = {{Further analysts of the data by akaike' s information criterion and the finite corrections}},
+  Author                   = {Sugiura, Nariaki},
+  Journal                  = {Communications in Statistics - Theory and Methods},
+  Year                     = {1978},
+  Month                    = jan,
+  Number                   = {1},
+  Pages                    = {13--26},
+  Volume                   = {7},
+  Keywords                 = {aic, criteria, model, selection},
+  Url                      = {http://dx.doi.org/10.1080/03610927808827599}
+}
+
+
+ at article{Knuth1984,
+  title={Literate programming},
+  author={Knuth, Donald E.},
+  journal={The Computer Journal},
+  volume={27},
+  number={2},
+  pages={97--111},
+  year={1984},
+  publisher={British Computer Society}
+}
+
+
+ at article{Buckheit1995,
+  title={WaveLab and Reproducible Research},
+  author={Buckheit, J.B. and Donoho, D.L.},
+  journal={Wavelets and statistics},
+  volume={103},
+  pages={55},
+  year={1995},
+  publisher={Springer Verlag}
+}
+
+
+ at Manual{rmarkdown,
+    title = {rmarkdown: Dynamic Documents for R},
+    author = {JJ Allaire and Joe Cheng and Yihui Xie and Jonathan McPherson and Winston Chang and Jeff Allen and Hadley Wickham and Aron Atkins and Rob Hyndman},
+    year = {2015},
+    note = {R package version 0.8},
+    url = {http://CRAN.R-project.org/package=rmarkdown},
+}
+  
+
+ at Manual{phyloch,
+    title = {PHYLOCH: R language tree plotting tools and interfaces to diverse phylogenetic software packages.},
+    author = {C. Heibl},
+    year = {2008 onwards},
+    url = {http://www.christophheibl.de/Rpackages.html},
+}
+
+
+ at Manual{ips,
+    title = {Interfaces to Phylogenetic Software in R},
+    author = {C. Heibl},
+    year = {2015},
+    url = {http://www.christophheibl.de/Rpackages.html},
+    note = {R package version 0.0-7},
+}
+
+
 @Manual{CRAN,
     title = {R: A Language and Environment for Statistical Computing},
     author = {{R Core Team}},
@@ -7,6 +119,16 @@
     url = {http://www.R-project.org/},
 }
 
+
+ at Manual{Biostrings,
+    title = {Biostrings: String objects representing biological sequences, and matching
+algorithms},
+    author = {H. Pages and P. Aboyoun and R. Gentleman and S. DebRoy},
+    year = {2015},
+    note = {R package version 2.36.4},
+}
+
+
 @Manual{Matrix,
     title = {Matrix: Sparse and Dense Matrix Classes and Methods},
     author = {Douglas Bates and Martin Maechler},
@@ -111,6 +233,20 @@
     journal = {Systematic Biology} 
 }
 
+
+ at article{Kuhner1994,
+author = {Kuhner, M K and Felsenstein, J}, 
+title = {A simulation comparison of phylogeny algorithms under equal and unequal evolutionary rates.},
+volume = {11}, 
+number = {3}, 
+pages = {459-468}, 
+year = {1994}, 
+URL = {http://mbe.oxfordjournals.org/content/11/3/459.abstract}, 
+eprint = {http://mbe.oxfordjournals.org/content/11/3/459.full.pdf+html}, 
+journal = {Molecular Biology and Evolution} 
+}
+
+
 @article{Lento1995,
     author = {Lento, G M and Hickson, R E and Chambers, G K and Penny, D}, 
     title = {Use of spectral analysis to test hypotheses on the origin of pinnipeds.},
@@ -124,6 +260,18 @@
     journal = {Molecular Biology and Evolution} 
 }
 
+
+ at article{Leaché2015,
+    author = {Leaché, Adam D. and Banbury, Barbara L. and Felsenstein, Joseph and Nieto-Montes de Oca, Adrián and Stamatakis, Alexandros}, 
+    title = {Short Tree, Long Tree, Right Tree, Wrong Tree: New Acquisition Bias Corrections for Inferring SNP Phylogenies},
+    year = {2015}, 
+    doi = {10.1093/sysbio/syv053}, 
+    URL = {http://sysbio.oxfordjournals.org/content/64/6/1032.abstract}, 
+    eprint = {http://sysbio.oxfordjournals.org/content/64/6/1032.full.pdf+html}, 
+    journal = {Systematic Biology} 
+}
+
+
 @article{Lewis2001,
     author = {Lewis, Paul O.}, 
     title = {A Likelihood Approach to Estimating Phylogeny from Discrete Morphological Character Data},
@@ -137,6 +285,22 @@
     journal = {Systematic Biology} 
 }
 
+
+ at article{Potts2014,
+    author = {Potts, Alastair J. and Hedderson, Terry A. and Grimm, Guido W.}, 
+    title = {Constructing Phylogenies in the Presence Of Intra-Individual Site Polymorphisms (2ISPs) with a Focus on the Nuclear Ribosomal Cistron},
+    volume = {63}, 
+    number = {1}, 
+    pages = {1-16}, 
+    year = {2014}, 
+    doi = {10.1093/sysbio/syt052}, 
+    URL = {http://sysbio.oxfordjournals.org/content/63/1/1.abstract}, 
+    eprint = {http://sysbio.oxfordjournals.org/content/63/1/1.full.pdf+html}, 
+    journal = {Systematic Biology} 
+}
+
+
+
 @Article{ Rambaut1997,
 	Author = "A. Rambaut and N.C. Grassly",
 	Title = "Seq-Gen: an application for the Monte Carlo simulation of DNA sequence evolution along phylogenetic trees",
@@ -171,6 +335,36 @@
     Url                      = {http://dx.doi.org/10.1111/2041-210X.12233}
 }
 
+
+ at InBook{Robinson1979,
+  Title                    = {Combinatorial Mathematics VI: Proceedings of the Sixth Australian Conference on Combinatorial Mathematics, Armidale, Australia, August 1978},
+  Author                   = {Robinson, D. F. and Foulds, L. R.},
+  Chapter                  = {Comparison of weighted labelled trees},
+  Editor                   = {Horadam, A. F. and Wallis, W. D.},
+  Pages                    = {119--126},
+  Publisher                = {Springer Berlin Heidelberg},
+  Year                     = {1979},
+  Address                  = {Berlin, Heidelberg},
+  Doi                      = {10.1007/BFb0102690},
+  ISBN                     = {978-3-540-34857-3},
+  Url                      = {http://dx.doi.org/10.1007/BFb0102690}
+}
+
+
+ at article{Robinson1981,
+author = "D.F. Robinson and L.R. Foulds",
+title = "Comparison of phylogenetic trees",
+journal = "Mathematical Biosciences",
+volume = "53",
+number = "1",
+pages = "131 - 147",
+year = "1981",
+note = "",
+issn = "0025-5564",
+doi = "http://dx.doi.org/10.1016/0025-5564(81)90043-2",
+url = "http://www.sciencedirect.com/science/article/pii/0025556481900432",
+}
+
 @article{Holland2004,
     author = {Holland, Barbara R. and Huber, Katharina T. and Moulton, Vincent and Lockhart, Peter J.}, 
     title = {Using Consensus Networks to Visualize Contradictory Evidence for Species Phylogeny},
@@ -218,6 +412,22 @@
 	Year = "2007"
 }
 
+
+ at article{Nguyen2015,
+author = {Nguyen, Lam-Tung and Schmidt, Heiko A. and von Haeseler, Arndt and Minh, Bui Quang}, 
+title = {IQ-TREE: A Fast and Effective Stochastic Algorithm for Estimating Maximum-Likelihood Phylogenies},
+volume = {32}, 
+number = {1}, 
+pages = {268-274}, 
+year = {2015}, 
+doi = {10.1093/molbev/msu300}, 
+URL = {http://mbe.oxfordjournals.org/content/32/1/268.abstract}, 
+eprint = {http://mbe.oxfordjournals.org/content/32/1/268.full.pdf+html}, 
+journal = {Molecular Biology and Evolution} 
+}
+
+
+
 @Article{ Nixon1999,
 	Author = "K. Nixon",
 	Title = "The Parsimony Ratchet, a New Method for Rapid Rarsimony Analysis",
@@ -291,7 +501,7 @@
 	Title = "Multiple comparisons of log-likelihoods with applications to phylogenetic inference.",
 	Journal = "Molecular Biology and Evolution",
 	Volume = "16",
-	Pages = "1114–1116",
+	Pages = "1114--1116",
 	Year = "1999"
 }
 
@@ -362,8 +572,24 @@
 	Year = "1985"
 }
 
+
+ at inproceedings{Leisch2002,
+  author = {Friedrich Leisch},
+  title = {Sweave: Dynamic Generation of Statistical Reports Using
+		  Literate Data Analysis},
+  booktitle = {Compstat 2002 --- Proceedings in Computational
+		  Statistics},
+  pages = {575--580},
+  year = 2002,
+  editor = {Wolfgang H{\"a}rdle and Bernd R{\"o}nz},
+  publisher = {Physica Verlag, Heidelberg},
+  note = {ISBN 3-7908-1517-9},
+  url = {http://www.stat.uni-muenchen.de/~leisch/Sweave}
+}
+
+
 @Article{Penny1985,
-    Author = "Penny, D. and Hendy, M.D.",
+    Author = "D. Penny and M.D. Hendy",
     Title = "Testing methods evolutionary tree construction",
 	Journal = "Cladistics",
 	Volume = "1",
@@ -372,7 +598,7 @@
 }
 
 @Article{Penny1986,
-    Author = "Penny, D. and Hendy, M.D.",
+    Author = "D. Penny and M.D. Hendy",
     Title = "Estimating the reliability of evolutionary trees",
     Journal = "Molecular Biology and Evolution",
 	Volume = "3",
@@ -380,6 +606,19 @@
 	Year = "1986"
 }
 
+
+ at Article{Yang1998,
+    author="Yang, Ziheng and Nielsen, Rasmus",
+    title="Synonymous and nonsynonymous rate variation in nuclear genes of mammals",
+    journal="Journal of Molecular Evolution",
+    year="1998",
+    volume="46",
+    number="4",
+    pages="409--418",
+    doi="10.1007/PL00006320",
+    url="http://dx.doi.org/10.1007/PL00006320"
+}
+
 @Book{ Yang2006,
 	Author = "Ziheng Yang",
 	Title = "Computational Molecular evolution",
@@ -388,6 +627,15 @@
 	Year = "2006"
 }
 
+
+ at Book{ Yang2014,
+	Author = "Ziheng Yang",
+	Title = "Molecular Evolution: A Statistical Approach",
+	Publisher = "Oxford University Press",
+	Address = "Oxford",
+	Year = "2014"
+}
+
 @Article{ Paradis2004,
 	Author = "E. Paradis and J. Claude and K. Strimmer",
 	Title = "{APE}: Analyses of Phylogenetics and Evolution in {R} language",
@@ -475,7 +723,7 @@
 
 @Article{ Rokas2003,
     title = "Genome-scale approaches to resolving incongruence in molecular phylogenies",
-	author = "Rokas, A. and Williams, B. L. and King, N., and Carroll, S. B.",
+	author = "A. Rokas and B.L. Williams and N. King and S.B. Carroll",
 	journal = "Nature",
 	year = "2011",
         volume = "425",
@@ -507,7 +755,7 @@
     title = {{MODELTEST}: testing the model of {DNA} substitution.}, 
     volume = {14}, 
     number = {9}, 
-    pages = {817-818}, 
+    pages = {817--818}, 
     year = {1998}, 
     journal = {Bioinformatics} 
 }
@@ -517,17 +765,17 @@
     title = {{jModelTest}: Phylogenetic Model Averaging}, 
     volume = {25}, 
     number = {7}, 
-    pages = {1253-1256}, 
+    pages = {1253--1256}, 
     year = {2008}, 
     URL = {http://mbe.oxfordjournals.org/content/25/7/1253.abstract}, 
     journal = {Molecular Biology and Evolution} 
 }
 
 @article{Hendy1982,
-    author = {Hendy, M.D. and Penny D.}, 
+    author = {M.D. Hendy and D. Penny}, 
     title = {Branch and bound algorithms to determine minimal evolutionary trees}, 
     volume = {59}, 
-    pages = {277-290}, 
+    pages = {277--290}, 
     year = {1982}, 
     journal = {Math. Biosc.} 
 }
@@ -541,7 +789,7 @@
 }
 
 @Book{ Burnham2002,
-    Author = "Burnham, K. P. and Anderson, D. R",
+    Author = "K. P. Burnham and D. R. Anderson",
     Title = "Model selection and multimodel inference: a practical information-theoretic approach",
     Edition = "Second",
     Publisher = "Springer",
@@ -560,6 +808,20 @@
     author = "Fran\c{c}ois-Joseph Lapointe and Philippe Lopez and Yan Boucher and Jeremy Koenig and Eric Bapteste"
 }
 
+
+ at article{Vos2003,
+    author = {Vos, R. A.}, 
+    title = {Accelerated Likelihood Surface Exploration: The Likelihood Ratchet},
+    volume = {52}, 
+    number = {3}, 
+    pages = {368-373}, 
+    year = {2003}, 
+    doi = {10.1080/10635150390196993}, 
+    URL = {http://sysbio.oxfordjournals.org/content/52/3/368.abstract}, 
+    journal = {Systematic Biology} 
+}
+
+
 @article{Wilkinson2007,
     title = "Of clades and clans: terms for phylogenetic relationships in unrooted trees",
     journal = "Trends in Ecology and Evolution",
@@ -579,3 +841,39 @@
     author = "Tandy Warnow"  
 }
 
+
+ at Manual{knitr,
+    title = {knitr: A General-Purpose Package for Dynamic Report
+      Generation in R},
+    author = {Yihui Xie},
+    year = {2015},
+    note = {R package version 1.11},
+    url = {http://yihui.name/knitr/},
+}
+
+
+ at Book{Xie2015,
+    title = {Dynamic Documents with {R} and knitr},
+    author = {Yihui Xie},
+    publisher = {Chapman and Hall/CRC},
+    address = {Boca Raton, Florida},
+    year = {2015},
+    edition = {2nd},
+    note = {ISBN 978-1498716963},
+    url = {http://yihui.name/knitr/},
+}
+
+
+ at InCollection{Xie2014,
+    booktitle = {Implementing Reproducible Computational Research},
+    editor = {Victoria Stodden and Friedrich Leisch and Roger D. Peng},
+    title = {knitr: A Comprehensive Tool for Reproducible Research in
+      {R}},
+    author = {Yihui Xie},
+    publisher = {Chapman and Hall/CRC},
+    year = {2014},
+    note = {ISBN 978-1466561595},
+    url = {http://www.crcpress.com/product/isbn/9781466561595},
+}
+
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/r-cran-phangorn.git



More information about the debian-med-commit mailing list