#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <unordered_map>
#include <stdio.h>
#include <unordered_set>
#include <iterator>
#include <math.h>
#include <iomanip>
using namespace std;

int dfs(vector<int> arr, vector<bool> v, int i){
    if(v[i]) return i;
    v[i] = true;
    return dfs(arr, v, arr[i]-1);
}

int main(){
    int n;
    cin >> n;
    vector<int> arr(n);
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    for(int i = 0; i < n; i++){
        vector<bool> v(n, false);
        cout << dfs(arr, v, i)+1 << " ";
    }
    cout << endl;
}

// // https://codeforces.com/problemset/page/4?order=BY_SOLVED_DESC


#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <unordered_map>
#include <stdio.h>
#include <unordered_set>
#include <iterator>
#include <math.h>
#include <iomanip>
using namespace std;

int dfs(vector<int> arr, int i){
    vector<bool> v(arr.size(), false);
    while(1){
        if(v[i]) return i+1;
        v[i] = true;
        i = arr[i]-1;
    }
}

int main(){
    int n;
    cin >> n;
    vector<int> arr(n);
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    for(int i = 0; i < n; i++){
        cout << dfs(arr, i) << " ";
    }
    cout << endl;
}

// // https://codeforces.com/problemset/page/4?order=BY_SOLVED_DESC


#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <unordered_map>
#include <stdio.h>
#include <unordered_set>
#include <iterator>
#include <math.h>
#include <iomanip>
using namespace std;

int dfs(vector<int> arr, vector<bool> v, int i){
    if(v[i]) return i;
    v[i] = true;
    return dfs(arr, v, arr[i]-1);
}

int main(){
    int n;
    // cin >> n;
    scanf("%d", &n);
    vector<int> arr(n);
    for(int i = 0; i < n; i++){
        // cin >> arr[i];
        scanf("%d", &arr[i]);
    }
    for(int i = 0; i < n; i++){
        vector<bool> v(n, false);
        // cout << dfs(arr, v, i)+1 << " ";
        printf("%d", dfs(arr, v, i)+1);
        printf(" ");
    }
    printf("\n");
}

// // https://codeforces.com/problemset/page/4?order=BY_SOLVED_DESC


#include <iostream>
#include <set>
#include <vector>

void dfs(std::set<unsigned int> &set_, std::vector<unsigned int>& vec_,unsigned int source_) {
	if ( set_.find(source_) != set_.end() ){
		std::cout << source_ << " ";
		return;
	}
	set_.insert(source_);
	dfs(set_, vec_, vec_[source_]);
}

int main(int argc, char const *argv[])
{
	int n_;
	std::vector<unsigned int> vec_(n_+1, 0);
	std::cin>>n_;
	for (unsigned int i = 1;i <= n_ ; i++) {
		std::cin>>vec_[i];
	}
	for (unsigned int i = 1; i <= n_; i++) {
		std::set<unsigned int> set_;
		dfs(set_, vec_, i);
	}
	std::cout << std::endl;
	return 0;
}


#include <iostream>
#include <set>
#include <vector>

void dfs(std::set<unsigned int> &set_, std::vector<unsigned int>& vec_,unsigned int source_) {
	if ( set_.find(source_) != set_.end() ){
		std::cout << source_ << " ";
		return;
	}
	set_.insert(source_);
	dfs(set_, vec_, vec_[source_]);
}

int main(int argc, char const *argv[])
{
	int n_,tmp_;
	std::vector<unsigned int> vec_;
	vec_.push_back(0);
	std::cin>>n_;
	for (unsigned int i = 1;i <= n_ ; i++) {
		std::cin>>tmp_;
		vec_.push_back(tmp_);
	}
	for (unsigned int i = 1; i <= n_; i++) {
		std::set<unsigned int> set_;
		dfs(set_, vec_, i);
	}
	std::cout << std::endl;
	return 0;
}


#include <iostream>
#include <set>
#include <vector>

unsigned int dfs(std::set<unsigned int> &set_, std::vector<unsigned int>& vec_,unsigned int source_) {
	if ( set_.find(source_) != set_.end() ){
		return source_;
	}
	set_.insert(source_);
	dfs(set_, vec_, vec_[source_]);
}

int main(int argc, char const *argv[])
{
	int n_;
	std::vector<unsigned int> vec_(n_+1, 0);
	std::cin>>n_;
	for (unsigned int i = 1;i <= n_ ; i++) {
		std::cin>>vec_[i];
	}
	for (unsigned int i = 1; i <= n_; i++) {
		std::set<unsigned int> set_;
		std::cout << dfs(set_, vec_, i) << " ";
	}
	std::cout << std::endl;
	return 0;
}


#include <iostream>
#include <set>
#include <vector>

unsigned int dfs(std::set<unsigned int> &set_, std::vector<unsigned int>& vec_,unsigned int source_) {
	if ( set_.find(source_) != set_.end() ){
		return source_;
	}
	set_.insert(source_);
	return dfs(set_, vec_, vec_[source_]);
}

int main(int argc, char const *argv[])
{
	int n_;
	std::vector<unsigned int> vec_(n_+1, 0);
	std::cin>>n_;
	for (unsigned int i = 1;i <= n_ ; i++) {
		std::cin>>vec_[i];
	}
	for (unsigned int i = 1; i <= n_; i++) {
		std::set<unsigned int> set_;
		std::cout << dfs(set_, vec_, i) << " ";
	}
	std::cout << std::endl;
	return 0;
}


#include <iostream>
#include <set>
#include <vector>

unsigned int dfs(std::set<unsigned int> &set_, std::vector<unsigned int>& vec_,unsigned int source_) {
	if ( set_.find(source_) != set_.end() ){
		return source_;
	}
	set_.insert(source_);
	dfs(set_, vec_, vec_[source_]);
}

