#include <iostream>
#include <vector>
#include <set>
using namespace std;
const int maxn = 1e5+10, maxlog = 20;
vector < int > v[maxn];
vector < int > a[maxn];
int depth[maxn];
set < int > s[20][maxn];
int sparce[maxlog][maxn];
void dfs(int x, int p = 0) {
    depth[x] = depth[p] + 1;
    sparce[0][x] = p;
    for (int i : a[x]) {
        if (s[0][x].size() == 10) break;
        s[0][x].insert(i);
    }
    for (int i : v[x]) {
        if (i == p) continue;
        dfs(i, x);
    }
}
int equalize(int x, int y) {
    for (int i = maxlog - 1 ; i >= 0 ; --i)
        if (depth[sparce[i][x]] >= depth[y])
            x = sparce[i][x];
    return x;
}
int find_lca(int x, int y) {
    if (x == y) return x;
    for (int i = maxlog-1 ; i >= 0 ; --i) {
        if (sparce[i][x] != sparce[i][y]) {
            x = sparce[i][x];
            y = sparce[i][y];
        }
    }
    return sparce[0][x];
}
int lca(int x, int y) {
    if (depth[x] > depth[y]) swap(x, y);
    return find_lca(x, equalize(y, x));
}
int mn;
set < int > res;
void merge(const set < int > &a1, const set < int > &b1) {
    auto it_a = a1.begin();
    auto it_b = b1.begin();
    res.clear();
    mn = 0;
    while (res.size() < 10 && (it_a != a1.end() || it_b != b1.end())) {
        if (it_b == b1.end()) {
            res.insert(*it_a);
            ++it_a;
            continue;
        }
        if (it_a == a1.end()) {
            res.insert(*it_b);
            ++it_b;
            continue;
        }
        if (*it_b < *it_a) {
            res.insert(*it_b);
            ++it_b;
        } else {
            res.insert(*it_a);
            ++it_a;
        }
    }
}
void f(int x, int lca, set < int > &curr) {
    for (int i = maxlog-2 ; i >= 0 ; --i) {
        if (depth[sparce[i][x]] >= depth[lca]) {
            merge(curr, s[i][x]);
            curr = res;
            x = sparce[i][x];
        }
    }
    merge(curr, {});
    curr = res;
}
set < int > a1, b1;
int x, y, z, n, m, t, len, curr_lca;
int main () {
    ios_base :: sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n >> m >> t;
    for (int i = 1 ; i < n ; ++i) {
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    for (int i = 1 ; i <= m ; ++i) {
        cin >> x;
        a[x].push_back(i);
    }
    dfs(1);
    for (int i = 1 ; i < maxlog ; ++i) {
        for (int j = 1 ; j <= n ; ++j) {
            sparce[i][j] = sparce[i-1][sparce[i-1][j]];
            s[i][j] = s[i-1][j];
            for (int x : s[i-1][sparce[i-1][j]])
                s[i][j].insert(x);
            auto it = s[i][j].end();
            while(s[i][j].size() > 10) {
                --it;
                s[i][j].erase(it);
            }
        }
    }
    for (int i = 1 ; i <= n ; ++i) {
        v[i].clear();
        a[i].clear();
    }
    for (int i = 0 ; i < t ; ++i) {
        cin >> x >> y >> z;
        curr_lca = sparce[0][lca(x, y)];
        a1.clear();
        b1.clear();
        f(x, curr_lca, a1);
        f(y, curr_lca, b1);
        merge(a1, b1);
        a1 = res;
        len = min(z, (int)a1.size());
        cout << len;
        auto it = a1.begin();
        for (int i = 0 ; i < len ; ++i) {
            cout << ' ' << *it;
            ++it;
        }
        cout << '\n';
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <cstdio>
using namespace std;
vector<int>adj[100001];
int N,M,Q;
set<int>arr[20][100001];
set<int>ans[100001];
int anc[20][100001];
int depth[100001];

void dfs(int node,int parent){
  anc[0][node]=parent;
  for (int i=0;i<adj[node].size();i++){
    if (adj[node][i]!=parent){
      depth[adj[node][i]]=depth[node]+1;
      dfs(adj[node][i],node);
    }
  }
}

void shorten(int i, int j){
  while (arr[i][j].size()>10)
    arr[i][j].erase(*arr[i][j].rbegin());
}

void shorten_pls(int x)
{
  while (ans[x].size()>10)
    ans[x].erase(*ans[x].rbegin());
}

int lca(int x, int y){
  if (depth[x]>depth[y])
    swap(x,y);
  int dif=depth[y]-depth[x];
  for (int i=19;i>=0;i--)
    if (((1<<i)&dif)!=0)
      y=anc[i][y];
  if (x==y)
    return x;
  for (int i=19;i>=0;i--){
    if (anc[i][x]!=anc[i][y]){
      x=anc[i][x];
      y=anc[i][y];
    }
  }
  return anc[0][x];
}

int main()
{
  int X,Y;
  scanf("%d%d%d",&N,&M,&Q);
  for (int i=0;i+1<N;i++){
    scanf("%d%d",&X,&Y);
    adj[X].push_back(Y);
    adj[Y].push_back(X);
  }
  for (int i=1;i<=M;i++){
    scanf("%d",&X);
    arr[0][X].insert(i);
  }
  dfs(1,1);
  for (int j=1;j<20;j++)
    for (int i=1;i<=N;i++)
      anc[j][i]=anc[j-1][anc[j-1][i]];
  for (int i=1;i<20;i++){
    for (int j=1;j<=N;j++){
      arr[i][j].insert(arr[i-1][j].begin(),arr[i-1][j].end());
      arr[i][j].insert(arr[i-1][anc[i-1][j]].begin(),arr[i-1][anc[i-1][j]].end());
      shorten(i,j);
    }
  }
  int V,U,A;
  /*
  for (;;){
    cin>>V>>U;
    cout<<arr[V][U].size()<<endl;
    for (set<int>::iterator it=arr[V][U].begin();it!=arr[V][U].end();it++)
      cout<<*it<<' ';
    cout<<endl;
  }
  */
  while (Q--){
    scanf("%d%d%d",&V,&U,&A);
    int node=lca(V,U);
    //cout<<"lca: "<<node<<endl;
    int dif=depth[V]-depth[node]+1;
    //cout<<"dif: "<<dif<<' ';
    for (int i=19;i>=0;i--){
      if (((1<<i)&dif)!=0){
	ans[Q].insert(arr[i][V].begin(),arr[i][V].end());
	//shorten_pls(Q);
	V=anc[i][V];
	//V=anc[0][V];
      }
    }
    //repeat
    dif=depth[U]-depth[node]+1;
    //cout<<dif<<endl;
    for (int i=19;i>=0;i--)
      if (((1<<i)&dif)!=0){
	ans[Q].insert(arr[i][U].begin(),arr[i][U].end());
	//shorten_pls(Q);
	U=anc[i][U];
	//U=anc[0][U];
      }
    int lol=min((int)ans[Q].size(),A);
    printf("%d ",lol);
    for (set<int>::iterator it=ans[Q].begin();it!=ans[Q].end();it++){
      printf("%d ",*it);
      lol--;
      if (lol==0)
	break;
    }
    printf("\n");
    ans[Q].clear();
  }
  return 0;
}


#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <cstdio>
using namespace std;

struct node{
  int a[11];
  node(){
    memset(a, 20, sizeof(a));
  }
  void insert(int val){
    a[10]=val;
    sort(a,a+11);
  }
};

vector<int>adj[100001];
int N,M,Q;
struct node arr[20][100001];
struct node ans[100001];
int anc[20][100001];
int depth[100001];

node merge(node x, node y){
  node ans = x;
  for (int i = 0; i < 11; i++){
    bool there=false;
    for (int j=0;j<11;j++){
      if (ans.a[j]==y.a[i]){
	there=true;
	break;
      }
    }
    if (there==false)
      ans.insert(y.a[i]);
  }
  return ans;
}

void dfs(int node,int parent){
  anc[0][node]=parent;
  for (int i=0;i<adj[node].size();i++){
    if (adj[node][i]!=parent){
      depth[adj[node][i]]=depth[node]+1;
      dfs(adj[node][i],node);
    }
  }
}

int lca(int x, int y){
  if (depth[x]>depth[y])
    swap(x,y);
  int dif=depth[y]-depth[x];
  for (int i=19;i>=0;i--)
    if (((1<<i)&dif)!=0)
      y=anc[i][y];
  if (x==y)
    return x;
  for (int i=19;i>=0;i--){
    if (anc[i][x]!=anc[i][y]){
      x=anc[i][x];
      y=anc[i][y];
    }
  }
  return anc[0][x];
}

int main()
{
  int X,Y;
  scanf("%d%d%d",&N,&M,&Q);
  for (int i=0;i+1<N;i++){
    scanf("%d%d",&X,&Y);
    adj[X].push_back(Y);
    adj[Y].push_back(X);
  }
  for (int i=1;i<=M;i++){
    scanf("%d",&X);
    arr[0][X].insert(i);
  }
  dfs(1,1);
  for (int j=1;j<20;j++)
    for (int i=1;i<=N;i++)
      anc[j][i]=anc[j-1][anc[j-1][i]];
  for (int i=1;i<20;i++){
    for (int j=1;j<=N;j++){
      arr[i][j]=merge(arr[i-1][j],arr[i-1][anc[i-1][j]]);
    }
  }
  int V,U,A;
  while (Q--){
    scanf("%d%d%d",&V,&U,&A);
    int node=lca(V,U);
    int dif=depth[V]-depth[node]+1;
    for (int i=19;i>=0;i--){
      if (((1<<i)&dif)!=0){
	ans[Q]=merge(arr[i][V],ans[Q]);
	V=anc[i][V];
      }
    }
    //repeat
    dif=depth[U]-depth[node]+1;
    for (int i=19;i>=0;i--)
      if (((1<<i)&dif)!=0){
	ans[Q]=merge(arr[i][U],ans[Q]);
	U=anc[i][U];
      }
    int temp=0;
    for (int i=0;i<10;i++){
      if (ans[Q].a[i]==336860180)
	break;
      temp++;
    }
    int lol=min(temp,A);
    printf("%d ",lol);
    for (int i=0;i<lol;i++)
      printf("%d ",ans[Q].a[i]);
    printf("\n");
  }
  return 0;
}


#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;
vector<int>adj[100001];
int N,M,Q;
set<int>arr[20][100001];
set<int>ans[100001];
int anc[20][100001];
int depth[100001];

void dfs(int node,int parent){
  anc[0][node]=parent;
  for (int i=0;i<adj[node].size();i++){
    if (adj[node][i]!=parent){
      depth[adj[node][i]]=depth[node]+1;
      dfs(adj[node][i],node);
    }
  }
}

void shorten(int i, int j){
  while (arr[i][j].size()>10)
    arr[i][j].erase(*arr[i][j].rbegin());
}

int lca(int x, int y){
  if (depth[x]>depth[y])
    swap(x,y);
  int dif=depth[y]-depth[x];
  for (int i=19;i>=0;i--)
    if (((1<<i)&dif)!=0)
      y=anc[i][y];
  if (x==y)
    return x;
  for (int i=19;i>=0;i--){
    if (anc[i][x]!=anc[i][y]){
      x=anc[i][x];
      y=anc[i][y];
    }
  }
  return anc[0][x];
}

int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int X,Y;
  cin>>N>>M>>Q;
  for (int i=0;i+1<N;i++){
    cin>>X>>Y;
    adj[X].push_back(Y);
    adj[Y].push_back(X);
  }
  for (int i=1;i<=M;i++){
    cin>>X;
    arr[0][X].insert(i);
  }
  dfs(1,1);
  for (int j=1;j<20;j++)
    for (int i=1;i<=N;i++)
      anc[j][i]=anc[j-1][anc[j-1][i]];
  for (int i=1;i<20;i++){
    for (int j=1;j<=N;j++){
      arr[i][j].insert(arr[i-1][j].begin(),arr[i-1][j].end());
      arr[i][j].insert(arr[i-1][anc[i-1][j]].begin(),arr[i-1][anc[i-1][j]].end());
      shorten(i,j);
    }
  }
  int V,U,A;
  /*
  for (;;){
    cin>>V>>U;
    cout<<arr[V][U].size()<<endl;
    for (set<int>::iterator it=arr[V][U].begin();it!=arr[V][U].end();it++)
      cout<<*it<<' ';
    cout<<endl;
  }
  */
  while (Q--){
    cin>>V>>U>>A;
    int node=lca(V,U);
    //cout<<"lca: "<<node<<endl;
    int dif=depth[V]-depth[node]+1;
    //cout<<"dif: "<<dif<<' ';
    for (int i=19;i>=0;i--){
      if (((1<<i)&dif)!=0){
	ans[Q].insert(arr[i][V].begin(),arr[i][V].end());
	V=anc[i][V];
	//V=anc[0][V];
      }
    }
    //repeat
    dif=depth[U]-depth[node]+1;
    //cout<<dif<<endl;
    for (int i=19;i>=0;i--)
      if (((1<<i)&dif)!=0){
	ans[Q].insert(arr[i][U].begin(),arr[i][U].end());
	U=anc[i][U];
	//U=anc[0][U];
      }
    int lol=min((int)ans[Q].size(),A);
    cout<<lol<<' ';
    for (set<int>::iterator it=ans[Q].begin();it!=ans[Q].end();it++){
      cout<<*it<<' ';
      lol--;
      if (lol==0)
	break;
    }
    cout<<endl;
  }
  return 0;
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Exam
{
    public int a;
    public int b;
}

class GFG
{
    public static void Main()
    {

        string str = Console.ReadLine();
        int n = str.Length;
        int[] len = new int[n + 1];
        len[0] = 1;

        var ans = str.ToCharArray();

        for (int i = 1; i < n; i++)
        {
            if (str[i - 1] == str[i])
            {
                len[i] = len[i - 1] + 1;

                if (len[i] % 3 == 0)
                {
                    ans[i] = ' ';
                    ans[i - 1] = ' ';
                    len[i] = 1;
                    len[i - 1] = 0;
                }
                if (i - 2 >= 0 && len[i] == 2 && len[i - 2] == 2)
                {
                    ans[i] = ' ';
                    len[i]--;
                }

            }
            else
            {
                len[i] = 1;

            }
        }

        Console.Write(string.Join("",ans).Replace(" ", ""));

    }

}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Exam
{
    public int a;
    public int b;
}

class GFG
{
    public static void Main()
    {

        string str = Console.ReadLine();
        int n = str.Length;
        int[] len = new int[n + 1];
        len[0] = 1;

        var ans = str.ToCharArray();

        for (int i = 1; i < n; i++)
        {
            if (str[i - 1] == str[i])
            {
                len[i] = len[i - 1] + 1;

            }
            else
            {
                if (len[i - 1] >= 3)
                {
                    var start = i - len[i - 1];
                    var lst = 0;
                    if (start == 0 || len[start - 1] == 2)
                    {
                        start = start + 1;
                        lst = 1;
                    }
                    else
                    {
                        start = start + 2;
                        lst = 2;
                    }
                    int j = start;
                    for (; j < i; j++)
                    {
                        ans[j] = ' ';
                        len[j] = len[start - 1] == 2 ? 1 : 2;
                    }
                    len[j - 1] = lst;
                }
                else if (len[i - 1] == 2)
                {

                    if (i - 3 >= 0 && len[i - 1] == 2 && len[i - 3] == 2)
                    {
                        ans[i - 1] = ' ';
                        len[i - 1]--;
                    }
                }
                len[i] = 1;

            }
        }

        int lsts = len[str.Length - 1];
        if (lsts > 2)
        {
            if (len[str.Length - lsts - 1] != 2)
            {
                var cc = string.Join("", ans).Replace(" ", "");
                Console.Write(string.Join("", ans).Replace(" ", "").Substring(0, (cc.Length - lsts) + 2));
            }
            else
            {
                var cc = string.Join("", ans).Replace(" ", "");
                Console.Write(string.Join("", ans).Replace(" ", "").Substring(0, (cc.Length - lsts) + 1));
            }
        }
        else if (lsts == 2)
        {

            if (str.Length - 3 >= 0 && len[str.Length - 1] == 2 && len[str.Length - 3] == 2)
            {
                ans[str.Length - 1] = ' ';
                len[str.Length - 1]--;
                Console.Write(string.Join("", ans).Replace(" ", ""));
            }
            else
            {
                Console.Write(string.Join("", ans).Replace(" ", ""));
            }
        }
        else
        {

            Console.Write(string.Join("", ans).Replace(" ", ""));
        }
        Console.WriteLine();

    }

}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Exam
{
    public int a;
    public int b;
}

class GFG
{
    public static void Main()
    {

        string str = Console.ReadLine();
        int n = str.Length;
        int[] len = new int[n + 1];
        len[0] = 1;

        var ans = str.ToCharArray();

        for (int i = 1; i < n; i++)
        {
            if (str[i - 1] == str[i])
            {
                len[i] = len[i - 1] + 1;

            }
            else
            {
                if (len[i - 1] >= 3)
                {
                    var start = i - len[i - 1];
                    var lst = 0;
                    if (len[start - 1] == 2)
                    {
                        start = start + 1;
                        lst = 1;
                    }
                    else
                    {
                        start = start + 2;
                        lst = 2;
                    }
                    int j = start;
                    for (; j < i; j++)
                    {
                        ans[j] = ' ';
                        len[j] = len[start - 1] == 2 ? 1 : 2;
                    }
                    len[j - 1] = lst;
                }
                else if(len[i-1]==2)
                {

                    if (i - 3 >= 0 && len[i-1] == 2 && len[i - 3] == 2)
                    {
                        ans[i-1] = ' ';
                        len[i-1]--;
                    }
                }
                len[i] = 1;

            }
        }

        int lsts = len[str.Length - 1];
        if (lsts > 2)
        {
            var cc = string.Join("", ans).Replace(" ", "");
            Console.Write(string.Join("", ans).Replace(" ", "").Substring(0, (cc.Length - lsts) + 2));
        }
        else if(lsts==2)
        {

            if (str.Length - 3 >= 0 && len[str.Length - 1] == 2 && len[str.Length - 3] == 2)
            {
                ans[str.Length - 1] = ' ';
                len[str.Length - 1]--;
                Console.Write(string.Join("", ans).Replace(" ", ""));
            }
            else
            {
                Console.Write(string.Join("", ans).Replace(" ", ""));
            }
        }
        else
        {

            Console.Write(string.Join("", ans).Replace(" ", ""));
        }
        Console.WriteLine();

    }

}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Exam
{
    public int a;
    public int b;
}

class GFG
{
    public static void Main()
    {

        string str = Console.ReadLine();
        int n = str.Length;
        int[] len = new int[n + 1];
        len[0] = 1;

        var ans = str.ToCharArray();

        for (int i = 1; i < n; i++)
        {
            if (str[i - 1] == str[i])
            {
                len[i] = len[i - 1] + 1;

                if (len[i] % 3 == 0)
                {
                    ans[i] = ' ';
                    if (i != n - 1)
                        ans[i - 1] = ' ';
                    len[i] = 1;
                    len[i - 1] = 0;
                }
                if (i - 2 >= 0 && len[i] == 2 && len[i - 2] == 2)
                {
                    ans[i] = ' ';
                    len[i]--;
                }

            }
            else
            {
                len[i] = 1;

            }
        }

        Console.Write(string.Join("", ans).Replace(" ", ""));

    }

}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class GFG
{
    public static void Main()
    {

        string str = Console.ReadLine();

        List<char> ans = new List<char>();
        long flag = 0; ;
        int sz = 0;
        for (int i = 0; i < str.Length; i++)
        {
            flag = 0;
            sz = ans.Count;
            if (sz > 1 && ans[sz - 1] == ans[sz - 2] && ans[sz - 1] == str[i])
                flag = 1;
            if (sz > 2 && ans[sz - 1] == str[i] && ans[sz - 2] == ans[sz - 3])
                flag = 1;
            if (flag == 0) ans.Add(str[i]);
        }

        for(int i=0;i<ans.Count;i++)
        {
            Console.Write(ans[i]);
        }

    }

}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var phrase = new StringBuilder(Console.ReadLine());
            for (int i = phrase.Length-1; i >= 0; --i)
            {
                while (i - 2 >= 0 && phrase[i] == phrase[i - 1] && phrase[i - 1] == phrase[i - 2])
                {
                    phrase.Remove(i,1);
                    --i;
                }
                while (i - 3 >= 0 && phrase[i] == phrase[i - 1] && phrase[i - 2] == phrase[i - 3])
                {
                    phrase.Remove(i-2, 1);
                    --i;
                }
            }

            Console.WriteLine(phrase);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var phrase = new StringBuilder(Console.ReadLine());
            for (int i = phrase.Length-1; i >= 0; --i)
            {
                while (i - 2 >= 0 && phrase[i] == phrase[i - 1] && phrase[i - 1] == phrase[i - 2])
                {
                    phrase.Remove(i,1);
                    --i;
                }
                if (i - 3 >= 0 && phrase[i] == phrase[i - 1] && phrase[i - 2] == phrase[i - 3])
                {
                    phrase.Remove(i-2, 1);
                    --i;
                }
            }

            Console.WriteLine(phrase);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var phrase = new StringBuilder(Console.ReadLine());
            for (int i = phrase.Length-1; i >= 0; --i)
            {
                while (i - 2 >= 0 && phrase[i] == phrase[i - 1] && phrase[i - 1] == phrase[i - 2])
                {
                    phrase.Remove(i,1);
                    --i;
                }
                if (i - 3 >= 0 && phrase[i] == phrase[i - 1] && phrase[i - 2] == phrase[i - 3])
                {
                    phrase.Remove(i, 1);
                    --i;
                }
            }

            Console.WriteLine(phrase);
        }
    }
}


