/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		String distinguisedName = "CN=Paul Sebula,OU=BAE,OU=Users,OU=TIES Project,DC=SPHQTest,DC=na,DC=baesystems,DC=com";
		String[] names = distinguisedName.split(",")[0].split("=")[1].split(" ");
        String firstName = names[0];
        String lastName= names.length > 2 ? names[names.length-1] : names[1];
        System.out.println(firstName + " " + lastName);
	}
}