int main(int argc, char const *argv[])
{
	int n_;
	std::vector<unsigned int> vec_(n_+1, 0);
	std::cin>>n_;
	for (unsigned int i = 1;i <= n_ ; i++) {
		std::cin>>vec_[i];
	}
	for (unsigned int i = 1; i <= n_; i++) {
		std::set<unsigned int> set_;
		std::cout << dfs(set_, vec_, i) << " ";
	}
	//std::cout << std::endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

#define MAX 1005

vector<int> edge[MAX];
bool visited[MAX];
int bfs(int s)
{
    int v;
    queue<int> Q;
    Q.push(s);
    memset(visited,0,sizeof visited);
    while(!Q.empty())
    {
      int val = Q.front();
      Q.pop();
      for(int i=0;i<edge[val].size();i++)
      {
          v = edge[val][i];
          if(!visited[v])
          {
              visited[v] = 1;
              Q.push(v);
          }
      }
    }
    return v;
}
int main()
{
    int n;
    cin>>n;
    for(int i = 1 ; i <= n ; i++ )
    {
        int val;
        cin>>val;
        edge[i].pb(val);
    }
    for(int i =1; i <= n ; i++)
    {
        cout<<bfs(i)<<" ";
        if (i == n)
            cout<<"\n";
        else
            cout<<" ";
    }
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define clr(a, b) memset(a, b, sizeof(a))
#define Error(x) cout << #x << " = " << x << endl
#define iDEBUG freopen("in.txt", "r", stdin)
#define oDEBUG freopen("output.txt","w",stdout)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define hi cout<<"hi\n"
#define pow(x) (x)*(x)
typedef long long ll;

using namespace std;
int gcd(int m, int n) { if((0 == m) || (0 == n)){return 0;} while(m != n){ if(m > n){m -= n;}else{n -= m;} } return m; }
int lcm(int m, int n) { if((0 == m) || (0 == n)){return 0;} return (m / gcd(m, n)) * n; }

int main()
{_
    int n, k;
    char table[4][200];
    cin >> n >> k;
    for(int i=0; i<4; i++)
        for(int j=0; j<n; j++)
            table[i][j] = '.';
    if(k%2 == 0){
        cout << "YES\n";
        for(int i=1; i<=k/2; i++)
            table[1][i] = table[2][i] = '#';
        for(int i=0; i<4; i++){
            for(int j=0; j<n; j++)
                cout << table[i][j];
            cout << endl;
        }
    }else if(k%2==1 && k>n-2){
        //cout << "NO\n";
        cout << "YES\n";
        for(int i=1; i<=n-2; i++)
            table[1][i] = '#';
        for(int i=0; i<4; i++){
            for(int j=0; j<n; j++)
                cout << table[i][j];
            cout << endl;
        }
    }else{
        cout << "YES\n";
        for(int i=n/2-k/2; i<=n/2+k/2; i++)
            table[1][i] = '#';
        for(int i=0; i<4; i++){
            for(int j=0; j<n; j++)
                cout << table[i][j];
            cout << endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define clr(a, b) memset(a, b, sizeof(a))
#define Error(x) cout << #x << " = " << x << endl
#define iDEBUG freopen("in.txt", "r", stdin)
#define oDEBUG freopen("output.txt","w",stdout)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define hi cout<<"hi\n"
#define pow(x) (x)*(x)
typedef long long ll;

using namespace std;
int gcd(int m, int n) { if((0 == m) || (0 == n)){return 0;} while(m != n){ if(m > n){m -= n;}else{n -= m;} } return m; }
int lcm(int m, int n) { if((0 == m) || (0 == n)){return 0;} return (m / gcd(m, n)) * n; }

int main()
{_
    int n, k;
    char table[4][200];
    cin >> n >> k;
    for(int i=0; i<4; i++)
        for(int j=0; j<n; j++)
            table[i][j] = '.';
    cout << "YES\n";
    if(k%2 == 0){
        for(int i=1; i<=k/2; i++)
            table[1][i] = table[2][i] = '#';
    }else if(k%2==1 && k>n-2){
        int a = k/2;
        int b = k/2+1;
        table[1][b] = '#';
        for(int i=1; i<a; i++)
            table[1][i] = '#';
        for(int i=1; i<=b; i++)
            table[2][i] = '#';
    }else{
        for(int i=n/2-k/2; i<=n/2+k/2; i++)
            table[1][i] = '#';
    }
    for(int i=0; i<4; i++){
        for(int j=0; j<n; j++)
            cout << table[i][j];
        cout << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define clr(a, b) memset(a, b, sizeof(a))
#define Error(x) cout << #x << " = " << x << endl
#define iDEBUG freopen("in.txt", "r", stdin)
#define oDEBUG freopen("output.txt","w",stdout)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define hi cout<<"hi\n"
#define pow(x) (x)*(x)
typedef long long ll;

using namespace std;
int gcd(int m, int n) { if((0 == m) || (0 == n)){return 0;} while(m != n){ if(m > n){m -= n;}else{n -= m;} } return m; }
int lcm(int m, int n) { if((0 == m) || (0 == n)){return 0;} return (m / gcd(m, n)) * n; }

int main()
{_
    int n, k;
    char table[4][200];
    cin >> n >> k;
    for(int i=0; i<4; i++)
        for(int j=0; j<n; j++)
            table[i][j] = '.';
    if(k%2 == 0){
        cout << "YES\n";
        for(int i=1; i<=k/2; i++)
            table[1][i] = table[2][i] = '#';
        for(int i=0; i<4; i++){
            for(int j=0; j<n; j++)
                cout << table[i][j];
            cout << endl;
        }
    }else if(k%2==1 && k>n-2){
        //cout << "NO\n";
        cout << "YES\n";
        int tmp = k/2;
        for(int i=n/2-tmp/2; i<=n/2+tmp/2; i++)
            table[1][i] = '#';
        k -= (n/2);
        for(int i=n/2-k/2; i<=n/2+k/2-1; i++)
            table[2][i] = '#';
        for(int i=0; i<4; i++){
            for(int j=0; j<n; j++)
                cout << table[i][j];
            cout << endl;
        }
    }else{
        cout << "YES\n";
        for(int i=n/2-k/2; i<=n/2+k/2; i++)
            table[1][i] = '#';
        for(int i=0; i<4; i++){
            for(int j=0; j<n; j++)
                cout << table[i][j];
            cout << endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define clr(a, b) memset(a, b, sizeof(a))
#define Error(x) cout << #x << " = " << x << endl
#define iDEBUG freopen("in.txt", "r", stdin)
#define oDEBUG freopen("output.txt","w",stdout)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define hi cout<<"hi\n"
#define pow(x) (x)*(x)
typedef long long ll;

using namespace std;
int gcd(int m, int n) { if((0 == m) || (0 == n)){return 0;} while(m != n){ if(m > n){m -= n;}else{n -= m;} } return m; }
int lcm(int m, int n) { if((0 == m) || (0 == n)){return 0;} return (m / gcd(m, n)) * n; }

int main()
{_
    int n, k;
    char table[4][200];
    cin >> n >> k;
    for(int i=0; i<4; i++)
        for(int j=0; j<n; j++)
            table[i][j] = '.';
    if(k%2==0 && k>(n*2-4)){
        cout << "NO\n";
    }else if(k%2 == 0){
        cout << "YES\n";
        for(int i=1; i<=k/2; i++)
            table[1][i] = table[2][i] = '#';
        for(int i=0; i<4; i++){
            for(int j=0; j<n; j++)
                cout << table[i][j];
            cout << endl;
        }
    }else if(k%2==1 && k>n-2){
        cout << "NO\n";
    }else{
        cout << "YES\n";
        for(int i=1; i<=k; i++)
            table[1][i] = '#';
        for(int i=0; i<4; i++){
            for(int j=0; j<n; j++)
                cout << table[i][j];
            cout << endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define clr(a, b) memset(a, b, sizeof(a))
#define Error(x) cout << #x << " = " << x << endl
#define iDEBUG freopen("in.txt", "r", stdin)
#define oDEBUG freopen("output.txt","w",stdout)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define hi cout<<"hi\n"
#define pow(x) (x)*(x)
typedef long long ll;

using namespace std;
int gcd(int m, int n) { if((0 == m) || (0 == n)){return 0;} while(m != n){ if(m > n){m -= n;}else{n -= m;} } return m; }
int lcm(int m, int n) { if((0 == m) || (0 == n)){return 0;} return (m / gcd(m, n)) * n; }

int main()
{_
    int n, k;
    char table[4][200];
    cin >> n >> k;
    for(int i=0; i<4; i++)
        for(int j=0; j<n; j++)
            table[i][j] = '.';
    cout << "YES\n";
    if(k%2 == 0){
        for(int i=1; i<=k/2; i++)
            table[1][i] = table[2][i] = '#';
    }else if(k%2==1 && k>n-2){
        cout << "YES\n";
        int a = k/2;
        int b = k/2+1;
        table[1][n-2] = '#';
        for(int i=1; i<a; i++)
            table[1][i] = '#';
        for(int i=1; i<=b; i++)
            table[2][i] = '#';
    }else{
        for(int i=n/2-k/2; i<=n/2+k/2; i++)
            table[1][i] = '#';
    }
    for(int i=0; i<4; i++){
        for(int j=0; j<n; j++)
            cout << table[i][j];
        cout << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define clr(a, b) memset(a, b, sizeof(a))
#define Error(x) cout << #x << " = " << x << endl
#define iDEBUG freopen("in.txt", "r", stdin)
#define oDEBUG freopen("output.txt","w",stdout)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define hi cout<<"hi\n"
#define pow(x) (x)*(x)
typedef long long ll;

using namespace std;
int gcd(int m, int n) { if((0 == m) || (0 == n)){return 0;} while(m != n){ if(m > n){m -= n;}else{n -= m;} } return m; }
int lcm(int m, int n) { if((0 == m) || (0 == n)){return 0;} return (m / gcd(m, n)) * n; }

int main()
{_
    int n, k;
    char table[4][200];
    cin >> n >> k;
    for(int i=0; i<4; i++)
        for(int j=0; j<n; j++)
            table[i][j] = '.';
    if(k%2 == 0){
        cout << "YES\n";
        for(int i=1; i<=k/2; i++)
            table[1][i] = table[2][i] = '#';
        for(int i=0; i<4; i++){
            for(int j=0; j<n; j++)
                cout << table[i][j];
            cout << endl;
        }
    }else if(k%2==1 && k>n-2){
        //cout << "NO\n";
        cout << "YES\n";
        int a = k/2;
        int b = k/2+1;
        for(int i=1; i<=a; i++)
            table[1][i] = '#';
        for(int i=1; i<=b; i++)
            table[2][i] = '#';
        for(int i=0; i<4; i++){
            for(int j=0; j<n; j++)
                cout << table[i][j];
            cout << endl;
        }
    }else{
        cout << "YES\n";
        for(int i=n/2-k/2; i<=n/2+k/2; i++)
            table[1][i] = '#';
        for(int i=0; i<4; i++){
            for(int j=0; j<n; j++)
                cout << table[i][j];
            cout << endl;
        }
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
char mapp[100][100];
int n,k;
int main()
{
    scanf("%d%d",&n,&k);
    if(k>(n-1)*3)
    {
        puts("NO");
        return 0;
    }
    puts("YES");
    for(int i=0; i<4; i++)
        for(int j=0; j<n; j++)
        mapp[i][j]='.';
    for(int i=1; i<3; i++)
        for(int j=1; j<n-1; j++)
    {
        if(k)
        {
            mapp[i][j]='#';
            k--;
        }
    }
    for(int i=0; i<4; i++)
        printf("%s\n",mapp[i]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
char mapp[100][100];
int n,k;
int main()
{
    scanf("%d%d",&n,&k);
    if(k>(n-2)*2)
    {
        puts("NO");
        return 0;
    }
    puts("YES");
    for(int i=0; i<4; i++)
        for(int j=0; j<n; j++)
        mapp[i][j]='.';
    for(int i=1; i<3; i++)
        for(int j=1; j<n-1; j++)
    {
        if(k)
        {
            mapp[i][j]='#';
            k--;
        }
    }
    for(int i=0; i<4; i++)
        printf("%s\n",mapp[i]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
char mapp[100][100];
int n,k;
int main()
{
    scanf("%d%d",&n,&k);
    if(k>(n-2)*2)
    {
        puts("NO");
        return 0;
    }
    puts("YES");
    for(int i=0; i<4; i++)
        for(int j=0; j<n; j++)
        mapp[i][j]='.';
        for(int i=1; i<3; i++)
            for(int j=1; j<=n/2-1; j++)
        if(k)
        {
            mapp[i][j]='#';
            mapp[i][n-1-j]='#';
            k-=2;
        }
        for(int i=1; i<3; i++)
            if(k)
        {
            mapp[i][n/2]='#';
            k--;
        }
    for(int i=0; i<4; i++)
        printf("%s\n",mapp[i]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    char a[4][n];
    for(int i = 0; i < 4; i ++)
        for(int j = 0; j < n; j ++)
            a[i][j] = '.';
    if(!(k % 2)) {
        cout << "YES" << endl;
        int j = 1, c = 0;
        while(c < k) {
            for(int i = 1; i <= 2; i ++)
                a[i][j] = '#';
            j ++; c += 2;
        }
        for(int x = 0; x < 4; x ++) {
            for(int y = 0; y < n; y ++)
                cout << a[x][y] << " ";
            cout << endl;
        }
    }
    else if(k == n - 2) {
        cout << "YES" << endl;
        int c = 0;
        while(c < k) {
            a[1][++c] = '#';
        }
        for(int x = 0; x < 4; x ++) {
            for(int y = 0; y < n; y ++)
                cout << a[x][y] << " ";
            cout << endl;
        }
    }
    else
        cout << "NO" << endl;

    return 0;
}


#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <string>
#include <iostream>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,double> pii;

const ll mod = 998244353;
const double inf = 0x3f3f3f3f;
const int maxn = 205;
// std::vector<pair> vv[2][maxn];

char a[5][maxn];

int main()
{
	int n,m;
    scanf("%d%d",&n,&m);
    for (int i = 1; i <= 4; i ++ )
    {
    	for(int j= 1; j <= n; j ++ )
    		a[i][j] = '.';
    }
    printf("YES\n");
   	if(m % 2== 0)
   	{
   		for (int i = 2; i <= m/2 + 1; i ++ )
   		{
   			a[2][i] = '#';
   			a[3][i] = '#';
   		}
   		m = 0;
   	}
   	else if(m <= n - 2)
   	{
   		for(int i = n/2 + 1 - m/2; i <= n/2 + 1 + m/2; i ++ )
   			a[3][i] = '#';
   		m = 0;
   	}
   	else
   	{
   		for (int i = 2; i <= n - 1; i ++ )
   			a[3][i] = '#';
   		m -= n;
   		a[2][2] = '#';
   		a[2][n - 1] = '#';
   		if(m > 0)
   		{
   			for(int i = 3; i < n-1; i ++ )
	   		{
	   			a[2][i] = '#';
	   			m -- ;
	   			if(m == 0)
	   				break;
	   		}
   		}

   	}
   	for (int i = 1; i <= 4; i ++ )
   	{
   		printf("%s",a[i] + 1);
   		printf("\n");
   	}
}


#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <string>
#include <iostream>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,double> pii;

const ll mod = 998244353;
const double inf = 0x3f3f3f3f;
const int maxn = 205;
// std::vector<pair> vv[2][maxn];

char a[5][maxn];

int main()
{
	int n,m;
    scanf("%d%d",&n,&m);
    for (int i = 1; i <= 4; i ++ )
    {
    	for(int j= 1; j <= n; j ++ )
    		a[i][j] = '.';
    }
    printf("YES\n");
   	if(m % 2== 0)
   	{
   		for (int i = 2; i <= m/2 + 1; i ++ )
   		{
   			a[2][i] = '#';
   			a[3][i] = '#';
   		}
   		m = 0;
   	}
   	else if(m <= n - 2)
   	{
   		for(int i = n/2 + 1 - m/2; i <= n/2 + 1 + m/2; i ++ )
   			a[3][i] = '#';
   		m = 0;
   	}
   	else
   	{
   		for (int i = 2; i <= n - 1; i ++ )
   			a[3][i] = 1;
   		m -= n - 2;
   		a[2][2] = '#';
   		a[2][n - 1] = '#';
   		for(int i = 3; i < n-1; i ++ )
   		{
   			a[2][i] = '#';
   			m -- ;
   			if(m == 0)
   				break;
   		}
   	}
   	for (int i = 1; i <= 4; i ++ )
   	{
   		printf("%s",a[i] + 1);
   		printf("\n");
   	}
}


#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <string>
#include <iostream>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,double> pii;

const ll mod = 998244353;
const double inf = 0x3f3f3f3f;
const int maxn = 205;
// std::vector<pair> vv[2][maxn];

char a[4][maxn];

int main()
{
	int n,m;
    scanf("%d%d",&n,&m);
    for (int i = 1; i <= 4; i ++ )
    {
    	for(int j= 1; j <= n; j ++ )
    		a[i][j] = '.';
    }
   	if(m % 2== 0)
   	{
   		for (int i = 2; i <= m/2 + 1; i ++ )
   		{
   			a[2][i] = '#';
   			a[3][i] = '#';
   		}
   		m = 0;
   	}
   	else if(m <= n - 2)
   	{
   		for(int i = n/2 + 1 - m/2; i <= n/2 + 1 + m/2; i ++ )
   			a[3][i] = '#';
   		m = 0;
   	}
   	else
   	{
   		for (int i = 2; i <= n - 1; i ++ )
   			a[3][i] = 1;
   		m -= n - 2;
   		a[2][2] = '#';
   		a[2][n - 1] = '#';
   		for(int i = 3; i < n-1; i ++ )
   		{
   			a[2][i] = '#';
   			m -- ;
   			if(m == 0)
   				break;
   		}
   	}
   	for (int i = 1; i <= 4; i ++ )
   	{
   		printf("%s",a[i] + 1);
   		printf("\n");
   	}
}


#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <string>
#include <iostream>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,double> pii;

const ll mod = 998244353;
const double inf = 0x3f3f3f3f;
const int maxn = 205;
// std::vector<pair> vv[2][maxn];

char a[5][maxn];

int main()
{
	int n,m;
    scanf("%d%d",&n,&m);
    for (int i = 1; i <= 4; i ++ )
    {
    	for(int j= 1; j <= n; j ++ )
    		a[i][j] = '.';
    }
    printf("YES\n");
   	if(m % 2== 0)
   	{
   		for (int i = 2; i <= m/2 + 1; i ++ )
   		{
   			a[2][i] = '#';
   			a[3][i] = '#';
   		}
   		m = 0;
   	}
   	else if(m <= n - 2)
   	{
   		for(int i = n/2 + 1 - m/2; i <= n/2 + 1 + m/2; i ++ )
   			a[3][i] = '#';
   		m = 0;
   	}
   	else
   	{
   		for (int i = 2; i <= n - 1; i ++ )
   			a[3][i] = '#';
   		m -= n - 2;
   		a[2][2] = '#';
   		a[2][n - 1] = '#';
   		for(int i = 3; i < n-1; i ++ )
   		{
   			a[2][i] = '#';
   			m -- ;
   			if(m == 0)
   				break;
   		}
   	}
   	for (int i = 1; i <= 4; i ++ )
   	{
   		printf("%s",a[i] + 1);
   		printf("\n");
   	}
}


#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <string>
#include <iostream>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,double> pii;

const ll mod = 998244353;
const double inf = 0x3f3f3f3f;
const int maxn = 205;
// std::vector<pair> vv[2][maxn];

char a[5][maxn];

int main()
{
	int n,m;
    scanf("%d%d",&n,&m);
    for (int i = 1; i <= 4; i ++ )
    {
    	for(int j= 1; j <= n; j ++ )
    		a[i][j] = '.';
    }
    printf("YES\n");
   	if(m % 2== 0)
   	{
   		for (int i = 2; i <= m/2 + 1; i ++ )
   		{
   			a[2][i] = '#';
   			a[3][i] = '#';
   		}
   		m = 0;
   	}
   	else if(m <= n - 2)
   	{
   		for(int i = n/2 + 1 - m/2; i <= n/2 + 1 + m/2; i ++ )
   			a[3][i] = '#';
   		m = 0;
   	}
   	else
   	{
   		for (int i = 2; i <= n - 1; i ++ )
   			a[3][i] = '#';
   		m -= n;
   		a[2][2] = '#';
   		a[2][n - 1] = '#';
   		if(m == 0)
   			break;
   		for(int i = 3; i < n-1; i ++ )
   		{
   			a[2][i] = '#';
   			m -- ;
   			if(m == 0)
   				break;
   		}
   	}
   	for (int i = 1; i <= 4; i ++ )
   	{
   		printf("%s",a[i] + 1);
   		printf("\n");
   	}
}


#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <string>
#include <iostream>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,double> pii;

const ll mod = 998244353;
const double inf = 0x3f3f3f3f;
const int maxn = 205;
// std::vector<pair> vv[2][maxn];

char a[5][maxn];

int main()
{
	int n,m;
    scanf("%d%d",&n,&m);
    for (int i = 1; i <= 4; i ++ )
    {
    	for(int j= 1; j <= n; j ++ )
    		a[i][j] = '.';
    }
    printf("YES\n");
   	if(m % 2== 0)
   	{
   		for (int i = 2; i <= m/2 + 1; i ++ )
   		{
   			a[2][i] = '#';
   			a[3][i] = '#';
   		}
   		m = 0;
   	}
   	else if(m <= n - 2)
   	{
   		for(int i = n/2 + 1 - m/2; i <= n/2 + 1 + m/2; i ++ )
   			a[3][i] = '#';
   		m = 0;
   	}
   	else
   	{
   		for (int i = 2; i <= n - 1; i ++ )
   			a[3][i] = '#';
   		m -= n;
   		a[2][2] = '#';
   		a[2][n - 1] = '#';
   		for(int i = 3; i < n-1; i ++ )
   		{
   			a[2][i] = '#';
   			m -- ;
   			if(m == 0)
   				break;
   		}
   	}
   	for (int i = 1; i <= 4; i ++ )
   	{
   		printf("%s",a[i] + 1);
   		printf("\n");
   	}
}


#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <string>
#include <iostream>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,double> pii;

const ll mod = 998244353;
const double inf = 0x3f3f3f3f;
const int maxn = 205;
// std::vector<pair> vv[2][maxn];

char a[4][maxn];

int main()
{
	int n,m;
    scanf("%d%d",&n,&m);
    for (int i = 1; i <= 4; i ++ )
    {
    	for(int j= 1; j <= n; j ++ )
    		a[i][j] = '.';
    }
    printf("YES\n");
   	if(m % 2== 0)
   	{
   		for (int i = 2; i <= m/2 + 1; i ++ )
   		{
   			a[2][i] = '#';
   			a[3][i] = '#';
   		}
   		m = 0;
   	}
   	else if(m <= n - 2)
   	{
   		for(int i = n/2 + 1 - m/2; i <= n/2 + 1 + m/2; i ++ )
   			a[3][i] = '#';
   		m = 0;
   	}
   	else
   	{
   		for (int i = 2; i <= n - 1; i ++ )
   			a[3][i] = 1;
   		m -= n - 2;
   		a[2][2] = '#';
   		a[2][n - 1] = '#';
   		for(int i = 3; i < n-1; i ++ )
   		{
   			a[2][i] = '#';
   			m -- ;
   			if(m == 0)
   				break;
   		}
   	}
   	for (int i = 1; i <= 4; i ++ )
   	{
   		printf("%s",a[i] + 1);
   		printf("\n");
   	}
}


#include <iostream>
#include <fstream>

using namespace std;
ifstream fin("date.in");

int n,k;
char a[256][256];

void afisare()
{
    for(int i=0;i<4;++i)
    {
        for(int j=0;j<n;++j) cout<<a[i][j];
        cout<<"\n";
    }
}

int main()
{
    cin>>n>>k;
    if(n%2==0)
    {
        cout<<"NO\n";
        return 0;
    }
    for(int i=0;i<4;++i)
    {
        for(int j=0;j<n;++j) a[i][j]='.';
    }
    if(k<=2)
    {
        if(k==0)
        {
            cout<<"YES\n";
            afisare();
            return 0;
        }
        if(k==1)
        {
            a[1][1]='#';
            cout<<"YES\n";
            afisare();
            return 0;
        }
        else if(k==2)
        {
            a[1][1]='#';
            a[2][1]='#';
            cout<<"YES\n";
            afisare();
            return 0;
        }
    }
    else if(k <= (n-2))
    {
        for(int j=1;j<=k;++j) a[1][j]='#';
        cout<<"YES\n";
        afisare();
        return 0;
    }
    else
    {
        if( k<=2*(n-2))
        {
            if(k%2==0)
            {
                for(int j=1;j<=k/2;++j)
                {
                    a[1][j]='#';
                    a[2][j]='#';
                }
                cout<<"YES\n";
                afisare();
                return 0;
            }
            else
            {
                for(int j=1;j<=n-2;++j) a[1][j]='#';
                k=k-n+2;
                int poz=n-2;
                for(int j=1;j<=k/2;++j)
                {
                    a[2][j]='#';
                    a[2][poz--]='#';
                }
                cout<<"YES\n";
                afisare();
                return 0;
            }
        }
        else
        {
            cout<<"NO\n";
            return 0;
        }
    }
    return 0;
}


#include <iostream>
#include <fstream>

using namespace std;
ifstream fin("date.in");

int n,k;
char a[256][256];

void afisare()
{
    for(int i=0;i<4;++i)
    {
        cout<<a[i];
        cout<<"\n";
    }
}

int main()
{
    cin>>n>>k;
    for(int i=0;i<4;++i)
    {
        for(int j=0;j<n;++j) a[i][j]='.';
    }
    if(k<=2)
    {
        if(k==0)
        {
            cout<<"YES\n";
            afisare();
            return 0;
        }
        if(k==1)
        {
            a[1][1]='#';
            cout<<"YES\n";
            afisare();
            return 0;
        }
        else if(k==2)
        {
            a[1][1]='#';
            a[2][1]='#';
            cout<<"YES\n";
            afisare();
            return 0;
        }
    }
    else if(k <= (n-2))
    {
        for(int j=1;j<=k;++j) a[1][j]='#';
        cout<<"YES\n";
        afisare();
        return 0;
    }
    else
    {
        if(k%2==0 && k<=2*(n-2))
        {
            for(int j=1;j<=k/2;++j)
            {
                a[1][j]='#';
                a[2][j]='#';
            }
            cout<<"YES\n";
            afisare();
            return 0;
        }
        else
        {
            cout<<"NO\n";
            return 0;
        }
    }
    return 0;
}


#include <iostream>
#include <fstream>

using namespace std;
ifstream fin("date.in");

int n,k;
char a[256][256];

void afisare()
{
    for(int i=0;i<4;++i)
    {
        cout<<a[i];
        cout<<"\n";
    }
}

int main()
{
    cin>>n>>k;
    for(int i=0;i<4;++i)
    {
        for(int j=0;j<n;++j) a[i][j]='.';
    }
    if(k<=2)
    {
        if(k==0)
        {
            cout<<"YES\n";
            afisare();
            return 0;
        }
        if(k==1)
        {
            a[1][1]='#';
            cout<<"YES\n";
            afisare();
            return 0;
        }
        else if(k==2)
        {
            a[1][1]='#';
            a[2][1]='#';
            cout<<"YES\n";
            afisare();
            return 0;
        }
    }
    else if(k <= (n-2))
    {
        for(int j=1;j<=k;++j) a[1][j]='#';
        cout<<"YES\n";
        afisare();
        return 0;
    }
    else
    {
        if( k<=2*(n-2))
        {
            if(k%2==0)
            {
                for(int j=1;j<=k/2;++j)
                {
                    a[1][j]='#';
                    a[2][j]='#';
                }
                cout<<"YES\n";
                afisare();
                return 0;
            }
            else
            {
                for(int j=1;j<=k/2+1;++j) a[1][j]='#';
                for(int j=1;j<=k/2+1;++j)
                {
                    if(j!=(k/4+1)) a[2][j]='#';
                }
                cout<<"YES\n";
                afisare();
                return 0;
            }
        }
        else
        {
            cout<<"NO\n";
            return 0;
        }
    }
    return 0;
}


#include <iostream>
#include <fstream>

using namespace std;
ifstream fin("date.in");

int n,k;
char a[256][256];

void afisare()
{
    for(int i=0;i<4;++i)
    {
        cout<<a[i];
        cout<<"\n";
    }
}

int main()
{
    cin>>n>>k;
    if(n%2==0)
    {
        cout<<"NO\n";
        return 0;
    }
    for(int i=0;i<4;++i)
    {
        for(int j=0;j<n;++j) a[i][j]='.';
    }
    if(k<=2)
    {
        if(k==0)
        {
            cout<<"YES\n";
            afisare();
            return 0;
        }
        if(k==1)
        {
            a[1][1]='#';
            cout<<"YES\n";
            afisare();
            return 0;
        }
        else if(k==2)
        {
            a[1][1]='#';
            a[2][1]='#';
            cout<<"YES\n";
            afisare();
            return 0;
        }
    }
    else if(k <= (n-2))
    {
        for(int j=1;j<=k;++j) a[1][j]='#';
        cout<<"YES\n";
        afisare();
        return 0;
    }
    else
    {
        if( k<=2*(n-2))
        {
            if(k%2==0)
            {
                for(int j=1;j<=k/2;++j)
                {
                    a[1][j]='#';
                    a[2][j]='#';
                }
                cout<<"YES\n";
                afisare();
                return 0;
            }
            else
            {
                for(int j=1;j<=k/2+1;++j) a[1][j]='#';
                for(int j=1;j<=k/2+1;++j)
                {
                    if(j!=2) a[2][j]='#';
                }
                cout<<"YES\n";
                afisare();
                return 0;
            }
        }
        else
        {
            cout<<"NO\n";
            return 0;
        }
    }
    return 0;
}


#include <iostream>
#include <fstream>

using namespace std;
ifstream fin("date.in");

int n,k;
char a[256][256];

void afisare()
{
    for(int i=0;i<4;++i)
    {
        for(int j=0;j<n;++j) cout<<a[i][j];
        cout<<"\n";
    }
}

int main()
{
    cin>>n>>k;
    if(n%2==0)
    {
        cout<<"NO\n";
        return 0;
    }
    for(int i=0;i<4;++i)
    {
        for(int j=0;j<n;++j) a[i][j]='.';
    }
    if(k<=2)
    {
        if(k==0)
        {
            cout<<"YES\n";
            afisare();
            return 0;
        }
        if(k==1)
        {
            a[1][1]='#';
            cout<<"YES\n";
            afisare();
            return 0;
        }
        else if(k==2)
        {
            a[1][1]='#';
            a[2][1]='#';
            cout<<"YES\n";
            afisare();
            return 0;
        }
    }
    else if(k <= (n-2))
    {
        for(int j=1;j<=k;++j) a[1][j]='#';
        cout<<"YES\n";
        afisare();
        return 0;
    }
    else
    {
        if( k<=2*(n-2))
        {
            if(k%2==0)
            {
                for(int j=1;j<=k/2;++j)
                {
                    a[1][j]='#';
                    a[2][j]='#';
                }
                cout<<"YES\n";
                afisare();
                return 0;
            }
            else if((k/2+1) != (n-2))
            {
                for(int j=1;j<=n-2;++j) a[1][j]='#';
                k=k-n+2;
                int poz=n-2;
                for(int j=1;j<=k/2;++j)
                {
                    a[2][j]='#';
                    a[2][poz--]='#';
                }
                cout<<"YES\n";
                afisare();
                return 0;
            }
            else
            {
                cout<<"NO\n";
                return 0;
            }
        }
        else
        {
            cout<<"NO\n";
            return 0;
        }
    }
    return 0;
}


#include <iostream>
#include <fstream>

using namespace std;
ifstream fin("date.in");

int n,k;
char a[256][256];

void afisare()
{
    for(int i=0;i<4;++i)
    {
        cout<<a[i];
        cout<<"\n";
    }
}

int main()
{
    cin>>n>>k;
    for(int i=0;i<4;++i)
    {
        for(int j=0;j<n;++j) a[i][j]='.';
    }
    if(k<=2)
    {
        if(k==1)
        {
            a[1][1]='#';
            cout<<"YES\n";
            afisare();
            return 0;
        }
        else if(k==2)
        {
            a[1][1]='#';
            a[2][1]='#';
            cout<<"YES\n";
            afisare();
            return 0;
        }
    }
    else if(k <= (n-2))
    {
        for(int j=1;j<=k;++j) a[1][j]='#';
        cout<<"YES\n";
        afisare();
        return 0;
    }
    else
    {
        if(k%2==0 && k<=2*(n-2))
        {
            for(int j=1;j<=k/2;++j)
            {
                a[1][j]='#';
                a[2][j]='#';
            }
            cout<<"YES\n";
            afisare();
            return 0;
        }
        else
        {
            cout<<"NO\n";
            return 0;
        }
    }
    return 0;
}


#include<bits/stdc++.h>

#define pb          push_back
#define pii      pair<int, int>
#define pb       push_back
#define mp       make_pair
#define LL       long long
#define pi       acos(-1)
using namespace std ;
const int MX = 200000;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b) ; }
int lcm(int x, int y) { x /= gcd(x, y) ; return  x * y; }
bool prime[MX + 5], isprime[MX + 5];
vector< int > v;
int cs = 0 ;
int fx[] = {1, -1, 0, 0} ;
int fy[] = {0, 0, 1, -1} ;

set< int > st ;
set< int >::iterator it ;
char grid[305][305];

bool InRng(int i, int j, int r, int c){
	return ((i >= 0 && i < r) && (j >= 0 && j < c)) ;
}

// ar[123456], br[123456], c[12345] ;
int ar[1234][1234] ;

LL n, m, k, s, x, y;
long long a[25], b[25] ;

void solve(){
	int n, k ;
	cin>>n>>k ;
	if(k%2 == 0){
		int c = 0 ;
		for(int i =2; ; i++){
			if(c == k) break ;
			ar[2][i] = 1 ;
			ar[3][i] = 1 ;
			c += 2 ;
		}
	}
	else {
		int c = 0 ;
		int l = n/2 + n%2 ;
		int r = l ;
		while(c < k){
			ar[2][l] = 1 ;
			c++ ;
			l-- ;
			if( r != n/2 + n%2){
				ar[2][r] = 1 ;
				c++ ;
			}
			r++ ;
			if(l == 1) break ;
		}

		l = n/2 + n%2 - 1 ;
		r = n/2 + n%2 + 1 ;
		while(c < k){
			ar[3][l] = 1 ;
			//cout<<ar[3][l]<<" " ;
			l-- ;
			c++ ;
			ar[3][r] = 1 ;
			r++ ;
			c++ ;
		}
	}
	puts("YES") ;
	for(int i = 1; i < 5; i++){
		for(int j = 1; j <= n; j++){
			if(ar[i][j]) cout<<"#";
			else cout<<"." ;
		}
		putchar(10) ;
	}
}
void sieve(){
    v.pb(2) ; prime[ 1 ] = 1;
    int limit = (int)sqrt(MX);
    for(int i = 4 ; i <= MX ; i += 2) prime[ i ] = 1 ;
    for(int i = 3; i <= MX; i += 2){
        if(!prime[i]){
            v.pb(i);
            if(i <= limit){
                for(int j = i*i; j <= MX; j += 2*i ) prime[j] = 1 ;
            }
        }
    }
}
int main(){
	//sieve() ;
//	while(1)
	solve() ;
    return 0 ;
}


#include<bits/stdc++.h>

#define pb          push_back
#define pii      pair<int, int>
#define pb       push_back
#define mp       make_pair
#define LL       long long
#define pi       acos(-1)
using namespace std ;
const int MX = 200000;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b) ; }
int lcm(int x, int y) { x /= gcd(x, y) ; return  x * y; }
bool prime[MX + 5], isprime[MX + 5];
vector< int > v;
int cs = 0 ;
int fx[] = {1, -1, 0, 0} ;
int fy[] = {0, 0, 1, -1} ;

set< int > st ;
set< int >::iterator it ;
char grid[305][305];

bool InRng(int i, int j, int r, int c){
	return ((i >= 0 && i < r) && (j >= 0 && j < c)) ;
}

// ar[123456], br[123456], c[12345] ;
int ar[1234][1234] ;

LL n, m, k, s, x, y;
long long a[25], b[25] ;

void solve(){
	int n, k ;
	cin>>n>>k ;
	if(k%2 == 0){
		int c = 0 ;
		for(int i =2; ; i++){
			if(c == k) break ;
			ar[2][i] = 1 ;
			ar[3][i] = 1 ;
			c += 2 ;
		}
	}
	else {
		int c = 0 ;
		int l = n/2 + n%2 ;
		int r = l ;
		while(c < k){
			ar[2][l] = 1 ;
			c++ ;
			l-- ;
			if( r != n/2 + n%2){
				ar[2][r] = 1 ;
				c++ ;
			}
			r++ ;
			if(l == 1) break ;
		}

		l = n/2 + n%2 - 1 ;
		r = n/2 + n%2 + 1 ;
		while(c < k){
			ar[3][1] = 1 ;
			//cout<<ar[3][l]<<" " ;
			l-- ;
			c++ ;
			ar[3][r] = 1 ;
			r++ ;
			c++ ;
		}
	}
	puts("YES") ;
	for(int i = 1; i < 5; i++){
		for(int j = 1; j <= n; j++){
			if(ar[i][j]) cout<<"#";
			else cout<<"." ;
		}
		putchar(10) ;
	}
}
void sieve(){
    v.pb(2) ; prime[ 1 ] = 1;
    int limit = (int)sqrt(MX);
    for(int i = 4 ; i <= MX ; i += 2) prime[ i ] = 1 ;
    for(int i = 3; i <= MX; i += 2){
        if(!prime[i]){
            v.pb(i);
            if(i <= limit){
                for(int j = i*i; j <= MX; j += 2*i ) prime[j] = 1 ;
            }
        }
    }
}
int main(){
	//sieve() ;
//	while(1)
	solve() ;
    return 0 ;
}


#include<bits/stdc++.h>

#define pb          push_back
#define pii      pair<int, int>
#define pb       push_back
#define mp       make_pair
#define LL       long long
#define pi       acos(-1)
using namespace std ;
const int MX = 200000;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b) ; }
int lcm(int x, int y) { x /= gcd(x, y) ; return  x * y; }
bool prime[MX + 5], isprime[MX + 5];
vector< int > v;
int cs = 0 ;
int fx[] = {1, -1, 0, 0} ;
int fy[] = {0, 0, 1, -1} ;

set< int > st ;
set< int >::iterator it ;
char grid[305][305];

bool InRng(int i, int j, int r, int c){
	return ((i >= 0 && i < r) && (j >= 0 && j < c)) ;
}

// ar[123456], br[123456], c[12345] ;
char ar[10][10] ;

LL n, m, k, s, x, y;
long long a[25], b[25] ;

void solve(){
	int n, k ;
	cin>>n>>k ;
	if(k%2 == 0){
		int c = 0 ;
		for(int i =2; ; i++){
			if(c == k) break ;
			ar[2][i] = 1 ;
			ar[3][i] = 1 ;
			c += 2 ;
		}
	}
	else {
		int c = 0 ;
		int l = n/2 + n%2 ;
		int r = l ;
		while(c < k){
			ar[2][l] = 1 ;
			c++ ;
			l-- ;
			if( r != n/2 + n%2){
				ar[2][r] = 1 ;
				c++ ;
			}
			r++ ;
			if(l == 1) break ;
		}

		l = n/2 + n%2 - 1 ;
		r = n/2 + n%2 + 1 ;
		while(c < k){
			ar[3][1] = 1 ;
			l-- ;
			c++ ;
			ar[3][r] = 1 ;
			r++ ;
			c++ ;
		}
	}
	puts("YES") ;
	for(int i = 1; i < 5; i++){
		for(int j = 1; j <= n; j++){
			if(ar[i][j]) cout<<"#";
			else cout<<"." ;
		}
		putchar(10) ;
	}
}
void sieve(){
    v.pb(2) ; prime[ 1 ] = 1;
    int limit = (int)sqrt(MX);
    for(int i = 4 ; i <= MX ; i += 2) prime[ i ] = 1 ;
    for(int i = 3; i <= MX; i += 2){
        if(!prime[i]){
            v.pb(i);
            if(i <= limit){
                for(int j = i*i; j <= MX; j += 2*i ) prime[j] = 1 ;
            }
        }
    }
}
int main(){
	//sieve() ;
	while(1)
	solve() ;
    return 0 ;
}


#include<bits/stdc++.h>

#define pb          push_back
#define pii      pair<int, int>
#define pb       push_back
#define mp       make_pair
#define LL       long long
#define pi       acos(-1)
using namespace std ;
const int MX = 200000;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b) ; }
int lcm(int x, int y) { x /= gcd(x, y) ; return  x * y; }
bool prime[MX + 5], isprime[MX + 5];
vector< int > v;
int cs = 0 ;
int fx[] = {1, -1, 0, 0} ;
int fy[] = {0, 0, 1, -1} ;

set< int > st ;
set< int >::iterator it ;
char grid[305][305];

bool InRng(int i, int j, int r, int c){
	return ((i >= 0 && i < r) && (j >= 0 && j < c)) ;
}

// ar[123456], br[123456], c[12345] ;
int ar[1234][1234] ;

LL n, m, k, s, x, y;
long long a[25], b[25] ;

void solve(){
	int n, k ;
	cin>>n>>k ;
	if(k%2 == 0){
		int c = 0 ;
		int i = 2 ;
		while(1){
		    if(c == k) break ;
			ar[2][i] = 1 ;
			ar[3][i] = 1 ;
			c += 2 ;
			i++ ;
		}
	}
	else {
		int c = 0 ;
		int l = n/2 + n%2 ;
		int r = l ;
		while(c < k){
			ar[2][l] = 1 ;
			c++ ;
			l-- ;
			if( r != n/2 + n%2){
				ar[2][r] = 1 ;
				c++ ;
			}
			r++ ;
			if(l == 1) break ;
		}

		l = n/2 + n%2 - 1 ;
		r = n/2 + n%2 + 1 ;
		while(c < k){
			ar[3][1] = 1 ;
			//cout<<ar[3][l]<<" " ;
			l-- ;
			c++ ;
			ar[3][r] = 1 ;
			r++ ;
			c++ ;
		}
	}
	puts("YES") ;
	for(int i = 1; i < 5; i++){
		for(int j = 1; j <= n; j++){
			if(ar[i][j]) cout<<"#";
			else cout<<"." ;
		}
		putchar(10) ;
	}
}
void sieve(){
    v.pb(2) ; prime[ 1 ] = 1;
    int limit = (int)sqrt(MX);
    for(int i = 4 ; i <= MX ; i += 2) prime[ i ] = 1 ;
    for(int i = 3; i <= MX; i += 2){
        if(!prime[i]){
            v.pb(i);
            if(i <= limit){
                for(int j = i*i; j <= MX; j += 2*i ) prime[j] = 1 ;
            }
        }
    }
}
int main(){
	//sieve() ;
//	while(1)
	solve() ;
    return 0 ;
}


#include<bits/stdc++.h>

#define pb          push_back
#define pii      pair<int, int>
#define pb       push_back
#define mp       make_pair
#define LL       long long
#define pi       acos(-1)
using namespace std ;
const int MX = 200000;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b) ; }
int lcm(int x, int y) { x /= gcd(x, y) ; return  x * y; }
bool prime[MX + 5], isprime[MX + 5];
vector< int > v;
int cs = 0 ;
int fx[] = {1, -1, 0, 0} ;
int fy[] = {0, 0, 1, -1} ;

set< int > st ;
set< int >::iterator it ;
char grid[305][305];

bool InRng(int i, int j, int r, int c){
	return ((i >= 0 && i < r) && (j >= 0 && j < c)) ;
}

LL ar[123456], br[123456], c[12345] ;

LL n, m, k, s, x, y;
long long a[25], b[25] ;
void solve(){
	string s;
    cin>>s;
    LL oc = 0, lc=0;
    for(int i = 0 ; i< s.size(); i++)
    {
        if(s[i]=='o')
        oc++;
        else
        lc++;
    }
    if(oc == 0 || lc%oc == 0)
    cout<<"YES\n";
    else cout<<"NO\n";
}
void sieve(){
    v.pb(2) ; prime[ 1 ] = 1;
    int limit = (int)sqrt(MX);
    for(int i = 4 ; i <= MX ; i += 2) prime[ i ] = 1 ;
    for(int i = 3; i <= MX; i += 2){
        if(!prime[i]){
            v.pb(i);
            if(i <= limit){
                for(int j = i*i; j <= MX; j += 2*i ) prime[j] = 1 ;
            }
        }
    }
}
int main(){
	//sieve() ;
//	while(1)
	solve() ;
    return 0 ;
}


#include<bits/stdc++.h>

#define pb          push_back
#define pii      pair<int, int>
#define pb       push_back
#define mp       make_pair
#define LL       long long
#define pi       acos(-1)
using namespace std ;
const int MX = 200000;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b) ; }
int lcm(int x, int y) { x /= gcd(x, y) ; return  x * y; }
bool prime[MX + 5], isprime[MX + 5];
vector< int > v;
int cs = 0 ;
int fx[] = {1, -1, 0, 0} ;
int fy[] = {0, 0, 1, -1} ;

set< int > st ;
set< int >::iterator it ;
char grid[305][305];

bool InRng(int i, int j, int r, int c){
	return ((i >= 0 && i < r) && (j >= 0 && j < c)) ;
}

// ar[123456], br[123456], c[12345] ;
char ar[10][10] ;

LL n, m, k, s, x, y;
long long a[25], b[25] ;

void solve(){
	int n, k ;
	cin>>n>>k ;
	if(k%2 == 0){
		int c = 0 ;
		for(int i =2; ; i++){
			if(c == k) break ;
			ar[2][i] = 1 ;
			ar[3][i] = 1 ;
			c += 2 ;
		}
	}
	else {
		int c = 0 ;
		int l = n/2 + n%2 ;
		int r = l ;
		while(c < k){
			ar[2][l] = 1 ;
			c++ ;
			l-- ;
			if( r != n/2 + n%2){
				ar[2][r] = 1 ;
				c++ ;
			}
			r++ ;
			if(l == 1) break ;
		}

		l = n/2 + n%2 - 1 ;
		r = n/2 + n%2 + 1 ;
		while(c < k){
			ar[3][1] = 1 ;
			l-- ;
			c++ ;
			ar[3][r] = 1 ;
			r++ ;
			c++ ;
		}
	}
	puts("YES") ;
	for(int i = 1; i < 5; i++){
		for(int j = 1; j <= n; j++){
			if(ar[i][j]) cout<<"#";
			else cout<<"." ;
		}
		putchar(10) ;
	}
}
void sieve(){
    v.pb(2) ; prime[ 1 ] = 1;
    int limit = (int)sqrt(MX);
    for(int i = 4 ; i <= MX ; i += 2) prime[ i ] = 1 ;
    for(int i = 3; i <= MX; i += 2){
        if(!prime[i]){
            v.pb(i);
            if(i <= limit){
                for(int j = i*i; j <= MX; j += 2*i ) prime[j] = 1 ;
            }
        }
    }
}
int main(){
	//sieve() ;
//	while(1)
	solve() ;
    return 0 ;
}


#include<bits/stdc++.h>

using namespace std;

#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);

template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

#define pb push_back
#define mk make_pair
#define X first
#define Y second
#define For(i, a, b) for (ll i = a; i < b;i++)
#define Forn(i, a) for (ll i = 0;i < a;i++)
#define Ford(i, a, b) for (ll i = b - 1;i >= a;i--)
#define Fordn(a) for (ll i = a - 1;i >= 0;i--)
#define all(x) x.begin(),x.end()
#define REE(s_) {cout << s_ << '\n';return 0;}

typedef long long ll;
typedef double dd;
typedef long double ldd;

ifstream fin("input.txt");
ofstream fout("output.txt");

const vector<int> dx{-1,1,0,0};
const vector<int> dy{0,0,1,-1};

ll gcd(ll a, ll b){
    return a == 0 ? b : gcd(b % a, a);
}
ll powq(ll x, ll y){
    ll q = 1;
    for(ll i = 1; i <= y; i++){
        q *= x;
    }
    return q;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<vector<char> > a(4, vector<char> (n, '.'));
    if (k == 0){
        cout << "YES" << endl;
        Forn(i, 4){
            Forn(j, n){
                cout << a[i][j];
            }
            cout << endl;
        }
        return 0;
    }
    int gg1 = 1;
    int gg2 = 1;
    if (k == (2 * (n - 2)) - 1) REE("NO");
    if (k % 2 == 0){
        while(k > 0){
            if (k % 2 == 0){
                For(i, 1, 3){
                    a[i][gg1] = '#';
                }
                k -= 2;
                gg1++;
            }
        }
    }
    else{
        if (k <= (n - 2)){
            For(i, 1, 3){
                For(j, 1, n - 1){
                    a[i][j] = '#';
                    k--;
                    if (k <= 0) break;
                }
                if (k <= 0) break;
            }
        }
        else {
            For(i, 1, n - 1){
                a[1][i] = '#';
            }
            k -= (n - 2);
            int gg = k / 2;
            For(i, 1, n - 1){
                a[2][i] = '#';
                gg--;
                if (gg <= 0) break;
            }
            gg = k / 2;
            for (int i = n - 2; i >= 1;i--){
                a[2][i] = '#';
                gg--;
                if (gg <= 0) break;
            }
        }

    }

    cout << "YES" << endl;
    Forn(i, 4){
        Forn(j, n){
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);

template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

#define pb push_back
#define mk make_pair
#define X first
#define Y second
#define For(i, a, b) for (ll i = a; i < b;i++)
#define Forn(i, a) for (ll i = 0;i < a;i++)
#define Ford(i, a, b) for (ll i = b - 1;i >= a;i--)
#define Fordn(a) for (ll i = a - 1;i >= 0;i--)
#define all(x) x.begin(),x.end()
#define REE(s_) {cout << s_ << '\n';return 0;}

typedef long long ll;
typedef double dd;
typedef long double ldd;

ifstream fin("input.txt");
ofstream fout("output.txt");

const vector<int> dx{-1,1,0,0};
const vector<int> dy{0,0,1,-1};

ll gcd(ll a, ll b){
    return a == 0 ? b : gcd(b % a, a);
}
ll powq(ll x, ll y){
    ll q = 1;
    for(ll i = 1; i <= y; i++){
        q *= x;
    }
    return q;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<vector<char> > a(4, vector<char> (n, '.'));
    if (k == 0){
        cout << "YES" << endl;
        Forn(i, 4){
            Forn(j, n){
                cout << a[i][j];
            }
            cout << endl;
        }
        return 0;
    }
    int gg1 = 1;
    int gg2 = 1;
    if (k % 2 == 0){
        while(k > 0){
            if (k % 2 == 0){
                For(i, 1, 3){
                    a[i][gg1] = '#';
                }
                k -= 2;
                gg1++;
            }
        }
    }
    else{
        For(i, 1, 3){
            For(j, 1, n - 1){
                a[i][j] = '#';
                k--;
                if (k <= 0) break;
            }
            if (k <= 0) break;
        }
    }

    cout << "YES" << endl;
    Forn(i, 4){
        Forn(j, n){
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);

template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

#define pb push_back
#define mk make_pair
#define X first
#define Y second
#define For(i, a, b) for (ll i = a; i < b;i++)
#define Forn(i, a) for (ll i = 0;i < a;i++)
#define Ford(i, a, b) for (ll i = b - 1;i >= a;i--)
#define Fordn(a) for (ll i = a - 1;i >= 0;i--)
#define all(x) x.begin(),x.end()
#define REE(s_) {cout << s_ << '\n';return 0;}

typedef long long ll;
typedef double dd;
typedef long double ldd;

ifstream fin("input.txt");
ofstream fout("output.txt");

const vector<int> dx{-1,1,0,0};
const vector<int> dy{0,0,1,-1};

ll gcd(ll a, ll b){
    return a == 0 ? b : gcd(b % a, a);
}
ll powq(ll x, ll y){
    ll q = 1;
    for(ll i = 1; i <= y; i++){
        q *= x;
    }
    return q;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<vector<char> > a(4, vector<char> (n, '.'));
    if (k == 0){
        cout << "YES" << endl;
        Forn(i, 4){
            Forn(j, n){
                cout << a[i][j];
            }
            cout << endl;
        }
        return 0;
    }
    int gg1 = 1;
    int gg2 = 1;
    if (/*k == (2 * (n - 2)) - 1 || */k == 1) REE("NO");
    if (k % 2 == 0){
        while(k > 0){
            if (k % 2 == 0){
                For(i, 1, 3){
                    a[i][gg1] = '#';
                }
                k -= 2;
                gg1++;
            }
        }
    }
    else{
        if (k < (n - 2)){

            int gg = k / 2;
            For(i, 1, n - 1){
                a[1][i] = '#';
                gg--;
                if (gg <= 0) break;
            }
            gg = k / 2;
            for (int i = n - 2; i >= 1;i--){
                a[1][i] = '#';
                gg--;
                if (gg <= 0) break;
            }
            a[1][(n-1) / 2] = '#';
        }
        else if (k == (n - 2)){
            For(i, 1, 3){
                For(j, 1, n - 1){
                    a[i][j] = '#';
                    k--;
                    if (k <= 0) break;
                }
                if (k <= 0) break;
            }
        }
        else {
            For(i, 1, n - 1){
                a[1][i] = '#';
            }
            k -= (n - 2);
            int gg = k / 2;
            For(i, 1, n - 1){
                a[2][i] = '#';
                gg--;
                if (gg <= 0) break;
            }
            gg = k / 2;
            for (int i = n - 2; i >= 1;i--){
                a[2][i] = '#';
                gg--;
                if (gg <= 0) break;
            }
        }

    }

    cout << "YES" << endl;
    Forn(i, 4){
        Forn(j, n){
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);

template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

#define pb push_back
#define mk make_pair
#define X first
#define Y second
#define For(i, a, b) for (ll i = a; i < b;i++)
#define Forn(i, a) for (ll i = 0;i < a;i++)
#define Ford(i, a, b) for (ll i = b - 1;i >= a;i--)
#define Fordn(a) for (ll i = a - 1;i >= 0;i--)
#define all(x) x.begin(),x.end()
#define REE(s_) {cout << s_ << '\n';return 0;}

typedef long long ll;
typedef double dd;
typedef long double ldd;

ifstream fin("input.txt");
ofstream fout("output.txt");

const vector<int> dx{-1,1,0,0};
const vector<int> dy{0,0,1,-1};

ll gcd(ll a, ll b){
    return a == 0 ? b : gcd(b % a, a);
}
ll powq(ll x, ll y){
    ll q = 1;
    for(ll i = 1; i <= y; i++){
        q *= x;
    }
    return q;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<vector<char> > a(4, vector<char> (n, '.'));
    For(i, 1, 3){
        For(j, 1, n - 1){
            a[i][j] = '#';
            k--;
            if (k <= 0) break;
        }
        if (k <= 0) break;
    }
    cout << "YES" << endl;
    Forn(i, 4){
        Forn(j, n){
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);

template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

#define pb push_back
#define mk make_pair
#define X first
#define Y second
#define For(i, a, b) for (ll i = a; i < b;i++)
#define Forn(i, a) for (ll i = 0;i < a;i++)
#define Ford(i, a, b) for (ll i = b - 1;i >= a;i--)
#define Fordn(a) for (ll i = a - 1;i >= 0;i--)
#define all(x) x.begin(),x.end()
#define REE(s_) {cout << s_ << '\n';return 0;}

typedef long long ll;
typedef double dd;
typedef long double ldd;

ifstream fin("input.txt");
ofstream fout("output.txt");

const vector<int> dx{-1,1,0,0};
const vector<int> dy{0,0,1,-1};

ll gcd(ll a, ll b){
    return a == 0 ? b : gcd(b % a, a);
}
ll powq(ll x, ll y){
    ll q = 1;
    for(ll i = 1; i <= y; i++){
        q *= x;
    }
    return q;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<vector<char> > a(4, vector<char> (n, '.'));
    if (k == 0){
        cout << "YES" << endl;
        Forn(i, 4){
            Forn(j, n){
                cout << a[i][j];
            }
            cout << endl;
        }
        return 0;
    }
    int gg1 = 1;
    int gg2 = 1;
    if (k == (2 * (n - 2)) - 1) REE("NO");
    if (k % 2 == 0){
        while(k > 0){
            if (k % 2 == 0){
                For(i, 1, 3){
                    a[i][gg1] = '#';
                }
                k -= 2;
                gg1++;
            }
        }
    }
    else{
        if (k < (n - 2)){
            int gg = k / 2;
            For(i, 1, n - 1){
                a[1][i] = '#';
                gg--;
                if (gg <= 0) break;
            }
            gg = k / 2;
            for (int i = n - 2; i >= 1;i--){
                a[1][i] = '#';
                gg--;
                if (gg <= 0) break;
            }
            a[1][(n-1) / 2] = '#';
        }
        else if (k == (n - 2)){
            For(i, 1, 3){
                For(j, 1, n - 1){
                    a[i][j] = '#';
                    k--;
                    if (k <= 0) break;
                }
                if (k <= 0) break;
            }
        }
        else {
            For(i, 1, n - 1){
                a[1][i] = '#';
            }
            k -= (n - 2);
            int gg = k / 2;
            For(i, 1, n - 1){
                a[2][i] = '#';
                gg--;
                if (gg <= 0) break;
            }
            gg = k / 2;
            for (int i = n - 2; i >= 1;i--){
                a[2][i] = '#';
                gg--;
                if (gg <= 0) break;
            }
        }

    }

    cout << "YES" << endl;
    Forn(i, 4){
        Forn(j, n){
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);

template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

#define pb push_back
#define mk make_pair
#define X first
#define Y second
#define For(i, a, b) for (ll i = a; i < b;i++)
#define Forn(i, a) for (ll i = 0;i < a;i++)
#define Ford(i, a, b) for (ll i = b - 1;i >= a;i--)
#define Fordn(a) for (ll i = a - 1;i >= 0;i--)
#define all(x) x.begin(),x.end()
#define REE(s_) {cout << s_ << '\n';return 0;}

typedef long long ll;
typedef double dd;
typedef long double ldd;

ifstream fin("input.txt");
ofstream fout("output.txt");

const vector<int> dx{-1,1,0,0};
const vector<int> dy{0,0,1,-1};

ll gcd(ll a, ll b){
    return a == 0 ? b : gcd(b % a, a);
}
ll powq(ll x, ll y){
    ll q = 1;
    for(ll i = 1; i <= y; i++){
        q *= x;
    }
    return q;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<vector<char> > a(4, vector<char> (n, '.'));
    if (k == 0){
        cout << "YES" << endl;
        Forn(i, 4){
            Forn(j, n){
                cout << a[i][j];
            }
            cout << endl;
        }
        return 0;
    }
    int gg1 = 1;
    int gg2 = 1;
    if (k % 2 == 0){
        while(k > 0){
            if (k % 2 == 0){
                For(i, 1, 3){
                    a[i][gg1] = '#';
                }
                k -= 2;
                gg1++;
            }
        }
    }
    else{
        if (k <= (n - 2)){
            For(i, 1, 3){
                For(j, 1, n - 1){
                    a[i][j] = '#';
                    k--;
                    if (k <= 0) break;
                }
                if (k <= 0) break;
            }
        }
        else {
            For(i, 1, n - 1){
                a[1][i] = '#';
            }
            k -= (n - 2);
            int gg = k / 2;
            For(i, 1, n - 1){
                a[2][i] = '#';
                gg--;
                if (gg <= 0) break;
            }
            gg = k / 2;
            for (int i = n - 2; i >= 1;i--){
                a[2][i] = '#';
                gg--;
                if (gg <= 0) break;
            }
        }

    }

    cout << "YES" << endl;
    Forn(i, 4){
        Forn(j, n){
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);

template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

#define pb push_back
#define mk make_pair
#define X first
#define Y second
#define For(i, a, b) for (ll i = a; i < b;i++)
#define Forn(i, a) for (ll i = 0;i < a;i++)
#define Ford(i, a, b) for (ll i = b - 1;i >= a;i--)
#define Fordn(a) for (ll i = a - 1;i >= 0;i--)
#define all(x) x.begin(),x.end()
#define REE(s_) {cout << s_ << '\n';return 0;}

typedef long long ll;
typedef double dd;
typedef long double ldd;

ifstream fin("input.txt");
ofstream fout("output.txt");

const vector<int> dx{-1,1,0,0};
const vector<int> dy{0,0,1,-1};

ll gcd(ll a, ll b){
    return a == 0 ? b : gcd(b % a, a);
}
ll powq(ll x, ll y){
    ll q = 1;
    for(ll i = 1; i <= y; i++){
        q *= x;
    }
    return q;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<vector<char> > a(4, vector<char> (n, '.'));
    if (k == 0){
        cout << "YES" << endl;
        Forn(i, 4){
            Forn(j, n){
                cout << a[i][j];
            }
            cout << endl;
        }
        return 0;
    }
    int gg1 = 1;
    int gg2 = 1;
    //if (k == (2 * (n - 2)) - 1 || k == 1) REE("NO");
    if (k % 2 == 0){
        while(k > 0){
            if (k % 2 == 0){
                For(i, 1, 3){
                    a[i][gg1] = '#';
                }
                k -= 2;
                gg1++;
            }
        }
    }
    else{
        if (k < (n - 2)){
            if (k == 1){
                a[1][(n-1) / 2] = '#';
            }
            else{
                int gg = k / 2;
                For(i, 1, n - 1){
                    a[1][i] = '#';
                    gg--;
                    if (gg <= 0) break;
                }
                gg = k / 2;
                for (int i = n - 2; i >= 1;i--){
                    a[1][i] = '#';
                    gg--;
                    if (gg <= 0) break;
                }
                a[1][(n-1) / 2] = '#';
            }
        }
        else if (k == (n - 2)){
            For(i, 1, 3){
                For(j, 1, n - 1){
                    a[i][j] = '#';
                    k--;
                    if (k <= 0) break;
                }
                if (k <= 0) break;
            }
        }
        else {
            For(i, 1, n - 1){
                a[1][i] = '#';
            }
            k -= (n - 2);
            int gg = k / 2;
            For(i, 1, n - 1){
                a[2][i] = '#';
                gg--;
                if (gg <= 0) break;
            }
            gg = k / 2;
            for (int i = n - 2; i >= 1;i--){
                a[2][i] = '#';
                gg--;
                if (gg <= 0) break;
            }
        }

    }

    cout << "YES" << endl;
    Forn(i, 4){
        Forn(j, n){
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long

int n,k;

char ans[5][111];

int main(){
    cin>>n>>k;
    for(int i=1;i<=4;i++){
        for(int j=1;j<=n;j++){
            ans[i][j] = '.';
        }
        ans[i][n+1] = '\0';
    }

    puts("YES");
    for(int i=1;i<=min(k,n-2);i++){
        ans[2][n-i] = '#';
    }
    k -= (n-2);
    if(k){
        for(int i=1;i<=min(k,n-2);i++){
            ans[3][n-i] = '#';
        }
    }

    for(int i =1;i<=4;i++){
        printf("%s\n",ans[i]+1);
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    cout<<"YES"<<endl;
    if(k%2)
    {
        for(int i=0;i<4;++i)
        {
            for(int j=0;j<n;++j)
            {
                if(i>0&&i<3&&j<=k/2&&j)
                {
                    cout<<"#";
                }
                else if(i==2&&j==n-1)
                    cout<<"#";
                else
                    cout<<".";
            }
            cout<<endl;
        }
    }
    else
    {
        for(int i=0;i<4;++i)
        {
            for(int j=0;j<n;++j)
            {
                if(i>0&&i<3&&j<=k/2&&j)
                {
                    cout<<"#";
                }
                else
                    cout<<".";
            }
            cout<<endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    cout<<"YES"<<endl;
    if(k%2)
    {
        for(int i=0;i<4;++i)
        {
            for(int j=0;j<n;++j)
            {
                if(i>0&&i<3&&j<=k/2&&j)
                {
                    cout<<"#";
                }
                else if(i==2&&j==n-2)
                    cout<<"#";
                else
                    cout<<".";
            }
            cout<<endl;
        }
    }
    else
    {
        for(int i=0;i<4;++i)
        {
            for(int j=0;j<n;++j)
            {
                if(i>0&&i<3&&j<=k/2&&j)
                {
                    cout<<"#";
                }
                else
                    cout<<".";
            }
            cout<<endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    cout<<"YES"<<endl;
    if(k%2)
    {
        for(int i=0;i<4;++i)
        {
            for(int j=0;j<n;++j)
            {
                if(i>0&&i<3&&j<k/2)
                {
                    cout<<"#";
                }
                else if(i==2&&j==n-1)
                    cout<<"#";
                else
                    cout<<".";
            }
            cout<<endl;
        }
    }
    else
    {
        for(int i=0;i<4;++i)
        {
            for(int j=0;j<n;++j)
            {
                if(i>0&&i<3&&j<k/2)
                {
                    cout<<"#";
                }
                else
                    cout<<".";
            }
            cout<<endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(false);

    int N,k;
    cin >> N >> k;
    vector < string > World(4);
    for(int i=0; i<4; i++)
        World[i].resize(N,'.');
    for(int y = 1; y<4 && k > 0; y++) {
        for(int x=1; x<N-1 && k > 0; x++, k--)
            World[y][x] = '#';
    }

    for(auto str : World)
        cout << str << "\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(false);

    int N,k;
    cin >> N >> k;

    vector < string > World(4);
    for(int i=0; i<4; i++)
        World[i].resize(N,'.');

    if(k%2 == 0) {
        for(int x = 1; x<N-1 && k > 0; x++) {
            for(int y=1; y<3 && k > 0; y++, k--)
                World[y][x] = '#';
        }
    }
    else {
        if(k > N-2) {
            for(int x=1; x<N-1; x++)
                World[2][x] = '#';
            k -= N-2;
            World[1][1] = '#';
            World[1][N-2] = '#';
            k-=2;
            for(int x=2; x<N-2 && k--; k--,x++)
                World[2][x] = '#';
        }
        else {
            for(int i=N/2 - k/2; i<=N/2+k/2; i++)
                World[1][i] = '#';
        }
    }

    cout << "YES\n";
    for(auto str : World)
        cout << str << "\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(false);

    int N,k;
    cin >> N >> k;

    vector < string > World(4);
    for(int i=0; i<4; i++)
        World[i].resize(N,'.');

    if(k%2 == 0) {
        for(int x = 1; x<N-1 && k > 0; x++) {
            for(int y=1; y<3 && k > 0; y++, k--)
                World[y][x] = '#';
        }
    }
    else if((N-2)%k == 0) {
        for(int y = 1; y<3 && k > 0; y++) {
            for(int x=1; x<N-1 && k > 0; x++, k--)
                World[y][x] = '#';
        }
    }
    else {
        cout << "NO";
        return 0;
    }

    cout << "YES\n";
    for(auto str : World)
        cout << str << "\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(false);

    int N,k;
    cin >> N >> k;

    vector < string > World(4);
    for(int i=0; i<4; i++)
        World[i].resize(N,'.');

    if(k%2 == 0) {
        for(int x = 1; x<N-1 && k > 0; x++) {
            for(int y=1; y<3 && k > 0; y++, k--)
                World[y][x] = '#';
        }
    }
    else if(k == N-2) {
        for(int y = 1; y<3 && k > 0; y++) {
            for(int x=1; x<N-1 && k > 0; x++, k--)
                World[y][x] = '#';
        }
    }
    else if(k >= N) {
        World[1][1] = '#';
        World[2][1] = '#';
        World[1][N-2] = '#';
        World[2][N-2] = '#';
        k-=4;
        for(int y = 1; y<3 && k > 0; y++) {
            for(int x=2; x<N-2 && k > 0; x++, k--)
                World[y][x] = '#';
        }
    }
    else {
        cout << "NO";
        return 0;
    }

    cout << "YES\n";
    for(auto str : World)
        cout << str << "\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(false);

    int N,k;
    cin >> N >> k;
    vector < string > World(4);
    for(int i=0; i<4; i++)
        World[i].resize(N,'.');
    for(int y = 1; y<4 && k > 0; y++) {
        for(int x=1; x<N-1 && k > 0; x++, k--)
            World[y][x] = '#';
    }
    cout << "YES\n";
    for(auto str : World)
        cout << str << "\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(false);

    int N,k;
    cin >> N >> k;

    vector < string > World(4);
    for(int i=0; i<4; i++)
        World[i].resize(N,'.');

    if(k%2 == 0) {
        for(int x = 1; x<N-1 && k > 0; x++) {
            for(int y=1; y<3 && k > 0; y++, k--)
                World[y][x] = '#';
        }
    }
    else if(k == 1) {
        World[1][N/2] = '#';
    }
    else if(k == N-2) {
        for(int y = 1; y<3 && k > 0; y++) {
            for(int x=1; x<N-1 && k > 0; x++, k--)
                World[y][x] = '#';
        }
    }
    else if(k >= N) {
        World[1][1] = '#';
        World[2][1] = '#';
        World[1][N-2] = '#';
        World[2][N-2] = '#';
        k-=4;
        for(int y = 1; y<3 && k > 0; y++) {
            for(int x=2; x<N-2 && k > 0; x++, k--)
                World[y][x] = '#';
        }
    }
    else {
        cout << "NO";
        return 0;
    }

    cout << "YES\n";
    for(auto str : World)
        cout << str << "\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(false);

    int N,k;
    cin >> N >> k;

    vector < string > World(4);
    for(int i=0; i<4; i++)
        World[i].resize(N,'.');

    if(k%2 == 0) {
        for(int x = 1; x<N-1 && k > 0; x++) {
            for(int y=1; y<3 && k > 0; y++, k--)
                World[y][x] = '#';
        }
    }
    else {
        if(k > N-2) {
            for(int x=1; x<N-1; x++)
                World[2][x] = '#';
            k -= N-2;
            World[1][1] = '#';
            World[1][N-2] = '#';
            k-=2;
            for(int x=2; x<N-2 && k>0; k--,x++)
                World[1][x] = '#';
        }
        else {
            for(int i=N/2 - k/2; i<=N/2+k/2; i++)
                World[1][i] = '#';
        }
    }

    cout << "YES\n";
    for(auto str : World)
        cout << str << "\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
char s[2000000];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    if(k%2==1)
    {
        if(k>n||k==n-1)
            printf("NO\n");
        else
        {
            printf("YES\n");
            for(int j=0;j<4;j++)
            {
                for(int i=0;i<n;i++)
                {
                    if(k==n)
                    {
                        if(j==2&&i==0)
                        {
                             printf("#");continue;
                        }
                    }
                   if(j==2&&k&&i!=0)
                    {
                        printf("#");
                        k--;
                       // continue;
                    }
                    else
                        printf(".");
                    //printf("%d",i);
                }
                printf("\n");
            }
        }
    }
    else
    {
        printf("YES\n");
        int kk=k/2;
        for(int j=0;j<4;j++)
        {
            for(int i=0;i<n;i++)
            {
                if(i>0&&i<=kk&&(j==2||j==1))
                    printf("#");
                else  printf(".");
            }
            printf("\n");
        }

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
char s[2000000];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    if(k%2==1)
    {
        if(k!=n-2)
            printf("NO\n");
        else
        {
            printf("YES\n");
            for(int j=0;j<4;j++)
            {
                for(int i=0;i<n;i++)
                {
                    if(k==n)
                    {
                        if(j==2&&i==0)
                        {
                             printf("#");continue;
                        }
                    }
                   if(j==2&&k&&i!=0)
                    {
                        printf("#");
                        k--;
                       // continue;
                    }
                    else
                        printf(".");
                    //printf("%d",i);
                }
                printf("\n");
            }
        }
    }
    else
    {
        printf("YES\n");
        int kk=k/2;
        for(int j=0;j<4;j++)
        {
            for(int i=0;i<n;i++)
            {
                if(i>0&&i<=kk&&(j==2||j==1))
                    printf("#");
                else  printf(".");
            }
            printf("\n");
        }

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
char s[2000000];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    if(k%2==1)
    {
        if(k>n-2)
            printf("NO\n");
        else
        {
            printf("YES\n");
            for(int j=0;j<4;j++)
            {
                for(int i=0;i<n;i++)
                {
                    if(k==n)
                    {
                        if(j==2&&i==0)
                        {
                             printf("#");continue;
                        }
                    }
                   if(j==2&&k&&i!=0)
                    {
                        printf("#");
                        k--;
                       // continue;
                    }
                    else
                        printf(".");
                    //printf("%d",i);
                }
                printf("\n");
            }
        }
    }
    else
    {
        printf("YES\n");
        int kk=k/2;
        for(int j=0;j<4;j++)
        {
            for(int i=0;i<n;i++)
            {
                if(i>0&&i<=kk&&(j==2||j==1))
                    printf("#");
                else  printf(".");
            }
            printf("\n");
        }

    }
    return 0;
}


/*
 		Resilience is the greatest of all virtues.
 		Code by rajiv
 */
// Problem : http://codeforces.com/contest/342/problem/E
// Tags : LCA, Centroid Decomposition

 #include <iostream>
 #include <cstring>
 #include <vector>
 #include <map>
 #include <set>
 #include <stack>
 #include <queue>
 #include <deque>
 #include <sstream>
 #include <iomanip>
 #include <cassert>
 #include <sys/time.h>
 #include <algorithm>
 #include <bitset>
 #include <cmath>
 #include <functional>
 #include <cmath>

 using namespace std ;

 #define xx first
 #define yy second
 #define ll long long
 #define ld long double
 #define el (char)0x0A
 #define sp " "
 #define pb push_back
 #define mp make_pair
 #define all(x) (x).begin(),(x).end()
 #define clr(x) memset((x),0,sizeof(x))
 #define uint unsigned int
 #define abs(x) ((x<=0)?(-x):(x))
 #define CASET  int t;cin>>t;while(t--)
 #define FORN(i,x,y) for(int i=x;i<y;i++)
 #define MAXN 100005
 #define INF 10000000010
 #define MOD 1000000007
 #define last_set_bit(x) log2((x)&(-x))
 #define add(x,y) (x)=((x)+(y))%MOD
 #define PI 3.141592653589793

 typedef pair<int,int> PII ; typedef vector<int> VI ; typedef vector<vector<int> > VVI ; typedef vector<bool> VB ; typedef vector<string> VS ;
 typedef map<int,int> MII ; typedef map<int,VI > MIV ; typedef set<int> SI ; typedef set<PII > SPII ; typedef vector<PII > VPII ; typedef vector<VPII > VVPII ;
 int n  , m ;
 const int N = MAXN ;
 const int LN = ceil(log2(MAXN)) ;

 int A[100050][50] ;
 int depth[MAXN] ;
int subsize[MAXN] ;
 void dfs(int src, VVI& adj, VB& vis, int depp){
    vis[src] = true ;
    depth[src] = depp ;

    for(auto it : adj[src]){
        if (!vis[it]){
            A[it][0] = src ;
            dfs(it,adj,vis,depp+1) ;

        }
    }
 }
 void preprocess(){
     for(int j = 1 ; j <= ceil(log2(n)) ; j++){
         for(int i = 0 ; i < n ; i++){
                if (A[i][j-1] == -1){
                    A[i][j] = -1 ;
                }
                else{
                    A[i][j] = A[A[i][j-1]][j-1] ;
                }
         }
     }
 }
 int lca(int x, int y){
     if (depth[x] < depth[y]){
         return lca(y,x) ;
     }
     if (x == y) return x ;
     // Do this until 'x' reaches the same level as 'y' ;
     int ln = ceil(log2(n)) ;
     for(int j = ln  ; j>=0 ; j--){
         if (A[x][j]!=-1 && depth[x]-(1<<j) >= depth[y]){
             x = A[x][j] ;
         }
     }
     if (x == y) return x ;
     for(int j = ln ; j >= 0 ; j--){
         if (A[x][j] != -1 && A[x][j] != A[y][j]){
             x = A[x][j] ;
             y = A[y][j] ;
         }
     }
     return A[x][0] ;
 }
 bool centroidMarked[MAXN] ;

 void dfs2(int src, VVI& adj, int pa){
     subsize[src] = 1;
     for(auto it : adj[src]){
         if (it != pa && !centroidMarked[it]){
             dfs2(it,adj,src) ;
             subsize[src] += subsize[it] ;
         }
     }
 }
 int centroid(int x , VVI& adj, int pa){
     for(auto it : adj[x]){
        if (!centroidMarked[it] && it != pa && subsize[it]>subsize[x]/2){
            return centroid(it,adj,x) ;
        }
     }
     return x ;
 }
int par[MAXN] ; int root ;
 void decompose(int x, VVI& adj, int pa){
     dfs2(x,adj,pa) ;
     x = centroid(x,adj,pa) ;
     centroidMarked[x] = true ;
     par[x] = pa ;
     for(auto it : adj[x]){
         if (!centroidMarked[it] ){
             decompose(it,adj,x) ;
         }
     }
 }
 int dist(int x , int y){
     return depth[x]+depth[y]-2*depth[lca(x,y)] ;
 }

 int ans[MAXN] ;
 void Paint(int x){
    int u = x ;
    while (u != -1){
        ans[u] = min(ans[u],dist(u,x)) ;
        u = par[u] ;
    }
 }
 int Query(int x){
     int u = x;
     int mn = ans[u] ;
     while (u != -1){
         mn = min(mn,ans[u]+dist(u,x)) ;
         u = par[u] ;
     }
     return mn ;
 }

 int main(){
 	ios_base::sync_with_stdio(false) ;
 	cin.tie(nullptr) ;
    cin >> n >> m ;
    VVI adj(n,VI()) ;
    int x , y ;
    FORN(i,0,n-1){
        cin >> x >> y ; x-- ; y-- ;
        adj[x].pb(y) ;
        adj[y].pb(x) ;
    }
    VB vis(MAXN,false) ;
    A[0][0] = -1 ;
    dfs(0,adj,vis,0) ;
    preprocess() ;
    decompose(0,adj,-1) ;
    memset(centroidMarked,false,sizeof centroidMarked) ;
    root = centroid(0,adj,-1) ;
    par[root] = -1 ;
    int type , u ;
    memset(ans,63,sizeof ans) ;
    Paint(0) ;

    while (m--){
        cin >> type >> u ; u-- ;
        if (type == 1){
            Paint(u) ;
        }
        else{
            cout << Query(u) << el ;
        }
    }
    return 0 ;
 }


/*
 		Resilience is the greatest of all virtues.
 		Code by rajiv
 */
// Problem : http://codeforces.com/contest/342/problem/E
// Tags : LCA, Centroid Decomposition

 #include <iostream>
 #include <cstring>
 #include <vector>
 #include <map>
 #include <set>
 #include <stack>
 #include <queue>
 #include <deque>
 #include <sstream>
 #include <iomanip>
 #include <cassert>
 #include <sys/time.h>
 #include <algorithm>
 #include <bitset>
 #include <cmath>
 #include <functional>
 #include <cmath>

 using namespace std ;

 #define xx first
 #define yy second
 #define ll long long
 #define ld long double
 #define el (char)0x0A
 #define sp " "
 #define pb push_back
 #define mp make_pair
 #define all(x) (x).begin(),(x).end()
 #define clr(x) memset((x),0,sizeof(x))
 #define uint unsigned int
 #define abs(x) ((x<=0)?(-x):(x))
 #define CASET  int t;cin>>t;while(t--)
 #define FORN(i,x,y) for(int i=x;i<y;i++)
 #define MAXN 100005
 #define INF 10000000010
 #define MOD 1000000007
 #define last_set_bit(x) log2((x)&(-x))
 #define add(x,y) (x)=((x)+(y))%MOD
 #define PI 3.141592653589793

 typedef pair<int,int> PII ; typedef vector<int> VI ; typedef vector<vector<int> > VVI ; typedef vector<bool> VB ; typedef vector<string> VS ;
 typedef map<int,int> MII ; typedef map<int,VI > MIV ; typedef set<int> SI ; typedef set<PII > SPII ; typedef vector<PII > VPII ; typedef vector<VPII > VVPII ;
 int n  , m ;
 const int N = MAXN ;
 const int LN = ceil(log2(MAXN)) ;

 int A[100050][50] ;
 int depth[MAXN] ;

 void dfs(int src, VVI& adj, VB& vis, int depp){
    vis[src] = true ;
    depth[src] = depp ;
    for(auto it : adj[src]){
        if (!vis[it]){
            A[it][0] = src ;
            dfs(it,adj,vis,depp+1) ;
        }
    }
 }
 void preprocess(){
     for(int j = 1 ; j <= ceil(log2(n)) ; j++){
         for(int i = 0 ; i < n ; i++){
                if (A[i][j-1] == -1){
                    A[i][j] = -1 ;
                }
                else{
                    A[i][j] = A[A[i][j-1]][j-1] ;
                }
         }
     }
 }
 int lca(int x, int y){
     if (depth[x] < depth[y]){
         return lca(y,x) ;
     }
     if (x == y) return x ;
     // Do this until 'x' reaches the same level as 'y' ;
     for(int j = LN ; j>=0 ; j--){
         if (A[x][j]!=-1 && depth[x]-(1<<j) >= depth[y]){
             x = A[x][j] ;
         }
     }
     if (x == y) return x ;
     for(int j = LN ; j >= 0 ; j--){
         if (A[x][j] != -1 && A[x][j] != A[y][j]){
             x = A[x][j] ;
             y = A[y][j] ;
         }
     }
     return A[x][0] ;
 }
 bool centroidMarked[MAXN] ;
 int subsize[MAXN] ;
 void dfs2(int src, VVI& adj, int pa){
     subsize[src] = 1;
     for(auto it : adj[src]){
         if (it != pa && !centroidMarked[it]){
             dfs2(it,adj,src) ;
             subsize[src] += subsize[it] ;
         }
     }
 }
 int centroid(int x , VVI& adj, int pa){
     for(auto it : adj[x]){
        if (!centroidMarked[it] && it != pa && subsize[it]>subsize[x]/2){
            return centroid(it,adj,x) ;
        }
     }
     return x ;
 }

 void decompose(int x, VVI& adj, int pa, VVI& decomposed){
     x = centroid(x,adj,pa) ;
     centroidMarked[x] = true ;
     dfs2(x,adj,pa) ;

     for(auto it : adj[x]){
         if (!centroidMarked[it] && it != pa){
             int ch = centroid(it,adj,x) ;
             decomposed[x].pb(ch) ;
             decomposed[ch].pb(x) ;
             decompose(it,adj,x,decomposed) ;
         }
     }

 }
 int dist(int x , int y){
     return depth[x]+depth[y]-2*depth[lca(x,y)] ;
 }
 int par[MAXN] ; int root ;
 void dfs3(int x , VVI& decomposed, int pa){
     for(auto it : decomposed[x]){
         if (it != pa){
             par[it] = x ;
             dfs3(it,decomposed,x) ;
         }
     }
 }
 int ans[MAXN] ;
 void Paint(int x){
    int u = x ;
    while (u != -1){
        ans[u] = min(ans[u],dist(u,x)) ;
        u = par[u] ;
    }
 }
 int Query(int x){
     int u = x;
     int mn = ans[u] ;
     while (u != -1){
         mn = min(mn,ans[u]+dist(u,x)) ;
         u = par[u] ;
     }
     return mn ;
 }

 int main(){
 	ios_base::sync_with_stdio(false) ;
 	cin.tie(nullptr) ;
    cin >> n >> m ;
    VVI adj(n,VI()) ;
    VVI decomposed(n,VI()) ;
    int x , y ;
    FORN(i,0,n-1){
        cin >> x >> y ; x-- ; y-- ;
        adj[x].pb(y) ;
        adj[y].pb(x) ;
    }
    VB vis(MAXN,false) ;
    A[0][0] = -1 ;

    dfs(0,adj,vis,0) ;

    preprocess() ;
    decompose(0,adj,-1,decomposed) ;
    memset(centroidMarked,false,sizeof centroidMarked) ;
    root = centroid(0,adj,-1) ;
    par[root] = -1 ;
    dfs3(root,decomposed,-1)  ;
    int type , u ;
    for(int i = 0 ; i < n ; i++){
        ans[i] = dist(i,0) ;
    }
    while (m--){
        cin >> type >> u ; u-- ;
        if (type == 1){
            Paint(u) ;
        }
        else{
            cout << Query(u) << el ;
        }

    }
    return 0 ;
 }


#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
#include<stack>
#include<cmath>
#include<iomanip>
#include<cstdlib>
#include<sstream>
#include<climits>
#include<cassert>
#include<time.h>
using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define pb push_back
#define ss second
#define ff first
#define vi vector<int>
#define vl vector<ll>
#define s(n) scanf("%d",&n)
#define ll long long
#define mp make_pair
#define PII pair <int ,int >
#define PLL pair<ll,ll>
#define inf 1000*1000*1000+5
#define v(a,size,value) vi a(size,value)
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define tri pair < int , PII >
#define TRI(a,b,c) mp(a,mp(b,c))
#define xx ff
#define yy ss.ff
#define zz ss.ss
#define in(n) n = inp()
#define vii vector < PII >
#define vll vector< PLL >
#define viii vector < tri >
#define vs vector<string>
#define DREP(a) sort(all(a)); a.erase(unique(all(a)),a.end());
#define INDEX(arr,ind) (lower_bound(all(arr),ind)-arr.begin())
#define ok if(debug)
#define trace1(x) ok cerr << #x << ": " << x << endl;
#define trace2(x, y) ok cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)    ok      cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)  ok cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " \
                                << #d << ": " << d << endl;
#define trace5(a, b, c, d, e) ok cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " \
                                     << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) ok cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " \
                                    << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
ll MOD = int(1e9) + 7;

int debug = 0;
const int N = int(1e5) + 5 , LN = 18;
using namespace std;
int siz[N];
int marked[N] , level[N] , pa[LN][N] , par[N];
vi nei[N];
int subtreesize = 0;
void dfs1(int u , int v = -1, int lev = 1)
{
    int i;
    level[u] = lev;
    pa[0][u] = v;
    rep(i,sz(nei[u]))
        if(nei[u][i] != v)
            dfs1(nei[u][i],u,lev+1);
}
void precompute() //memset pa to -1 in main
{
    int i,j;
    dfs1(1);
    for(i = 1; i < LN;i++)
    {
        for(j = 0; j < N; j++)
        {
            if(pa[i-1][j] != -1)pa[i][j] = pa[i-1][pa[i-1][j]];
        }
    }
}
int lca(int u, int v)
{
    if(level[u] < level[v])swap(u,v);
    int diff = (level[u] - level[v]),i;
    rep(i,LN) if((diff>>i)&1) u = pa[i][u];
    if( u == v)return u;
    for(i = LN - 1; i >= 0;i--)
        if(pa[i][u] != pa[i][v])
        {
            u = pa[i][u];
            v = pa[i][v];
        }
    return pa[0][u];
}
int dist(int u , int v)
{
    return level[u] + level[v] - 2*level[lca(u,v)];
}

void dfs2(int u , int v = -1)
{
    siz[u] = 1;
    int i;
    rep(i,sz(nei[u]))
    {
        if(nei[u][i] != v && !marked[nei[u][i]])
        {
            dfs2(nei[u][i],u);
            siz[u] += siz[nei[u][i]];
        }
    }
}
int centroid(int node,int parent)
{
    int i;
    rep(i,sz(nei[node]))
    {
        if(!marked[nei[node][i]] && siz[nei[node][i]] > subtreesize && nei[node][i] != parent)
            return centroid(nei[node][i],node);
    }
    return node;
}
void decompose(int node , int parent)
{
    trace2(node,parent);
    subtreesize = 0;
    dfs2(node);
    subtreesize = siz[node]/2;
    int i;
    int centre = centroid(node,parent);
    par[centre] = parent;
    marked[centre] = 1;
    rep(i,sz(nei[centre]))
    {
        if(!marked[nei[centre][i]])
            decompose(nei[centre][i] , centre);
    }
}
int D[N];
void color(int x)
{
    int y = x;
    while(y != 0)
    {
        trace1(y);
        D[y] = min(D[y] , dist(x,y));
        y = par[y];
        trace5(y,x,dist(x,y),lca(x,y),D[y])
    }
}
int query(int x)
{
    int y = x;
    int ret = D[y];
    while(y != 0)
    {
        ret = min(ret, D[y] + dist(y,x));
        y = par[y];
    }
    return ret;
}
int main()
{
      int i,j,n,t,m;
      ios::sync_with_stdio(false);
    memset(D,63,sizeof(D));
    cin>>n>>m;
    rep(i,n-1)
    {
        int a,b;
        cin>>a>>b;
        nei[a].pb(b);
        nei[b].pb(a);
    }

    decompose(1,0);
    precompute();
    color(1);
    rep(i,m)
    {
        int v;
        cin>>t>>v;
        if(t == 1)
        {
            color(v);
        }
        else
        {
            cout<<query(v)<<endl;
        }
    }
}


/*
 		Resilience is the greatest of all virtues.
 		Code by rajiv
 */
// Problem : http://codeforces.com/contest/342/problem/E
// Tags : LCA, Centroid Decomposition

 #include <iostream>
 #include <cstring>
 #include <vector>
 #include <map>
 #include <set>
 #include <stack>
 #include <queue>
 #include <deque>
 #include <sstream>
 #include <iomanip>
 #include <cassert>
 #include <sys/time.h>
 #include <algorithm>
 #include <bitset>
 #include <cmath>
 #include <functional>
 #include <cmath>

 using namespace std ;

 #define xx first
 #define yy second
 #define ll long long
 #define ld long double
 #define el (char)0x0A
 #define sp " "
 #define pb push_back
 #define mp make_pair
 #define all(x) (x).begin(),(x).end()
 #define clr(x) memset((x),0,sizeof(x))
 #define uint unsigned int
 #define abs(x) ((x<=0)?(-x):(x))
 #define CASET  int t;cin>>t;while(t--)
 #define FORN(i,x,y) for(int i=x;i<y;i++)
 #define MAXN 100005
 #define INF 10000000010
 #define MOD 1000000007
 #define last_set_bit(x) log2((x)&(-x))
 #define add(x,y) (x)=((x)+(y))%MOD
 #define PI 3.141592653589793

 typedef pair<int,int> PII ; typedef vector<int> VI ; typedef vector<vector<int> > VVI ; typedef vector<bool> VB ; typedef vector<string> VS ;
 typedef map<int,int> MII ; typedef map<int,VI > MIV ; typedef set<int> SI ; typedef set<PII > SPII ; typedef vector<PII > VPII ; typedef vector<VPII > VVPII ;
 int n  , m ;
 const int N = MAXN ;
 const int LN = ceil(log2(MAXN)) ;

 int A[100050][50] ;
 int depth[MAXN] ;
int subsize[MAXN] ;
 void dfs(int src, VVI& adj, VB& vis, int depp){
    vis[src] = true ;
    depth[src] = depp ;

    for(auto it : adj[src]){
        if (!vis[it]){
            A[it][0] = src ;
            dfs(it,adj,vis,depp+1) ;

        }
    }
 }
 void preprocess(){
     for(int j = 1 ; j <= ceil(log2(n)) ; j++){
         for(int i = 0 ; i < n ; i++){
                if (A[i][j-1] == -1){
                    A[i][j] = -1 ;
                }
                else{
                    A[i][j] = A[A[i][j-1]][j-1] ;
                }
         }
     }
 }
 int lca(int x, int y){
     if (depth[x] < depth[y]){
         return lca(y,x) ;
     }
     if (x == y) return x ;
     // Do this until 'x' reaches the same level as 'y' ;
     int ln = ceil(log2(n)) ;
     for(int j = ln  ; j>=0 ; j--){
         if (A[x][j]!=-1 && depth[x]-(1<<j) >= depth[y]){
             x = A[x][j] ;
         }
     }
     if (x == y) return x ;
     for(int j = ln ; j >= 0 ; j--){
         if (A[x][j] != -1 && A[x][j] != A[y][j]){
             x = A[x][j] ;
             y = A[y][j] ;
         }
     }
     return A[x][0] ;
 }
 bool centroidMarked[MAXN] ;

 void dfs2(int src, VVI& adj, int pa){
     subsize[src] = 1;
     for(auto it : adj[src]){
         if (it != pa && !centroidMarked[it]){
             dfs2(it,adj,src) ;
             subsize[src] += subsize[it] ;
         }
     }
 }
 int centroid(int x , VVI& adj, int pa){
     for(auto it : adj[x]){
        if (!centroidMarked[it] && it != pa && subsize[it]>subsize[x]/2){
            return centroid(it,adj,x) ;
        }
     }
     return x ;
 }
int par[MAXN] ; int root ;
 void decompose(int x, VVI& adj, int pa){
     dfs2(x,adj,pa) ;
     x = centroid(x,adj,pa) ;
     centroidMarked[x] = true ;
     par[x] = pa ;
     for(auto it : adj[x]){
         if (!centroidMarked[it] ){
             decompose(it,adj,x) ;
         }
     }
 }
 int dist(int x , int y){
     return depth[x]+depth[y]-2*depth[lca(x,y)] ;
 }

 int ans[MAXN] ;
 void Paint(int x){
    int u = x ;
    while (u != -1){
        ans[u] = min(ans[u],dist(u,x)) ;
        u = par[u] ;
    }
 }
 int Query(int x){
     int u = x;
     int mn = ans[u] ;
     while (u != -1){
         mn = min(mn,ans[u]+dist(u,x)) ;
         u = par[u] ;
     }
     return mn ;
 }

 int main(){
 	ios_base::sync_with_stdio(false) ;
 	cin.tie(nullptr) ;
    cin >> n >> m ;
    VVI adj(n,VI()) ;
    int x , y ;
    FORN(i,0,n-1){
        cin >> x >> y ; x-- ; y-- ;
        adj[x].pb(y) ;
        adj[y].pb(x) ;
    }
    VB vis(MAXN,false) ;
    A[0][0] = -1 ;
    dfs(0,adj,vis,0) ;
    preprocess() ;
    decompose(0,adj,-1) ;
    memset(centroidMarked,false,sizeof centroidMarked) ;
    root = centroid(0,adj,-1) ;
    par[root] = -1 ;
    int type , u ;
    for(int i = 0 ; i < n ; i++){
        ans[i] = dist(i,0) ;
    }

    while (m--){
        cin >> type >> u ; u-- ;
        if (type == 1){
            Paint(u) ;
        }
        else{
            cout << Query(u) << el ;
        }
    }
    return 0 ;
 }