using System;

namespace ConsoleApplication23
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            char c = str[0];
            int index = 0;
            int count = 1;
            string str2 = c.ToString();
            for (int i = 1; i < str.Length; i++)
            {
                if (str[i] == c)
                {
                    count++;
                    if (count <= 2)
                    {
                        str2 = str2 + c;
                        continue;
                    }
                    continue;
                }
                c = str[i];
                str2 = str2 + c;
                index = i;
                count = 1;
            }
            if (count > 2)
            {
                str2 = str2 + c;
            }
            str = str2;
            str2 = str[0].ToString();
            c = str[0];
            index = 0;
            count = 0;
            int d = 0;
            for (int i = 1; i < str.Length; i++)
            {
                if (d > 1)
                {
                    count = 0;
                    d = 0;
                }
                if (c == str[i] && count == 1)
                {
                    count = 0;
                    c = str[i];
                    d = 0;
                    continue;
                }
                if (str[i] == c)
                {
                    count = 1;
                    d = 0;
                    str2 = str2 + str[i];
                    continue;
                }
                c = str[i];
                str2 = str2 + c;
                d++;
            }
            Console.WriteLine(str2);
        }
    }
}


using System;

namespace ConsoleApplication23
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            char c = str[0];
            int index = 0;
            int count = 1;
            int d = 0;
            int ala = 0;
            int h = 0;
            char e = str[0];
            Console.Write(str[0]);
            string str2 = c.ToString();
            for (int i = 1; i < str.Length; i++)
            {
                if (h > 1)
                {
                    ala = 0;
                    d = 0;
                }
                if (ala == 1)
                {
                    d = 0;
                    ala = 0;
                    h = 0;
                }
                if (str[i] == c)
                {
                    count++;
                    if (d == 1 && str[i] == c && str[i] != e)
                    {
                        ala = 1;
                        h = 0;
                        continue;
                    }
                    if (count <= 2)
                    {
                        Console.Write(c);
                        e = c;
                        d = 1;
                        h = 0;
                        continue;
                    }
                    continue;
                }
                c = str[i];
                Console.Write(c);
                index = i;
                count = 1;
                h++;
            }
        }
    }
}


using System;

namespace ConsoleApplication23
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            char c = str[0];
            int index = 0;
            int count = 1;
            for (int i = 1; i < str.Length; i++)
            {
                if (str[i] == c)
                {
                    count++;
                    continue;
                }
                if (count > 2)
                {
                    str = str.Remove(index + 1, count - 2);
                    i = i - count + 2;
                }
                c = str[i];
                index = i;
                count = 1;
            }
            if (count > 2)
            {
                str = str.Remove(index + 1, count - 2);
            }
            c = str[0];
            index = 0;
            count = 0;
            for (int i = 1; i < str.Length; i++)
            {
                if (c == str[i] && count == 1)
                {
                    str = str.Remove(i, 1);
                    i = i - 1;
                    count = 0;
                    c = str[i];
                    continue;
                }
                if (str[i] == c)
                {
                    count = 1;
                    continue;
                }
                c = str[i];
            }
            Console.WriteLine(str);
        }
    }
}


using System;

namespace ConsoleApplication23
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            char c = str[0];
            int index = 0;
            int count = 1;
            for (int i = 1; i < str.Length; i++)
            {
                if (str[i] == c)
                {
                    count++;
                    continue;
                }
                if (count > 2)
                {
                    str = str.Remove(index + 1, count - 2);
                    i = i - count + 2;
                }
                c = str[i];
                index = i;
                count = 1;
            }
            if (count > 2)
            {
                str = str.Remove(index + 1, count - 2);
            }
            c = str[0];
            index = 0;
            count = 0;
            int d = 0;
            for (int i = 1; i < str.Length; i++)
            {
                if (d > 1)
                {
                    count = 0;
                    d = 0;
                }
                if (c == str[i] && count == 1)
                {
                    str = str.Remove(i, 1);
                    i = i - 1;
                    count = 0;
                    c = str[i];
                    d = 0;
                    continue;
                }
                if (str[i] == c)
                {
                    count = 1;
                    d = 0;
                    continue;
                }
                c = str[i];
                d++;
            }
            Console.WriteLine(str);
        }
    }
}


using System;

namespace ConsoleApplication23
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            char c = str[0];
            int index = 0;
            int count = 1;
            int d = 0;
            int ala = 0;
            int h = 0;
            char e = str[0];
            string str2 = c.ToString();
            for (int i = 1; i < str.Length; i++)
            {
                if (h > 1)
                {
                    ala = 0;
                    d = 0;
                }
                if (ala == 1)
                {
                    d = 0;
                    ala = 0;
                    h = 0;
                }
                if (str[i] == c)
                {
                    count++;
                    if (d == 1 && str[i] == c && str[i] != e)
                    {
                        ala = 1;
                        h = 0;
                        continue;
                    }
                    if (count <= 2)
                    {
                        str2 = str2 + c;
                        e = c;
                        d = 1;
                        h = 0;
                        continue;
                    }
                    continue;
                }
                c = str[i];
                str2 = str2 + c;
                index = i;
                count = 1;
                h++;
            }
            if (count < 2)
            {
                str2 = str2 + c;
            }
            Console.WriteLine(str2);
        }
    }
}


using System;

namespace ConsoleApplication23
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            char c = str[0];
            int index = 0;
            int count = 1;
            for (int i = 1; i < str.Length; i++)
            {
                if (str[i] == c)
                {
                    count++;
                    continue;
                }
                if (count > 2)
                {
                    str = str.Remove(index + 1, count - 2);
                    i = i - count + 2;
                }
                c = str[i];
                index = i;
                count = 1;
            }
            c = str[0];
            index = 0;
            count = 0;
            for (int i = 1; i < str.Length; i++)
            {
                if (c == str[i] && count == 1)
                {
                    str = str.Remove(i, 1);
                    i = i - 1;
                    count = 0;
                    c = str[i];
                    continue;
                }
                if (str[i] == c)
                {
                    count = 1;
                    continue;
                }
                c = str[i];
            }
            Console.WriteLine(str);
        }
    }
}


using System;

namespace ConsoleApplication23
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            char c = str[0];
            int index = 0;
            int count = 1;
            int d = 0;
            int ala = 0;
            int h = 0;
            char e = str[0];
            string str2 = c.ToString();
            for (int i = 1; i < str.Length; i++)
            {
                if (h > 1)
                {
                    ala = 0;
                    d = 0;
                }
                if (ala == 1)
                {
                    d = 0;
                    ala = 0;
                    h = 0;
                }
                if (str[i] == c)
                {
                    count++;
                    if (d == 1 && str[i] == c && str[i] != e)
                    {
                        ala = 1;
                        h = 0;
                        continue;
                    }
                    if (count <= 2)
                    {
                        str2 = str2 + c;
                        e = c;
                        d = 1;
                        h = 0;
                        continue;
                    }
                    continue;
                }
                c = str[i];
                str2 = str2 + c;
                index = i;
                count = 1;
                h++;
            }
            Console.WriteLine(str2);
        }
    }
}


struct Scan {
    buffer: std::collections::VecDeque<String>,
}

impl Scan {
    fn new() -> Scan {
        Scan {
            buffer: std::collections::VecDeque::new(),
        }
    }

    fn next_line(&self) -> String {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).expect("Fail to read");
        line
    }

    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop_front() {
                break token.parse::<T>().ok().unwrap();
            }
            let line = self.next_line();
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }
}

fn _main() {
    let mut scan = Scan::new();
    let input: Vec<char> = scan.next::<String>().chars().collect();
    let mut output: Vec<char> = Vec::new();
    output.push(input[0]);
    output.push(input[1]);
    let mut o_i = 1;
    for i in 2..input.len() {
        let tripple_typo = input[i] == input[i - 1] && input[i] == input[i - 2];
        let double_typo = o_i >= 2 && input[i] == output[o_i] && output[o_i - 1] == output[o_i - 2];
        if tripple_typo || double_typo {
            continue;
        }
        output.push(input[i]);
        o_i += 1;
    }
    let output: String = output.into_iter().collect();
    println!("{}", output);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(1 << 23)
        .spawn(_main)
        .unwrap()
        .join()
        .unwrap();
}


struct Scan {
    buffer: std::collections::VecDeque<String>,
}

impl Scan {
    fn new() -> Scan {
        Scan {
            buffer: std::collections::VecDeque::new(),
        }
    }

    fn next_line(&self) -> String {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).expect("Fail to read");
        line
    }

    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop_front() {
                break token.parse::<T>().ok().unwrap();
            }
            let line = self.next_line();
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }
}

fn _main() {
    let mut scan = Scan::new();
    let input: Vec<char> = scan.next::<String>().chars().collect();
    let mut output: Vec<char> = Vec::new();
    if input.len() < 3 {
        let output: String = input.into_iter().collect();
        println!("{}", output);
        return;
    }
    output.push(input[0]);
    output.push(input[1]);
    let mut o_i = 1;
    for i in 2..input.len() {
        let tripple_typo = input[i] == input[i - 1] && input[i] == input[i - 2];
        let double_typo = o_i >= 2 && input[i] == output[o_i] && output[o_i - 1] == output[o_i - 2];
        if tripple_typo || double_typo {
            continue;
        }
        output.push(input[i]);
        o_i += 1;
    }
    let output: String = output.into_iter().collect();
    println!("{}", output);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(1 << 23)
        .spawn(_main)
        .unwrap()
        .join()
        .unwrap();
}


package main

import "fmt"

func main(){
	var c rune
	var a rune = 1
	var aa rune = 2
	var aaa rune = 3
	for string(c) != "\n" {
		fmt.Scanf("%c", &c)
		if !(aaa == aa && a == c) && !(c == a && a == aa) {
			fmt.Print(string(c))
			aaa = aa
			aa = a
			a = c
		}
	}
}


package main

import "fmt"
import "os"
import "bufio"

func main(){
	var c rune
	var a rune = 1
	var aa rune = 2
	var aaa rune = 3
	w := bufio.NewWriter(os.Stdin)
	for string(c) != "\n" {
		fmt.Scanf("%c", &c)
		if !(aaa == aa && a == c) && !(c == a && a == aa) {
			w.WriteString(string(c))
			aaa = aa
			aa = a
			a = c
		}
	}
	w.Flush()
}


package main

import "fmt"
import "os"
import "bufio"

func main(){
	var c rune
	var a rune = 1
	var aa rune = 2
	var aaa rune = 3
	w := bufio.NewWriter(os.Stdout)
	for string(c) != "\n" {
		fmt.Scanf("%c", &c)
		if !(aaa == aa && a == c) && !(c == a && a == aa) {
			w.WriteString(string(c))
			aaa = aa
			aa = a
			a = c
		}
	}
	w.Flush()
}


package main

import (
	"bufio"
	"fmt"
	"os"
	//	"strconv"
)

var (
	in  = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

var (
	st string
	//s  string
)

func main() {

	defer out.Flush()
	in.Split(bufio.ScanWords)

	fmt.Scan(&st)

	a := []byte(st)

	ln := len(a)
	s := a[:2]

	for i := 2; i < ln; i++ {
		if (st[i] != st[i-1]) || (st[i] != st[i-2]) {
			//s = s + st[i]
			s = append(s, a[i])
		}
	}

	ln = len(s)
	ans := s

	if ln < 4 {
		fmt.Print(string(ans))
	} else {

		ans = s[:3]

		for i := 3; i < ln; i++ {
			if (s[i] != s[i-1]) || (s[i-2] != s[i-3]) {
				ans = append(ans, s[i])
			}
		}
	}

	fmt.Print(string(ans))
}


package main

import (
	"bufio"
	"fmt"
	"os"
	//	"strconv"
)

var (
	in  = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

var (
	st  string
	s   []byte
	ans []byte
	//s  string
)

func main() {

	defer out.Flush()
	in.Split(bufio.ScanWords)

	fmt.Scan(&st)

	a := []byte(st)

	ln := len(a)
	s = append(s, a[0], a[1])

	for i := 2; i < ln; i++ {
		if (st[i] != st[i-1]) || (st[i] != st[i-2]) {
			//s = s + st[i]
			s = append(s, a[i])
		}
	}

	ln = len(s)

	//fmt.Println(s)
	if ln < 4 {
		fmt.Print(string(s))
	} else {

		ans = append(ans, s[0], s[1], s[2])

		for i := 3; i < ln; i++ {
			if (s[i] != ans[len(ans)-1]) || (ans[len(ans)-2] != ans[len(ans)-3]) {
				ans = append(ans, s[i])
			}
			//fmt.Println(s[i-3], " ", s[i-2], " ", s[i-1], " ", s[i])
			//fmt.Println(string(ans))
		}
	}

	fmt.Print(string(ans))
}


package main

import (
	"bufio"
	"fmt"
	"os"
	//	"strconv"
)

var (
	in  = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

var (
	st  string
	s   []byte
	ans []byte
	//s  string
)

func main() {

	defer out.Flush()
	in.Split(bufio.ScanWords)

	fmt.Scan(&st)

	a := []byte(st)

	ln := len(a)

	if ln < 2 {
		fmt.Print(st)
		out.Flush()
		os.Exit(0)
	}
	s = append(s, a[0], a[1])

	for i := 2; i < ln; i++ {
		if (st[i] != st[i-1]) || (st[i] != st[i-2]) {
			//s = s + st[i]
			s = append(s, a[i])
		}
	}

	ln = len(s)

	//fmt.Println(s)
	if ln < 4 {
		fmt.Print(string(s))
	} else {

		ans = append(ans, s[0], s[1], s[2])

		for i := 3; i < ln; i++ {
			if (s[i] != ans[len(ans)-1]) || (ans[len(ans)-2] != ans[len(ans)-3]) {
				ans = append(ans, s[i])
			}
			//fmt.Println(s[i-3], " ", s[i-2], " ", s[i-1], " ", s[i])
			//fmt.Println(string(ans))
		}
	}

	fmt.Print(string(ans))
}


package main

import (
	"bufio"
	"fmt"
	"os"
	//	"strconv"
)

var (
	in  = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

var (
	st string
	//s  string
)

func main() {

	defer out.Flush()
	in.Split(bufio.ScanWords)

	fmt.Scan(&st)

	a := []byte(st)

	ln := len(a)
	s := a[:2]

	for i := 2; i < ln; i++ {
		if (st[i] != st[i-1]) || (st[i] != st[i-2]) {
			//s = s + st[i]
			s = append(s, a[i])
		}
	}

	ln = len(s)
	ans := s

	if ln < 4 {
		fmt.Print(string(ans))
	} else {

		ans = s[:4]

		for i := 4; i < ln; i++ {
			if (s[i] != s[i-1]) || (s[i-2] != s[i-3]) {
				ans = append(ans, s[i])
			}
		}
	}

	fmt.Print(string(ans))
}


package main

import (
	"fmt"
)

func main() {
	const N int = 200000
	var counter = [N]int{}
	var typo string
	fmt.Scan(&typo)
	length := len(typo)
	tail := 0
	for i := 0; i < length; {
		j := i
		for ; j < length && typo[i] == typo[j]; j++ {
		}
		counter[tail] = j - i
		i = j
		tail++
	}
	for counter_iter, index := 0, 0; counter_iter < tail; {
		temp_iter := counter_iter
		for ; temp_iter < tail && counter[temp_iter] > 1; temp_iter++ {
		}
		for bit := 0; counter_iter < tail && counter_iter <= temp_iter; counter_iter++ {
			if (bit&1) == 0 && counter[counter_iter] > 1 {
				fmt.Printf("%c%c", typo[index], typo[index])
			} else {
				fmt.Printf("%c", typo[index])
			}
			index += counter[counter_iter]
			bit ^= 1
		}
	}
	fmt.Println()
}


<?php
error_reporting("off");
//363C: Fixing Typos
$string = str_split(trim(fgets(STDIN))); //$string = str_split("aabbaa");
$answer = array();
foreach ($string as $value) {
    $nope = FALSE;
    $last = end($answer);
    $secondtolast = prev($answer);
    $thirdtolast = prev($answer);
    if ($last == $value && $secondtolast == $value) {
        $nope = TRUE;
    } elseif ($last == $value && $secondtolast == $thirdtolast && $secondtolast !== FALSE) {
        $nope = TRUE;
    }

    if ($nope == FALSE) {
        $answer[] = $value;
    }
}
echo implode($answer);
?>


<?php
error_reporting("off");
//363C: Fixing Typos
$string = str_split(trim(fgets(STDIN))); //$string = str_split("heeello");
$answer = array();
foreach ($string as $value) {
    $nope = FALSE;
    $last = end($answer);
    $secondtolast = prev($answer);
    $thirdtolast = prev($answer);
    if ($last == $value && $secondtolast == $value) {
        $nope = TRUE;
    } elseif ($last == $value && $secondtolast == $thirdtolast) {
        $nope = TRUE;
    }

    if ($nope == FALSE) {
        $answer[] = $value;
    }
}
echo implode($answer);
?>


"Template made by : https://codeforces.com/profile/c1729 , github repo : https://github.com/cheran-senthil/PyRival"
from __future__ import division, print_function
import bisect
import math
import itertools
import sys
from atexit import register

if sys.version_info[0] < 3:
    from io import BytesIO as stream
else:
    from io import StringIO as stream

if sys.version_info[0] < 3:
    class dict(dict):
        """dict() -> new empty dictionary"""
        def items(self):
            """D.items() -> a set-like object providing a view on D's items"""
            return dict.iteritems(self)

        def keys(self):
            """D.keys() -> a set-like object providing a view on D's keys"""
            return dict.iterkeys(self)

        def values(self):
            """D.values() -> an object providing a view on D's values"""
            return dict.itervalues(self)

    input = raw_input
    range = xrange

    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip

def sync_with_stdio(sync=True):
    """Set whether the standard Python streams are allowed to buffer their I/O.

    Args:
        sync (bool, optional): The new synchronization setting.

    """
    global input, flush

    if sync:
        flush = sys.stdout.flush
    else:
        sys.stdin = stream(sys.stdin.read())
        input = lambda: sys.stdin.readline().rstrip('\r\n')

        sys.stdout = stream()
        register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

def main():
    s=input()
    x=0
    l1=[]
    c=0
    for i in range(0,len(s)):
        if i==0:
            l1.append(s[i])
            c=1
            f=s[0]
        else :
            if c<2:
                l1.append(s[i])
                if s[i]==f:
                    c+=1
                else :
                    f=s[i]
                    c=1
            else :
                if s[i]==f:
                    c+=1
                else :
                    l1.append(s[i])
                    f=s[i]
                    c=1
    c=0
    flag=0
    l2=[]
    for i in range(0,len(l1)):
        if flag==0:
            l2.append(l1[i])
            if c==0:
                c=1
                f=l1[i]
            elif l1[i]==f:
                c=2
                flag=1
            else :
                c=1
                f=l1[i]
        else :
            if c==2:
                x=l1[i]
                c-=1
                l2.append(l1[i])
            else :
                if l1[i]==x:
                    c=0
                    flag=0
                else :
                    l2.append(l1[i])
                    f=l1[i]
                    c=1
                    flag=0
    print(''.join(l2))

if __name__ == '__main__':
    sync_with_stdio(False)
    main()


import sys
from collections import Counter
#sys.stdin = open('input.txt', 'r')
#sys.stdout = open('output.txt','w')
S = list(raw_input().strip())
N = len(S)
ans = []
i = 0
prev, cnt = '1',0
while i < N :
    if prev == S[i] :
        ans[-1][1] += 1
    else :
        prev = S[i]
        cnt = 1
        ans += [S[i],cnt],
    i += 1
N = len(ans)
if ans[0][1] > 2 :
    ans[0][1] = 2
for i in xrange(1,N) :
    if ans[i][1] > 2 :
        ans[i][1] = 2
    if ans[i][1] == 2 and ans[i-1][1] == 2 :
        ans[i][1] = 1
ans = [ans[i][0]*ans[i][1] for i in xrange(N)]
print ''.join(ans)


import sys
a, b, c, d = '@', '#', '$', '%'
a = raw_input();
for x in range(0, len(a)):
    if (not((a[x] == b and b == c) or (a[x] == b and c == d))):
			sys.stdout.write(a[x])
			d = c;
			c = b;
			b = a[x];


import sys
a, b, c, d, str = '@', '#', '$', '%', ""
a = raw_input();

for x in range(0, len(a)):
    if (not((a[x] == b and b == c) or (a[x] == b and c == d))):
			sys.stdout.write(a[x])
			d = c;
			c = b;
			b = a[x];


s = raw_input().strip()
n = len(s)

l = []

cur = s[0]
num = 1

for i in xrange(1, n):
    if s[i] != cur:
        l.append([cur, num])
        cur = s[i]
        num = 1
    else:
        num += 1

l.append([cur, num])

for i in xrange(len(l) - 1):
    a, b = l[i], l[i + 1]
    if a[1] >= 3: a[1] = 2
    if a[1] == 2 and b[1] == 2: b[1] = 1

word = []
for i in xrange(len(l)):
    for j in xrange(l[i][1]): word.append(l[i][0])

print ''.join(word)


s = raw_input().strip()
n = len(s)

l = []

cur = s[0]
num = 1

for i in xrange(1, n):
    if s[i] != cur:
        l.append([cur, num])
        cur = s[i]
        num = 1
    else:
        num += 1

l.append([cur, num])

for i in xrange(len(l) - 1):
    a, b = l[i], l[i + 1]
    if a[1] >= 3: a[1] = 2
    if b[1] >= 3: b[1] = 2
    if a[1] == 2 and b[1] == 2: b[1] = 1

word = []
for i in xrange(len(l)):
    for j in xrange(l[i][1]): word.append(l[i][0])

print ''.join(word)


s = raw_input().strip()
n = len(s)

l = []

cur = s[0]
num = 1

for i in xrange(1, n):
    if s[i] != cur:
        l.append([cur, num])
        cur = s[i]
        num = 1
    else:
        num += 1

l.append([cur, num])

for i in xrange(len(l)):
    try:
        a, b = l[i], l[i + 1]
        if a[1] >= 3: a[1] = 2
        if b[1] >= 3: b[1] = 2
        if a[1] == 2 and b[1] == 2: b[1] = 1
    except:
        a = l[i]
        if a[1] >= 3: a[1] = 2

word = []
for i in xrange(len(l)):
    for j in xrange(l[i][1]): word.append(l[i][0])

print ''.join(word)


s = input()
l = list(s)
l.append(1)
#print(l)
l1 = []
c1,c = 1,1
for i in range(len(s)):
    if l[i]==l[i+1]:
        c1+=1
    else:
        l1.append(s[i])
        if c1>2:
            l1.append(s[i])
        elif c1==2 and c==2:
            l1.append(s[i])
        c = c1
        c1=1
print(''.join(l1))


s=input()
z=[]
count=1
for i in range(len(s)):
    z.append(s[i])
i=1
while(i<len(z)):
    if(s[i]==s[i-1]):
        count=count+1
    else:
        if(count>=3):
            kap=0
            while(count>2):
                z[i-kap-1]=-1
                kap=kap+1
                count=count-1
        count=1

    i=i+1
z=list(filter(lambda a: a!=-1,z))
for i in range(3,len(z)):
    if(z[i]==z[i-1] and z[i-2]==z[i-3]):
        z[i]=-1
z=list(filter(lambda a: a!=-1,z))
print(''.join(map(str,z)))


s=input()
z=[]
count=1
for i in range(len(s)):
    z.append(s[i])
i=1
while(i<len(z)):
    if(s[i]==s[i-1]):
        count=count+1
    else:
        if(count>=3):
            kap=0
            while(count>2):
                z[i-kap-1]=-1
                kap=kap+1
                count=count-1
        count=1

    i=i+1
if(count>=3):
    kap=0
    while(count>2):
        z[i-kap-1]=-1
        kap=kap+1
        count=count-1
z=list(filter(lambda a: a!=-1,z))

for i in range(3,len(z)):
    if(z[i]==z[i-1] and z[i-2]==z[i-3]):
        z[i]=-1
z=list(filter(lambda a: a!=-1,z))
print(''.join(map(str,z)))


import sys
import math as mt
#input=sys.stdin.buffer.readline
#import bisect
mod=1000000007
#t=int(input())
#tot=0
t=1

for __ in range(t):
    #n=int(input())
    #n,p=map(int,input().split())
    s1=input()
    ans=''
    ch=4
    for i in range(len(s1)):
        if i<=(len(s1)-3):
            if s1[i]==s1[i+1]==s1[i+2]:
                continue
        if i<=(len(s1)-2):
            if s1[i]==s1[i+1]:
                if ch!=-1:
                    ans+=s1[i]
                    ch=4
                else:
                    continue
                ch=-2
            else:
                ans+=s1[i]
                if ch==-2:
                    ch+=1
                else:
                    ch=4

    ans+=s1[-1]

    print(ans)


import sys
import math as mt
#input=sys.stdin.buffer.readline
#import bisect
mod=1000000007
#t=int(input())
#tot=0
t=1

for __ in range(t):
    #n=int(input())
    #n,p=map(int,input().split())
    s1=input()

    s2=''
    for i in range(len(s1)-2):
        if s1[i]==s1[i+1]==s1[i+2]:
            continue
        s2+=s1[i]

    s2+=s1[-2]
    s2+=s1[-1]
    ans=''
    ch=4
    #print(s2)
    for i in range(len(s2)-1):
        if s2[i]==s2[i+1]:
            if ch!=-1:
                ans+=s2[i]
                ch=4
            else:
                continue
            ch=-2
        else:
            ans+=s2[i]
            ch+=1
    ans+=s2[-1]
    print(ans)


import sys
import math as mt
#input=sys.stdin.buffer.readline
#import bisect
mod=1000000007
#t=int(input())
#tot=0
t=1

for __ in range(t):
    #n=int(input())
    #n,p=map(int,input().split())
    s=input()
    s1=list(s)
    s2=''
    for i in range(len(s1)-2):
        if s1[i]==s1[i+1]==s1[i+2]:
            continue
        s2+=s1[i]

    s2+=s1[-2]
    s2+=s1[-1]
    ans=''
    ch=4
    #print(s2)
    for i in range(len(s2)-1):
        if s2[i]==s2[i+1]:
            if ch!=-1:
                ans+=s2[i]
                ch=4
            else:
                continue
            ch=-2
        else:
            ans+=s2[i]
            ch+=1
    ans+=s2[-1]
    print(ans)


import sys
#import math as mt
#input=sys.stdin.buffer.readline
#import bisect

#t=int(input())
#tot=0
t=1

for __ in range(t):
    #n=int(input())
    #n,p=map(int,input().split())
    s1=input()
    ans=[]
    ch=4
    for i in range(len(s1)):
        if i<=(len(s1)-3):
            if s1[i]==s1[i+1]==s1[i+2]:
                continue
        if i<=(len(s1)-2):
            if s1[i]==s1[i+1]:
                if ch!=-1:
                    ans.append(s1[i])
                    ch=4
                else:
                    continue
                ch=-2
            else:
                ans.append(s1[i])
                if ch==-2:
                    ch+=1
                else:
                    ch=4

    ans.append(s1[-1])
    print(''.join(ans))

    #print(ans)


import sys
import math as mt
#input=sys.stdin.buffer.readline
#import bisect
mod=1000000007
#t=int(input())
#tot=0
t=1

for __ in range(t):
    #n=int(input())
    #n,p=map(int,input().split())
    s1=input()

    s2=''
    for i in range(len(s1)-2):
        if s1[i]==s1[i+1]==s1[i+2]:
            continue
        s2+=s1[i]

    s2+=s1[-2]
    s2+=s1[-1]
    ans=''
    ch=4
    #print(s2)
    for i in range(len(s2)-1):
        if s2[i]==s2[i+1]:
            if ch!=-1:
                ans+=s2[i]
                ch=4
            else:
                continue
            ch=-2
        else:
            ans+=s2[i]
            if ch==-2:
                ch+=1
            else:
                ch=4
    ans+=s2[-1]
    print(ans)


s = input()
fs = []
f = 0
fs.append(s[0])
e = s[0]
l = 0
for i in range(1,len(s)):
	if(s[i] == e and f == 0):
		if(i>=2 and (fs[l-1] != fs[l-2])):
			f = 1
			fs.append(s[i])
			l+=1
			e = s[i]
		elif(i<2):
			fs.append(s[i])
			l+=1
	elif(s[i] != e):
		f = 0
		fs.append(s[i])
		l+=1
		e = s[i]

for i in range(len(fs)):
	print(fs[i],end = "")


s = input()
fs = []
f = 0
fs.append(s[0])
e = s[0]
l = 0
for i in range(1,len(s)):
	if(s[i] == e and f == 0):
		if(i>2 and (fs[l-1] != fs[l-2])):
			f = 1
			fs.append(s[i])
			l+=1
			e = s[i]
		elif(i<2):
			fs.append(s[i])
			l+=1
	elif(s[i] != e):
		f = 0
		fs.append(s[i])
		l+=1
		e = s[i]

for i in range(len(fs)):
	print(fs[i],end = "")


n=input()
ar=['']
pair=0
for i in n:
    if ar[-1]==i and pair==0:
        ar.append(i)
        pair=2
    elif ar[-1]!=i:
        ar.append(i)
        if pair>0:
            pair-=1
s=''
s+=''.join(i for i in ar if i!='')
print(s)


n=input()
ar=['']
count=0
for i in n:
    if ar[-1]==i and count<1:
        ar.append(i)
        count+=1
    else:
        if ar[-1]!=i:
            ar.append(i)

s=''
s+=''.join(i for i in ar if i!='')
print(s)


n=input()
ar=['']
for i in n:
    if i==ar[-1] and len(ar)!=0:
        pass
    else:
        ar.append(i)
s=''
s+=''.join(str(i) for i in ar if i!='')
print(s)


from sys import stdin, stdout

def main(s):
    segs = []
    cur = [0, 0, s[0]]
    for i, c in enumerate(s[1:]):
        if cur[2] != c:
            segs.append(cur)
            cur = [i, i, c]
            prev = c
        else:
            cur[1] += 1
    segs.append(cur)

    for seg in segs:
        if seg[1] - seg[0] + 1 > 2:
            seg[1] = seg[0] + 1

    for i in range(len(segs) - 1):
        sega = segs[i]
        segb = segs[i + 1]
        if sega[1] - sega[0] + 1 == 2 and segb[1] - segb[0] + 1 == 2:
            segb[1] = segb[0]

    for seg in segs:
        stdout.write('{}'.format(seg[2] * (seg[1] - seg[0] + 1)))
    stdout.write("\n")

main(stdin.readline().strip())


s = list(input())

sans = []
for i in s:
    if len(sans) == 0:
        sans.append((i, 1))
    else:
        tmp, cnt = sans.pop()
        if tmp == i:
            sans.append((i, cnt + 1))
        else:
            sans.append((tmp, cnt))
            sans.append((i, 1))

sans = list(map(lambda x: [x[0], 1] if x[1] == 1 else [x[0], 2], sans))
for i in range(len(sans) - 1):
    if sans[i][1] == 2 and sans[i + 1][1] == 2:
        sans[i + 1][1] = 1
print("".join(map(lambda x: x[0] * x[1], sans)))


s = list(input())

sans = []
for i in s:
    if len(sans) == 0:
        sans.append((i, 1))
    else:
        tmp, cnt = sans.pop()
        if tmp == i:
            sans.append((i, cnt + 1))
        else:
            sans.append((tmp, cnt))
            sans.append((i, 1))

sans = list(map(lambda x: [x[0], 1] if x[1] == 1 else [x[0], 2], sans))

for i in range(len(sans) - 1):
    if sans[i][1] == 2 and sans[i + 1][1] == 2:
        sans[i][1] = 1
print("".join(map(lambda x: x[0] * x[1], sans)))


s = input()
fs = []
f = 0
fs.append(s[0])
e = s[0]
l = [0]
for i in range(1,len(s)):
	if(s[i] == e and f == 0):
		f = 1
		fs.append(s[i])
	elif(s[i] != e):
		f = 0
		fs.append(s[i])
		e = s[i]
for i in range(1,len(fs)):
	if(fs[i-1] == fs[i]):
		l.append(1)
	else:
		l.append(0)
i = 0
while(i<len(l)-2):
	if(l[i] == 1):
		if(l[i+2] == 1):
			fs.pop(i+2)
			l.pop(i+2)
			i+=2
		else:
			i+=1
	else:
		i+=1
for i in range(len(fs)):
	print(fs[i],end = "")


#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase
def vsInput():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
def value():
    return map(int,input().split())
def array():
    return [int(i) for i in input().split()]

#-------------------------code---------------------------#
#vsInput()

s=input()
n=len(s)
i=0
t=''
while(i<n):
    c=1
    while(i+1<n and s[i]==s[i+1]):
        c+=1
        i+=1
    t+=s[i]
    if(c>1):
        t+=s[i]
    i+=1
t=list(t)
#print(t)
for i in range(0,len(t)-4+1):
    #print(i)
    if(t[i]==t[i+1] and t[i+2]==t[i+3]):
        t[i+2]=-1
for i in t:
    if(i!=-1):
        print(i,end="")


#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase
def vsInput():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
def value():
    return map(int,input().split())
def array():
    return [int(i) for i in input().split()]

#-------------------------code---------------------------#
#vsInput()

s=input()
n=len(s)
i=0
t=[]
while(i<n):
    c=1
    while(i+1<n and s[i]==s[i+1]):
        c+=1
        i+=1
    t.append(s[i])
    if(c>1):
        t.append(s[i])
    i+=1
#print(t)
for i in range(0,len(t)-4+1):
    #print(i)
    if(t[i]==t[i+1] and t[i+2]==t[i+3]):
        t[i+2]=-1
for i in t:
    if(i!=-1):
        print(i,end="")


s = list(input())
l = []
if len(s)<=2:
    print(''.join(s))
elif len(s)==3:
    if s[0]==s[1]==s[2]:
        s = s[:2]
    print(''.join(s))
else:
    c = 0
    l.append(s[0])
    l.append(s[1])
    c+=2
    if l[0]==l[1]==l[2]:
        pass
    else:
        l.append(s[2])
        c+=1
    for i in range(3,len(s)):
        #print(l)
        if s[i]!=l[-1]:
            l.append(s[i])
        elif l[-1]==l[-2]==s[i]:
            pass
        elif c>=3 and l[-2]==l[-3] and s[i]==l[-1] :
            pass
        else:
            l.append(s[i])
    print(''.join(l))


s = list(input())
l = []
if len(s)<=2:
    print(''.join(s))
elif len(s)==3:
    if s[0]==s[1]==s[2]:
        s = s[:2]
    print(''.join(s))
else:
    c = 0
    l.append(s[0])
    l.append(s[1])
    c+=2
    if l[0]==l[1]==s[2]:
        pass
    else:
        l.append(s[2])
        c+=1
    for i in range(3,len(s)):
        #print(l)
        if s[i]!=l[-1]:
            l.append(s[i])
            c+=1
        elif l[-1]==l[-2]==s[i]:
            pass
        elif c>=3 and l[-2]==l[-3] and s[i]==l[-1] :
            pass
        else:
            l.append(s[i])
            c+=1
    print(''.join(l))


s = list(input())
l = []
if len(s)<=2:
    print(''.join(s))
elif len(s)==3:
    if s[0]==s[1]==s[2]:
        s = s[:2]
    print(''.join(s))
else:
    c = 0
    l.append(s[0])
    l.append(s[1])
    c+=2
    if l[0]==l[1]==s[2]:
        pass
    else:
        l.append(s[2])
        c+=1
    for i in range(3,len(s)):
        #print(l)
        if s[i]!=l[-1]:
            l.append(s[i])
        elif l[-1]==l[-2]==s[i]:
            pass
        elif c>=3 and l[-2]==l[-3] and s[i]==l[-1] :
            pass
        else:
            l.append(s[i])
    print(''.join(l))


# import sys

# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')

s = input()
res = []
n = len(s)
i = 0
prevTwo = False
while i < n:
    cnt = 0
    curr = s[i]
    while i < n and s[i] == curr:
        i += 1
        cnt += 1
    if prevTwo:
        prevTwo = False
        res.append(curr)
    else:
        prevTwo = True if cnt > 1 else False
        res.append(curr*min(cnt, 2))
print(''.join(res))


import sys

sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')

s = input()
res = []
n = len(s)
i = 0
prevTwo = False
while i < n:
    cnt = 0
    curr = s[i]
    while i < n and s[i] == curr:
        i += 1
        cnt += 1
    if prevTwo:
        prevTwo = False
        res.append(curr)
    else:
        prevTwo = True if cnt > 1 else False
        res.append(curr*min(cnt, 2))
print(''.join(res))


# s = input()
s = ''.join(['sshh'] * 50000)
to_be_removed = []
cur_char = s[0]
cur_char_cnt = 1
for i, c in enumerate(s):
    if i == 0:
        continue
    if c == cur_char:
        cur_char_cnt += 1
        if cur_char_cnt >= 3:
            to_be_removed.append(i)
    else:
        cur_char = c
        cur_char_cnt = 1

s = [c for c in s]
for i in to_be_removed:
    s[i] = ''
s = ''.join(s)
islands_of_2 = []
cur_char = s[0]
cur_char_cnt = 1
for i, c in enumerate(s):
    if i == 0:
        continue
    if c == cur_char:
        cur_char_cnt += 1
        if cur_char_cnt == 2:
            islands_of_2.append(i)
    else:
        cur_char = c
        cur_char_cnt = 1

if islands_of_2:
    island_to_remove = []
    prev_island = None
    for island in islands_of_2:
        if prev_island and prev_island + 2 == island:
            island_to_remove.append(island)
            prev_island = None
            continue
        else:
            prev_island = island

    s = [c for c in s]
    for i in island_to_remove:
        s[i] = ''

print(''.join(s))


s = input()
# s = ''.join(['sshh'] * 50000)
to_be_removed = []
cur_char = s[0]
cur_char_cnt = 1
for i, c in enumerate(s):
    if i == 0:
        continue
    if c == cur_char:
        cur_char_cnt += 1
        if cur_char_cnt >= 3:
            to_be_removed.append(i)
    else:
        cur_char = c
        cur_char_cnt = 1

s = [c for c in s]
for i in to_be_removed:
    s[i] = ''
s = ''.join(s)
islands_of_2 = []
cur_char = s[0]
cur_char_cnt = 1
for i, c in enumerate(s):
    if i == 0:
        continue
    if c == cur_char:
        cur_char_cnt += 1
        if cur_char_cnt == 2:
            islands_of_2.append(i)
    else:
        cur_char = c
        cur_char_cnt = 1

if islands_of_2:
    island_to_remove = []
    prev_island = None
    for island in islands_of_2:
        if prev_island and prev_island + 2 == island:
            island_to_remove.append(island)
            prev_island = None
            continue
        else:
            prev_island = island

    s = [c for c in s]
    for i in island_to_remove:
        s[i] = ''

print(''.join(s))


s = input()

to_be_removed = []
cur_char = s[0]
cur_char_cnt = 1
for i, c in enumerate(s):
    if i == 0:
        continue
    if c == cur_char:
        cur_char_cnt += 1
        if cur_char_cnt >= 3:
            to_be_removed.append(i)
    else:
        cur_char = c
        cur_char_cnt = 1

s = [s[i] for i in range(len(s)) if i not in set(to_be_removed)]

islands_of_2 = []
cur_char = s[0]
cur_char_cnt = 1
for i, c in enumerate(s):
    if i == 0:
        continue
    if c == cur_char:
        cur_char_cnt += 1
        if cur_char_cnt == 2:
            islands_of_2.append(i)
    else:
        cur_char = c
        cur_char_cnt = 1

if islands_of_2:
    island_to_remove = []
    prev_island = None
    for island in islands_of_2:
        if prev_island and prev_island + 2 == island:
            island_to_remove.append(island)
            prev_island = None
            continue
        else:
            prev_island = island

    s = [s[i] for i in range(len(s)) if i not in set(island_to_remove)]

print(''.join(s))


s = input()

to_be_removed = []
cur_char = s[0]
cur_char_cnt = 1
for i, c in enumerate(s):
    if i == 0:
        continue
    if c == cur_char:
        cur_char_cnt += 1
        if cur_char_cnt >= 3:
            to_be_removed.append(i)
    else:
        cur_char = c
        cur_char_cnt = 1

s = ''.join([s[i] for i in range(len(s)) if i not in set(to_be_removed)])

islands_of_2 = []
cur_char = s[0]
cur_char_cnt = 1
for i, c in enumerate(s):
    if i == 0:
        continue
    if c == cur_char:
        cur_char_cnt += 1
        if cur_char_cnt == 2:
            islands_of_2.append(i)
    else:
        cur_char = c
        cur_char_cnt = 1

if islands_of_2:
    island_to_remove = []
    prev_island = None
    for island in islands_of_2:
        if prev_island and prev_island + 2 == island:
            island_to_remove.append(island)
            prev_island = None
            continue
        else:
            prev_island = island

    s = ''.join([s[i] for i in range(len(s)) if i not in set(island_to_remove)])

print(s)


import os
import sys
from io import BytesIO, IOBase
import math

def main():
    pass

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

import os
import sys
from io import BytesIO, IOBase

def main():
    pass

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

s=input()
n=len(s)
i=1
cco=1
cch=s[0]
ans=[s[0]]
while(i<n):
    if(s[i]==cch):
        if(cco<2):
            if(s[i]==cch):
                ans.append(s[i])
                cco+=1
    else:
        cco=1
        cch=s[i]
        ans.append(s[i])
    i+=1
#print(ans)
i=1
ansf=[]
cdc=0
while(i<(len(ans))):
    if(ans[i]!=ans[i-1]):
        ansf.append(ans[i-1])
        i+=1
    else:
        if(cdc==1):
            ansf.append(ans[i])
            cdc=0
            i+=2
        else:
            ansf.append(ans[i])
            ansf.append(ans[i-1])
            cdc+=1
            i+=2
if(ans[-1]!=ans[-2]):
    ansf.append(ans[-1])
print("".join(ansf))


import os
import sys
from io import BytesIO, IOBase
import math

def main():
    pass

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

import os
import sys
from io import BytesIO, IOBase

def main():
    pass

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

s=input()
n=len(s)
i=1
cco=1
cch=s[0]
ans=[s[0]]
while(i<n):
    if(s[i]==cch):
        if(cco<2):
            if(s[i]==cch):
                ans.append(s[i])
                cco+=1
    else:
        cco=1
        cch=s[i]
        ans.append(s[i])
    i+=1
#print(ans)
i=1
ansf=[]
cdc=0
while(i<(len(ans))):
    if(ans[i]!=ans[i-1]):
        ansf.append(ans[i-1])
        i+=1
        cdc=0
    else:
        if(cdc==1):
            ansf.append(ans[i])
            cdc=0
            i+=2
        else:
            ansf.append(ans[i])
            ansf.append(ans[i-1])
            cdc+=1
            i+=2
if(ans[-1]!=ans[-2]):
    ansf.append(ans[-1])
print("".join(ansf))


import os
import sys
from io import BytesIO, IOBase
import math

def main():
    pass

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

import os
import sys
from io import BytesIO, IOBase

def main():
    pass

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

s=input()
n=len(s)
i=1
cco=1
cch=s[0]
ans=[s[0]]
if(n==1):
    print(s)
else:
    while(i<n):
        if(s[i]==cch):
            if(cco<2):
                if(s[i]==cch):
                    ans.append(s[i])
                    cco+=1
        else:
            cco=1
            cch=s[i]
            ans.append(s[i])
        i+=1
    #print(ans)
    i=1
    ansf=[]
    cdc=0
    while(i<(len(ans))):
        if(ans[i]!=ans[i-1]):
            ansf.append(ans[i-1])
            i+=1
            cdc=0
        else:
            if(cdc==1):
                ansf.append(ans[i])
                cdc=0
                i+=2
            else:
                ansf.append(ans[i])
                ansf.append(ans[i-1])
                cdc+=1
                i+=2
    if(ans[-1]!=ans[-2]):
        ansf.append(ans[-1])
    print("".join(ansf))


s = list(input())
n = len(s)
flag = 0
for i in range(1, n):
    if s[i] == s[i - 1] and flag == 0:
        flag = 1
    elif s[i] == s[i - 1] and (flag == 1 or flag == 3):
        s[i - 1] = ''
    elif s[i] != s[i - 1] and (flag == 1 or flag == 3):
        if flag == 3:
            flag = 0
        else:
            flag = 2
    elif s[i] == s[i - 1] and flag == 2:
        s[i - 1] = ''
        flag = 3
print(*s, sep='')


s = list(input())
n = len(s)
flag = 0
for i in range(1, n):
    if s[i] == s[i - 1] and flag == 0:
        flag = 1
    elif s[i] == s[i - 1] and (flag == 1 or flag == 3):
        s[i - 1] = ''
    elif s[i] != s[i - 1] and (flag == 1 or flag == 3):
        if flag == 3:
            flag = 0
        else:
            flag = 2
    elif s[i] != s[i - 1] and flag == 2:
        flag = 0
    elif s[i] == s[i - 1] and flag == 2:
        s[i - 1] = ''
        flag = 3
print(*s, sep='')


import sys
from math import sqrt
input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

s=input()
length = len(s)
leftIdx = 0
res = ''
isIdentical = False
isPrevIdentical = False
_list = []
while leftIdx < length:
    cnt = 1
    ch = s[leftIdx]
    for i in range(leftIdx+1,length):
        if ch == s[i]:
            cnt+=1
        else:
            break
    leftIdx+=cnt
    _list.append([ch,cnt])
for pair in _list:
    if pair[1]>3:
        pair[1]=2
for i in range(len(_list)-1):
    if _list[i][1]==2:
        _list[i+1][1] = 1
for pair in _list:
    for i in range(pair[1]):
        print(pair[0],end='')
print()


import sys
from math import sqrt
input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

s=input()
length = len(s)
leftIdx = 0
res = ''
_list = []
while leftIdx < length:
    cnt = 1
    ch = s[leftIdx]
    for i in range(leftIdx+1,length):
        if ch == s[i]:
            cnt+=1
        else:
            break
    leftIdx+=cnt
    _list.append([ch,cnt])
for pair in _list:
    if pair[1]>=3:
        pair[1]=2
for i in range(len(_list)-1):
    if _list[i][1]==2:
        _list[i+1][1] = 1
for pair in _list:
    for i in range(pair[1]):
        print(pair[0],end='')


import sys
from math import sqrt
input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

s=input()
length = len(s)
s+='*'
leftIdx = 0
rightIdx = 1
res = ''
isIdentical = False
isPrevIdentical = False
while leftIdx < length and rightIdx < len(s):
    if s[leftIdx] != s[rightIdx]:
        if isIdentical:
            if isPrevIdentical:
                res+=s[leftIdx]
            else:
                res+=s[leftIdx]+s[leftIdx]
            isPrevIdentical = True
            isIdentical = False
        else:
            isPrevIdentical = False
            res+=s[leftIdx]
        leftIdx = rightIdx
        rightIdx = leftIdx+1
    else:
        isIdentical = True
        rightIdx += 1
print(res)


import sys
from math import sqrt
input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

s=input()
length = len(s)
leftIdx = 0
res = ''
_list = []
while leftIdx < length:
    cnt = 1
    ch = s[leftIdx]
    for i in range(leftIdx+1,length):
        if ch == s[i]:
            cnt+=1
        else:
            break
    leftIdx+=cnt
    _list.append([ch,cnt])
for pair in _list:
    if pair[1]>=3:
        pair[1]=2
for i in range(len(_list)-1):
    if _list[i][1]==2:
        _list[i+1][1] = 1
for pair in _list:
    for i in range(pair[1]):
        res+=pair[0]
print(res)


class GoodString:
    def __init__(self):
        self.string = []
        self.prev = []
        self.current = []

    def appendChar(self,char):
        # print(char,self.string,self.prev,self.current)
        if len(self.current) == 0:
            self.current.append(char)
        else:
            if self.current[-1] != char:
                for ii in range(len(self.prev)):
                    self.string.append(self.prev[ii])
                self.prev = self.current
                self.current = [char]
            elif len(self.current)==2:
                pass
            else:
                if len(self.prev)==2:
                    pass
                else:
                    self.current.append(char)

    def getString(self):
        return [self.string,self.prev,self.current]

def main():
    string = input()
    goodString =  GoodString()
    for i in range(len(string)):
        goodString.appendChar(string[i])
    sol = goodString.getString()
    for i in range(len(sol)):
        for j in range(len(sol[i])):
            print(sol[i][j],end="")

main()


class GoodString:
    def __init__(self):
        self.string = []
        self.prev = []
        self.current = []

    def appendChar(self,char):
        # print(char,self.string,self.prev)
        if len(self.current) == 0:
            self.current.append(char)
        else:
            if self.current[-1] != char:
                self.string = self.string + self.prev
                self.prev = self.current
                self.current = [char]
            elif len(self.current)==2:
                pass
            else:
                if len(self.prev)==2:
                    pass
                else:
                    self.current.append(char)

    def getString(self):
        return self.string+self.prev+self.current

def main():
    string = input()
    goodString =  GoodString()
    for i in range(len(string)):
        goodString.appendChar(string[i])
    sol = goodString.getString()
    for i in sol:
        print(i,end="")

main()


class GoodString:
    def __init__(self):
        self.string = []
        self.prev = []
        self.current = []

    def appendChar(self,char):
        # print(char,self.string,self.prev)
        if len(self.current) == 0:
            self.current.append(char)
        else:
            if self.current[-1] != char:
                self.string = self.string + self.prev
                self.prev = self.current
                self.current = [char]
            elif len(self.current)==2:
                pass
            else:
                if len(self.prev)==2:
                    pass
                else:
                    self.current.append(char)

    def getString(self):
        sol = ""
        sol = sol+"".join(self.string)
        sol = sol + "".join(self.prev)
        sol = sol + "".join(self.current)
        return sol

def main():
    string = input()
    goodString =  GoodString()
    for i in range(len(string)):
        goodString.appendChar(string[i])
    print(goodString.getString())

main()


# import sys

# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')

s = input()
res = []
n = len(s)
i = 0
prevTwo = False
while i < n:
    cnt = 0
    curr = s[i]
    while i < n and s[i] == curr:
        i += 1
        cnt += 1
    if prevTwo:
        prevTwo = False
        res.append(curr)
    else:
        prevTwo = True if cnt > 1 else False
        res.append(curr*min(cnt, 2))
print(''.join(res))


s = input().rstrip()

n = len(s)
stack = []
for ch in s:
    if len(stack) <= 1 or not stack[-1] == stack[-2] == ch:
        stack.append(ch)
s = ''.join(stack)
stack = []
for ch in s:
    if len(stack) <= 2 or not (stack[-3] == stack[-2] and stack[-1] == ch):
        stack.append(ch)
print(''.join(stack))


s = input()
pre, ls, ans, last = [s[0], 1], len(s), [s[0]], 0

for i in range(1, ls):
    if s[i] == pre[0]:
        if last == 2 or pre[1] >= 2:
            continue
        else:
            ans.append(s[i])
            pre[1] += 1
    else:
        last = pre[1]
        pre = [s[i], 1]
        ans.append(s[i])

# print(last, pre)
print(''.join(ans))


s=input()
count=0
n=len(s)
if(n==1 or n==2):
    print(s)
else:
    res=[]
    last=s[0]
    for i in range(n):
        if(s[i]==last and count==0):
            count=1
            res.append(s[i])
        elif(s[i]==last and count==1):
            count=2
            res.append(s[i])
        elif(s[i]!=last and count==1):
            res.append(s[i])
        elif(s[i]!=last and count==2):
            count=3
            res.append(s[i])
        elif(s[i]!=last and count==3):
            count=1
            res.append(s[i])
        last=s[i]
print(''.join(res))


s=input()
count=0
n=len(s)
if(n==1 or n==2):
    print(s)
else:
    res=''
    last=s[0]
    for i in range(n):
        if(s[i]==last and count==0):
            count=1
            res+=s[i]
        elif(s[i]==last and count==1):
            count=2
            res+=s[i]
        elif(s[i]!=last and count==1):
            res+=s[i]
        elif(s[i]!=last and count==2):
            count=3
            res+=s[i]
        elif(s[i]!=last and count==3):
            count=1
            res+=s[i]
        last=s[i]
print(''.join(res))


s=input()
count=0
n=len(s)
res=[]
last=s[0]
for i in range(n):
    if(s[i]==last and count==0):
        count=1
        res.append(s[i])
    elif(s[i]==last and count==1):
        count=2
        res.append(s[i])
    elif(s[i]!=last and count==1):
        res.append(s[i])
    elif(s[i]!=last and count==2):
        count=3
        res.append(s[i])
    elif(s[i]!=last and count==3):
        count=1
        res.append(s[i])
    last=s[i]
print(''.join(res))


s=input()
ans=''
cur=0
l=len(s)
for i in range(l):
    flag=1

    if cur>=2:
        if s[i]==ans[cur-1] and ans[cur-1]==ans[cur-2] :
            flag=0

    if cur>=3:
        if ans[cur-1]==s[i] and ans[cur-3]==ans[cur-2] :
            flag=0

    if flag:
        ans+=s[i]
        cur+=1

print(ans)


s=input()
ans=''
cur=0
for i in s:
    flag=1
    if cur>=2:
        if i==ans[cur-1] and ans[cur-1]==ans[cur-2] :
            flag=0

    if cur>=3:
        if ans[cur-1]==i and ans[cur-3]==ans[cur-2] :
            flag=0

    if flag:
        ans+=i
        cur+=1

print(ans)


s=input()
ans=''
cur=0
for i in range(len(s)):

    if cur>=2:
        if s[i]==ans[cur-1] and ans[cur-1]==ans[cur-2] :
            continue

    if cur>=3:
        if ans[cur-1]==s[i] and ans[cur-3]==ans[cur-2] :
            continue

    ans+=s[i]
    cur+=1

print(ans)


s=input()
ans=''
cur=0
for i in range(len(s)):
    flag=1

    if cur>=2:
        if s[i]==ans[cur-1] and ans[cur-1]==ans[cur-2] :
            flag=0

    if cur>=3:
        if ans[cur-1]==s[i] and ans[cur-3]==ans[cur-2] :
            flag=0

    if flag:
        ans+=s[i]
        cur+=1

print(ans)


s=input()
ans=''
cur=0
for i in range(len(s)):

    if cur>=2:
        if s[i]==ans[cur-1] and ans[cur-1]==ans[cur-2] :
            continue

    if cur>=3:
        if ans[cur-1]==s[i] and ans[cur-3]==ans[cur-2] :
            continue

    ans.join(s[i])
    cur+=1

print(ans)


s=input()
ans=''

for i in range(len(s)):
    flag=1
    cur=len(ans)

    if cur>=2:
        if s[cur-1]==s[cur-2] and s[i]==s[cur-1]:
            flag=0

    if cur>=3:
        if s[cur-3]==s[cur-2] and s[cur-1]==s[i]:
            flag=0

    if flag:
        ans+=s[i]

print(ans)


s=input()
ans=[]
cur=0
for i in range(len(s)):

    if cur>=2:
        if s[i]==ans[cur-1] and ans[cur-1]==ans[cur-2] :
            continue

    if cur>=3:
        if ans[cur-1]==s[i] and ans[cur-3]==ans[cur-2] :
            continue

    ans.append(s[i])
    cur+=1

print("".join(ans))


#include <bits/stdc++.h>
using namespace std;
int pos=0;
char s[1000005];
void print(int d)
{for (int i=1;i<=d;i++)
{printf ("+");}
printf (">\n");
}
int get()
{int x=0;
while (s[pos]>='0'&&s[pos]<='9') {x=x*10+s[pos]-48;pos++;}
return x;
}
int main (){
	char c;int d;
	scanf ("%s",s);
	int len=strlen(s);
	d=get();
	print(d);
	while (pos<len)
	{c=s[pos];pos++;
	d=get();print(d);
	printf ("<[<%c>-]<\n",c);
	}
	printf ("++++++++++++++++++++++++++++++++++++++++++++++++.\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int pos=0;
char s[1000005];
void print(int d)
{for (int i=1;i<=d;i++)
{printf ("+");}
printf (">\n");
}
int get()
{int x=0;
while (s[pos]>='0'&&s[pos]<='9') {x=x*10+s[pos]-48;pos++;}
return x;
}
int main (){
	char c;int d;
	scanf ("%s",s);
	int len=strlen(s);
	d=get();
	print(d);
	while (pos<len)
	{c=s[pos];pos++;
	d=get();print(d);
	printf ("<[<%c>-]<\n",c);
	pos++;
	}
	printf ("++++++++++++++++++++++++++++++++++++++++++++++++.\n");
	return 0;
}


/*
ID: barish21
LANG: C++14
TASK: test
*/

/****Author: Barish Namazov****/
#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <stack>
#include <cstring>
#include <cmath>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sz(s) (intt)s.size()

#define ms0(arr) memset(arr,0,sizeof arr)
#define ms63(arr) memset(arr,63,sizeof arr)

#define forn(i,a,b) for(intt i=a;i<=b;i++)
#define rofn(i,a,b) for(intt i=a;i>=b;i--)
#define setf(it,myset) for(set<intt>::iterator it=myset.begin();it!=myset.end();it++)

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define VI vector<intt>
#define PII pair<intt,intt>
#define VPII vector< PII >

#define posl(ch) (int)(ch-'a'+1)
#define posL(ch) (int)(ch-'A'+1)

#define IO ios_base::sync_with_stdio(false);cin.tie();
/***************/

/***Additional Functions***/
intt powmod(intt a,intt b,intt mod){intt res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
intt gcd(intt a,intt b){return __gcd(a, b);}
intt lcm(intt a,intt b){return a*b/gcd(a,b);}
intt is_prime(intt n){if(n==1)return 0;if(n==2)return 1;if(n%2==0)return 0;for(intt i=3;i<=sqrt(n);i+=2)if(n%i==0)return 0;return 1;}
intt is_integer(double n){if(floor(n)==ceil(n))return 1;return 0;}

intt sto_int(string s){stringstream ss(s);intt n;ss>>n;return n;}
string to_string(intt n){stringstream ss;ss<<n;string s=ss.str();return s;}

/**************************/

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    IO;
    intt a, flag, operation;
    char ch = 92;
    string s;
    cin>>s;
    forn (i, 0, s.size() - 1)
    {
        if (s[i]>='0' && s[i]<='9')
            a = a*10 + s[i] - 48;
        else
        {
            while (a--)
                cout<<'+';
            a=0;
            cout<<">\n";
            flag++;
            if (flag>1)
            {
                if (operation=='+') cout<<"<<[->+<]>>\n";
                else
                {
                    cout << "<[<->-]<\n";
                    cout << "[->+<]>>\n";
                }
            }
            operation = s[i];
        }
    }
    while (a --)
    {
        cout << '+';
    }
    a = 0;
    cout << ">\n";
    flag ++;
    if (flag>1)
    {
        if (operation=='+') cout<<"<<[->+<]>>\n";
        else
        {
            cout<<"<[<->-]<\n";
            cout<<"[->+<]>>\n";
        }
    }
    cout<<"<";
    cout<<">>++++++++++<<[->+>-[>+>>]>[+[-<+>]>+>>]<<<<<<]>>[-]>>>++++++++++<[->-[>+>>]>[+[-<+>]>+>>]<<<<<]>[-]>>[>++++++[-<++++++++>]<.<<+>+>[-]]<[<[->-<]++++++[->++++++++<]>.[-]]<<++++++[-<++++++++>]<.[-]<<[-<+>]<";
    return 0;
}


/*
ID: barish21
LANG: C++14
TASK: test
*/

/****Author: Barish Namazov****/
#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <stack>
#include <cstring>
#include <cmath>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sz(s) (intt)s.size()

#define ms0(arr) memset(arr,0,sizeof arr)
#define ms63(arr) memset(arr,63,sizeof arr)

#define forn(i,a,b) for(intt i=a;i<=b;i++)
#define rofn(i,a,b) for(intt i=a;i>=b;i--)
#define setf(it,myset) for(set<intt>::iterator it=myset.begin();it!=myset.end();it++)

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define VI vector<intt>
#define PII pair<intt,intt>
#define VPII vector< PII >

#define posl(ch) (int)(ch-'a'+1)
#define posL(ch) (int)(ch-'A'+1)

#define IO ios_base::sync_with_stdio(false);cin.tie();
/***************/

/***Additional Functions***/
intt powmod(intt a,intt b,intt mod){intt res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
intt gcd(intt a,intt b){return __gcd(a, b);}
intt lcm(intt a,intt b){return a*b/gcd(a,b);}
intt is_prime(intt n){if(n==1)return 0;if(n==2)return 1;if(n%2==0)return 0;for(intt i=3;i<=sqrt(n);i+=2)if(n%i==0)return 0;return 1;}
intt is_integer(double n){if(floor(n)==ceil(n))return 1;return 0;}

intt sto_int(string s){stringstream ss(s);intt n;ss>>n;return n;}
string to_string(intt n){stringstream ss;ss<<n;string s=ss.str();return s;}

/**************************/

int main()
{
    IO;
    intt a = 0,t = 0,oper = 0;
char c=92;
string ch, s;

    cin>>s;
    forn(i, 0 ,s.size() - 1)
    {
        if (s[i]>='0' && s[i]<='9')

            a=a*10+s[i]-'0';

        else
        {
            while (a--)

                cout<<'+';
            a=0;
            cout<<">\n";
            t++;
            if (t>1)
            {
                if (oper=='+') cout<<"<<[->+<]>>\n";
                else
                {
                    cout<<"<[<->-]<\n";
                    cout<<"[->+<]>>\n";
                }
            }
            oper=s[i];
        }
    }
    while (a--)
    {
        cout<<'+';
    }
    a=0;
    cout<<">\n";
    t++;
    if (t>1)
    {
        if (oper=='+') cout<<"<<[->+<]>>\n";
        else
        {
            cout<<"<[<->-]<\n";
            cout<<"[->+<]>>\n";
        }
    }

    cout<<"<";
    cout<<">>++++++++++<<[->+>-[>+>>]>[+[-<+>]>+>>]<<<<<<]>>[-]>>>++++++++++<[->-[>+>>]>[+[-<+>]>+>>]<<<<<]>[-]>>[>++++++[-<++++++++>]<.<<+>+>[-]]<[<[->-<]++++++[->++++++++<]>.[-]]<<++++++[-<++++++++>]<.[-]<<[-<+>]<";

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int res=0;
	char c='+';
	while(c=='+'||c=='-')
	{
		char t='0';
		int a=0;
		while(t>='0'&&t<='9')
		{
			a=10*a+t-'0';
			t=getchar();
		}
		if(c=='-') a*=-1;
		res+=a;
		c=t;
	}
	while(res--) printf("+");
	printf(".\n");
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	char c='+';
	int res=0;
	while(c=='+'||c=='-')
	{
		char t='0';
		int a=0;
		while(t>='0'&&t<='9')
		{
			a=10*a+t-'0';
			t=getchar();
		}
		if(c=='+') res+=a;
		if(c=='-') res-=a;
		c=t;
	}
	if(res==0)
	{
		for(int j=0; j<'0'; ++j) printf("+");
		printf(".\n");
	}
	for(int i=100; i>0; i/=10)
	{
		if(res/i==0) continue;
		for(int j=0; j<res/i+'0'; ++j) printf("+");
		printf(".\n");
		res%=i;
	}
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	char c='+';
	int res=0;
	while(c=='+'||c=='-')
	{
		char t='0';
		int a=0;
		while(t>='0'&&t<='9')
		{
			a=10*a+t-'0';
			t=getchar();
		}
		if(c=='+') res+=a;
		if(c=='-') res-=a;
		c=t;
	}
	if(res==0)
	{
		for(int j=0; j<'0'; ++j) printf("+");
		printf(".\n");
	}

	bool print=0;
	for(int i=100; i>0; i/=10)
	{
		if(res/i>0) print=1;
		if(!print) continue;
		for(int j=0; j<res/i+'0'; ++j) printf("+");
		printf(".>\n");
		res%=i;
	}
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	char c='+';
	int res=0;
	while(c=='+'||c=='-')
	{
		char t='0';
		int a=0;
		while(t>='0'&&t<='9')
		{
			a=10*a+t-'0';
			t=getchar();
		}
		if(c=='+') res+=a;
		if(c=='-') res-=a;
		c=t;
	}
	for(int i=100; i>0; i/=10)
	{
		if(res/i==0) continue;
		for(int j=0; j<res/i+'0'; ++j) printf("+");
		printf(".\n");
		res%=i;
	}
}


//https://leetcode.com/problems/range-sum-query-2d-mutable/
//41  24
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>

#define INF 0x3f3f3f3f
#define INF64 0x3f3f3f3f3f3f3f3f
using namespace std;
long long MOD = 1e9+7;
long long M = 550;
int n, k, p, t0;
string st = "";
int main() {
    cin >> st;
    int ans = 0;
    int current = 0;
    int sign = 1;
    for (int i = 0; i < st.size(); i++) {
        if (st[i] == '+') {
            ans += sign * current;
            sign = 1;
            current = 0;
        } else if (st[i] == '-') {
            ans += sign * current;
            sign = -1;
            current = 0;
        } else {
            current = 10 * current + (st[i] - '0');
        }
    }
    ans += sign * current;
    if (ans < 0) {
        for (int i = 0; i < 45; i++) {
            cout << '+';
        }
        cout << ".>";
    }
    ans = abs(ans);
    string s = to_string(ans);
    for (char i: s) {
        for (int j = 0; j < (int)i; j++) {
            cout <<"+";
        }
        cout << ".>";
    }
}