This problem uses a simplified network topology model, please read the problem statement carefully and use it as a formal document as you develop the solution.

Polycarpus continues working as a system administrator in a large corporation. The computer network of this corporation consists of n computers, some of them are connected by a cable. The computers are indexed by integers from 1 to n. It's known that any two computers connected by cable directly or through other computers

Polycarpus decided to find out the network's topology. A network topology is the way of describing the network configuration, the scheme that shows the location and the connections of network devices.

Polycarpus knows three main network topologies: bus, ring and star. A bus is the topology that represents a shared cable with all computers connected with it. In the ring topology the cable connects each computer only with two other ones. A star is the topology where all computers of a network are connected to the single central node.

Let's represent each of these network topologies as a connected non-directed graph. A bus is a connected graph that is the only path, that is, the graph where all nodes are connected with two other ones except for some two nodes that are the beginning and the end of the path. A ring is a connected graph, where all nodes are connected with two other ones. A star is a connected graph, where a single central node is singled out and connected with all other nodes. For clarifications, see the picture. [Image] (1) — bus, (2) — ring, (3) — star 

You've got a connected non-directed graph that characterizes the computer network in Polycarpus' corporation. Help him find out, which topology type the given network is. If that is impossible to do, say that the network's topology is unknown. 


-----Input-----

The first line contains two space-separated integers n and m (4 ≤ n ≤ 10^5; 3 ≤ m ≤ 10^5) — the number of nodes and edges in the graph, correspondingly. Next m lines contain the description of the graph's edges. The i-th line contains a space-separated pair of integers x_{i}, y_{i} (1 ≤ x_{i}, y_{i} ≤ n) — the numbers of nodes that are connected by the i-the edge.

It is guaranteed that the given graph is connected. There is at most one edge between any two nodes. No edge connects a node with itself.


-----Output-----

In a single line print the network topology name of the given graph. If the answer is the bus, print "bus topology" (without the quotes), if the answer is the ring, print "ring topology" (without the quotes), if the answer is the star, print "star topology" (without the quotes). If no answer fits, print "unknown topology" (without the quotes).


-----Examples-----
Input
4 3
1 2
2 3
3 4

Output
bus topology

Input
4 4
1 2
2 3
3 4
4 1

Output
ring topology

Input
4 3
1 2
1 3
1 4

Output
star topology

Input
4 4
1 2
2 3
3 1
1 4

Output
unknown topology

Difficulty: EASY

Solutions:
(n, m) = map(int, input().split())
d = {i: [] for i in range(1, n + 1)}
for _ in range(m):
	(a, b) = map(int, input().split())
	d[a].append(b)
	d[b].append(a)
c = 0
(one, two) = (0, 0)
star = 0
for i in d:
	if len(d[i]) == 1:
		c += 1
		one += 1
	elif len(d[i]) == 2:
		two += 1
	elif len(d[i]) == n - 1:
		star += 1
if c == n - 1 and star == 1:
	print('star topology')
elif one == 2 and two == n - 2:
	print('bus topology')
elif two == n:
	print('ring topology')
else:
	print('unknown topology')


(n, m) = map(int, input().split())
l = [0] * n
d = l[:]
for _ in range(m):
	(a, b) = map(int, input().split())
	l[a - 1] += 1
	l[b - 1] += 1
for i in l:
	d[i] += 1
if d[1] == 2 and d[2] == n - 2:
	print('bus topology')
elif d[2] == n:
	print('ring topology')
elif d[1] == n - 1 and d[n - 1] == 1:
	print('star topology')
else:
	print('unknown topology')


(n, m) = map(int, input().split())
if n == m or n == m + 1:
	s = [0] * n
	for _ in range(m):
		(a, b) = map(int, input().split())
		s[a - 1] += 1
		s[b - 1] += 1
	s = set(s)
	if s == {2}:
		print('ring topology')
	elif s == {1, 2}:
		print('bus topology')
	elif s == {1, m}:
		print('star topology')
	else:
		print('unknown topology')
else:
	print('unknown topology')
	exit(0)


(n, m) = [int(i) for i in input().split()]
graf = [[] for i in range(n + 1)]
for i in range(m):
	(k1, k2) = [int(i) for i in input().split()]
	graf[k1].append(k2)
	graf[k2].append(k1)
seks = [0, 0, 0]
for i in range(1, n + 1):
	if len(graf[i]) == 1 or len(graf[i]) == 2:
		seks[len(graf[i])] += 1
	else:
		seks[0] += 1
if seks[0] == 0 and seks[1] == 2:
	print('bus topology')
elif seks[0] == seks[1] == 0:
	print('ring topology')
elif seks[0] == 1 and seks[2] == 0:
	print('star topology')
else:
	print('unknown topology')


from collections import defaultdict
(n, m) = map(int, input().split())
d = defaultdict(list)
a = []
for i in range(m):
	(x, y) = map(int, input().split())
	d[x].append(y)
	d[y].append(x)
for i in range(1, n + 1):
	p = len(d[i])
	a.append(p)
flag = 0
mid = 0
start = 0
for i in range(0, n):
	if a[i] == 2:
		mid += 1
	elif a[i] == 1:
		start += 1
if mid == n - 2 and start == 2:
	flag = 2
tag = 0
for i in range(n):
	if a[i] == 2:
		tag = 2
	else:
		tag = 1
		break
sac = 0
p = max(a)
t = a.index(p)
for i in range(n):
	if i != t:
		if a[i] == 1:
			sac = 2
		else:
			sac = 1
			break
	if i == t:
		if p == n - 1:
			sac = 2
		else:
			sac = 1
			break
if flag == 2:
	print('bus topology')
elif tag == 2:
	print('ring topology')
elif sac == 2:
	print('star topology')
else:
	print('unknown topology')


def checkTopology(network, n, e):
	if e == n - 1:
		if sum([len(y) == 1 for (x, y) in network.items()]) == 2:
			return 'bus'
		elif any([len(y) == e for (x, y) in network.items()]):
			return 'star'
	elif e == n:
		if all([len(y) == 2 for (x, y) in network.items()]):
			return 'ring'
	return 'unknown'
(nodes, edges) = [int(x) for x in input().split()]
connections = {}
for n in range(1, nodes + 1):
	connections[n] = []
for e in range(edges):
	(n, m) = [int(x) for x in input().split()]
	connections[n].append(m)
	connections[m].append(n)
print(checkTopology(connections, nodes, edges), 'topology')


def main():
	(n, m) = map(int, input().split())
	types = ['bus', 'ring', 'star', 'unknown']
	occ = [0] * n
	for i in range(m):
		(a, b) = map(int, input().split())
		occ[a - 1] += 1
		occ[b - 1] += 1
	cnt = [0] * 3
	for v in occ:
		cnt[min(2, v - 1)] += 1
	if cnt == [2, n - 2, 0]:
		res = types[0]
	elif cnt == [0, n, 0]:
		res = types[1]
	elif cnt == [n - 1, 0, 1]:
		res = types[2]
	else:
		res = types[3]
	print(res, 'topology')
main()


(n, e) = list(map(int, input().split()))
network = {}
arr = []
for i in range(e):
	(a, b) = map(int, input().split())
	if a in network:
		network[a].append(b)
	else:
		network[a] = [b]
	if b in network:
		network[b].append(a)
	else:
		network[b] = [a]
for k in network:
	arr.append(len(network[k]))
if arr.count(1) == 2 and arr.count(2) == n - 2:
	print('bus topology')
elif arr.count(2) == n:
	print('ring topology')
elif arr.count(n - 1) == 1 and arr.count(1) == n - 1:
	print('star topology')
else:
	print('unknown topology')


(n, m) = map(int, input().split())
graph = {}
for i in range(1, n + 1):
	graph[i] = []
for i in range(m):
	(u, v) = map(int, input().split())
	graph[u].append(v)
	graph[v].append(u)
c = 0
d = 0
for i in range(1, n + 1):
	if len(graph[i]) == 1:
		c = c + 1
	elif len(graph[i]) >= 2:
		d = d + 1
if m == n - 1 and c == 2 and (d == n - 2):
	print('bus topology')
elif c == 0 and d == n and (m == n):
	print('ring topology')
elif c == n - 1 and d == 1:
	print('star topology')
else:
	print('unknown topology')


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
g = [[] for _ in range(n)]
for _ in range(m):
	(x, y) = map(int, input().split())
	g[x - 1].append(y - 1)
	g[y - 1].append(x - 1)

def ring(n, m, g):
	if all((len(l) == 2 for l in g)):
		return True
	else:
		return False

def star(n, m, g):
	return any((len(l) == m for l in g))

def bus(n, m, g):
	for node in range(3):
		if len(g[node]) == 2:
			break
	else:
		return False
	exit = 0
	visited = [0] * n
	visited[node] = 1
	nodes = [node]
	while nodes:
		cur = nodes.pop()
		count = 0
		for new_node in g[cur]:
			if not visited[new_node]:
				visited[new_node] = 1
				nodes.append(new_node)
				count += 1
		if count == 0:
			exit += 1
	return exit == 2
if m == n - 1 and bus(n, m, g):
	print('bus topology')
elif m == n and ring(n, m, g):
	print('ring topology')
elif m == n - 1 and star(n, m, g):
	print('star topology')
else:
	print('unknown topology')


def main():
	(n, m) = map(int, input().split())
	l = [0] * n
	for i in range(m):
		(a, b) = map(int, input().split())
		l[a - 1] += 1
		l[b - 1] += 1
	k_1 = 0
	k_2 = 0
	k_n = 0
	for i in range(n):
		if l[i] == 1:
			k_1 += 1
		elif l[i] == 2:
			k_2 += 1
		elif l[i] == n - 1:
			k_n += 1
	if k_1 == 2 and k_2 == n - 2:
		print('bus topology')
	elif k_2 == n:
		print('ring topology')
	elif k_1 == n - 1 and k_n == 1:
		print('star topology')
	else:
		print('unknown topology')
main()


from collections import Counter
(n, m) = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
	(x, y) = map(int, input().split())
	g[x - 1].append(y - 1)
	g[y - 1].append(x - 1)
bus = [2] * (n - 2) + [1] * 2
star = [1] * (n - 1) + [n - 1]
lns = [len(lst) for lst in g]
if lns == [2] * n:
	print('ring topology')
elif Counter(lns) == Counter(bus):
	print('bus topology')
elif Counter(lns) == Counter(star):
	print('star topology')
else:
	print('unknown topology')


(m, n) = [int(i) for i in input().split()]
adj = []
for i in range(m):
	adj.append([])
for i in range(n):
	(first, second) = [int(i) for i in input().split()]
	adj[first - 1].append(second)
	adj[second - 1].append(first)
vertices = m
edges = n
ones = 0
twos = 0
every = 0
if edges == vertices:
	for i in range(m):
		if len(adj[i]) == 1:
			ones += 1
		elif len(adj[i]) == 2:
			twos += 1
elif edges < vertices:
	for i in range(m):
		if len(adj[i]) == 1:
			ones += 1
		elif len(adj[i]) == 2:
			twos += 1
		elif len(adj[i]) == n:
			every += 1
if twos == m:
	print('ring topology')
elif ones == n and every == 1:
	print('star topology')
elif twos == m - 2 and ones == 2:
	print('bus topology')
else:
	print('unknown topology')


(n, m) = map(int, input().split())
A = [0] * n
for _ in range(m):
	(a, b) = map(int, input().split())
	A[a - 1] += 1
	A[b - 1] += 1
x = set(A)
if x == {2}:
	print('ring topology')
elif x == {1, 2}:
	print('bus topology')
elif x == {1, m}:
	print('star topology')
else:
	print('unknown topology')


import os
import sys
from io import BytesIO, IOBase
mod = 10 ** 9 + 7

def main():
	(n, m) = map(int, input().split())
	graph = [[] for _ in range(n + 1)]
	for _ in range(m):
		(a, b) = map(int, input().split())
		graph[a].append(b)
		graph[b].append(a)
	ans = 'unknown'
	(one, two, three) = (0, 0, 0)
	for _ in range(1, n + 1):
		if len(graph[_]) > 2:
			three += 1
		elif len(graph[_]) == 2:
			two += 1
		else:
			one += 1
	if three:
		if three == 1 and one == n - 1:
			ans = 'star'
	elif one:
		ans = 'bus'
	else:
		ans = 'ring'
	print(f'{ans} topology')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


bt = 'bus topology'
st = 'star topology'
rt = 'ring topology'
ut = 'unknown topology'

def main():
	(n, m) = map(int, input().split())
	S = [0 for j in range(n)]
	for _ in range(m):
		(x, y) = map(int, input().split())
		S[x - 1] += 1
		S[y - 1] += 1
	if S.count(2) == len(S):
		print(rt)
		return
	elif S.count(2) == len(S) - 2 and S.count(1) == 2:
		print(bt)
		return
	elif S.count(n - 1) == 1 and S.count(1) == len(S) - 1:
		print(st)
		return
	else:
		print(ut)
		return
main()


(n, m) = map(int, input().split())
adj = [[] for i in range(n)]
oneDeg = 0
twoDeg = 0
maxDeg = 0
for i in range(m):
	(u, v) = map(int, input().split())
	u -= 1
	v -= 1
	adj[u].append(v)
	adj[v].append(u)
for i in range(n):
	maxDeg = max(maxDeg, len(adj[i]))
	if len(adj[i]) == 1:
		oneDeg += 1
	if len(adj[i]) == 2:
		twoDeg += 1
if oneDeg == n - 1:
	print('star topology')
elif twoDeg == n:
	print('ring topology')
elif oneDeg == 2 and twoDeg == n - 2:
	print('bus topology')
else:
	print('unknown topology')


(n, m) = map(int, input().split())
db = [[0] for i in range(n)]
for i in range(m):
	(x, y) = map(int, input().split())
	db[x - 1].append(y)
	db[y - 1].append(x)
	db[x - 1][0] += 1
	db[y - 1][0] += 1
one = 0
two = 0
mx = 0
for i in range(n):
	if db[i][0] == 1:
		one += 1
	elif db[i][0] == 2:
		two += 1
	mx = max(mx, db[i][0])
if one == 2 and two == n - 2:
	print('bus topology')
elif two == n:
	print('ring topology')
elif one == n - 1 and mx == n - 1:
	print('star topology')
else:
	print('unknown topology')


N = 100000.0 + 5
M = 100000.0 + 5
(n, m) = map(int, input().split(' '))
d = []
for i in range(0, n + 1):
	d.append(0)
for i in range(0, m):
	(u, v) = map(int, input().split(' '))
	d[u] += 1
	d[v] += 1
flag1 = 1
flag2 = 1
flag3 = 1
d1 = 0
d2 = 0
star_cent = 0
for i in range(1, n + 1):
	if d[i] == 1:
		d1 += 1
	if d[i] == 2:
		d2 += 1
	else:
		flag2 = 0
	if d[i] == n - 1:
		star_cent += 1
if d1 == 2 and d2 == n - 2:
	print('bus topology')
elif flag2:
	print('ring topology')
elif star_cent == 1 and d1 == n - 1:
	print('star topology')
else:
	print('unknown topology')


import sys
from collections import defaultdict

def bus(graph):
	x = None
	y = None
	for (k, v) in graph.items():
		if len(v) == 1:
			x = k
			y = v[0]
			break
	while y in graph:
		if len(graph[y]) == 1:
			if graph[y][0] == x:
				return True
			else:
				return False
		else:
			(a, b) = graph[y]
			if a == x:
				x = y
				y = b
			else:
				x = y
				y = a
	return False

def ring(graph):
	k = next(iter(graph))
	v = graph[k]
	if len(v) != 2:
		return False
	else:
		(x, y) = v
		while y in graph:
			temp = y
			(a, b) = graph[y]
			if a == x:
				x = y
				y = b
			else:
				x = y
				y = a
			del graph[temp]
		if len(graph) == 0:
			return True
		else:
			return False

def star(graph):
	count = 0
	for (k, v) in graph.items():
		if len(v) != 1:
			for i in v:
				if i in graph and len(graph[i]) == 1 and (graph[i][0] == k):
					count += 1
	if len(graph) == count + 1:
		return True
	else:
		return False
(n, m) = list(map(int, sys.stdin.readline().split()))
graph = defaultdict(list)
for i in range(0, m):
	(x, y) = list(map(int, sys.stdin.readline().split()))
	graph[x].append(y)
	graph[y].append(x)
failure = True
try:
	if star(graph):
		print('star topology')
		failure = False
except:
	pass
if failure:
	try:
		if bus(graph):
			print('bus topology')
			failure = False
	except:
		pass
if failure:
	try:
		if ring(graph):
			print('ring topology')
			failure = False
	except:
		pass
if failure:
	print('unknown topology')


(n, m) = map(int, input().split())
d = {}
for i in range(1, n + 1):
	d[i] = []
for i in range(m):
	(a, b) = map(int, input().split())
	d[a].append(b)
	d[b].append(a)
sh1 = 0
kol = 0
zvez = 0
for i in d:
	d[i] = len(d[i])
	if d[i] == 0:
		print('unknown topology')
		exit()
	if d[i] > 2:
		sh1 = 3
		kol = 2
		zvez += 1
	elif d[i] == 2:
		zvez += 1
	else:
		sh1 += 1
		kol = 2
if sh1 == 2:
	print('bus topology')
elif kol == 0:
	print('ring topology')
elif zvez == 1:
	print('star topology')
else:
	print('unknown topology')


import math
import sys
from collections import defaultdict
from collections import Counter
from collections import deque
import bisect
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]
INF = 10 ** 18
MOD = 10 ** 9 + 7
(n, m) = ilele()
A = []
G = defaultdict(list)
D = []
for i in range(m):
	(a, b) = ilele()
	G[a].append(b)
	G[b].append(a)
	D.append(a)
	D.append(b)
	A.append((a, b))
C = Counter(D)
g = C.most_common(1)[0][1]
if g == m:
	print('star topology')
else:
	f = 0
	c = 0
	for (i, j) in G.items():
		if len(j) > 2:
			f = 1
			break
		elif len(j) == 1:
			c += 1
	if f == 1:
		print('unknown topology')
	elif c == 2:
		print('bus topology')
	elif c == 0:
		print('ring topology')
	else:
		print('unknown topology')


import sys
import math
(n, m) = map(int, input().split())
degree = [0] * (n + 1)
for _ in range(0, int(m)):
	(a, b) = map(int, input().split())
	degree[a] = degree[a] + 1
	degree[b] = degree[b] + 1
if degree.count(1) == 2 and degree.count(2) == n - 2:
	print('bus topology')
elif degree.count(2) == n:
	print('ring topology')
elif degree.count(1) == n - 1 and degree.count(n - 1) == 1:
	print('star topology')
else:
	print('unknown topology')


(n, m) = [int(i) for i in input().split()]
s = []
for i in range(n + 1):
	s.append([])
for i in range(m):
	(x, y) = [int(i) for i in input().split()]
	s[x].append(y)
	s[y].append(x)
sbool = [False] * (n + 1)
v2 = 0
v1 = 0
other = 0

def dfs(new):
	global sbool, s, v2, v1, other
	sbool[new] = True
	if len(s[new]) == 1:
		v1 += 1
	elif len(s[new]) == 2:
		v2 += 1
	else:
		other += 1
for i in range(1, n + 1):
	dfs(i)
if v1 == 2 and v2 == n - 2:
	print('bus topology')
elif v1 == n - 1 and other == 1:
	print('star topology')
elif v2 == n:
	print('ring topology')
else:
	print('unknown topology')


from collections import Counter
(n, m) = map(int, input().split())
graph = [[] for _ in range(n)]
for _ in range(m):
	(a, b) = map(int, input().split())
	graph[a - 1].append(b - 1)
	graph[b - 1].append(a - 1)
cnt = dict(Counter(map(len, graph)))
if cnt == {2: n}:
	print('ring topology')
elif cnt == {2: n - 2, 1: 2}:
	print('bus topology')
elif cnt == {1: n - 1, n - 1: 1}:
	print('star topology')
else:
	print('unknown topology')


(n, m) = [int(i) for i in input().split()]
degrees = [0] * n
for i in range(m):
	(x, y) = [int(i) for i in input().split()]
	degrees[x - 1] += 1
	degrees[y - 1] += 1
ones = degrees.count(1)
twos = degrees.count(2)
like_stars = degrees.count(n - 1)
if ones == 2 and twos == n - 2:
	print('bus topology')
elif twos == n:
	print('ring topology')
elif like_stars == 1 and ones == n - 1:
	print('star topology')
else:
	print('unknown topology')


R = lambda : map(int, input().split())
(n, m) = R()
c = [0] * n
for i in range(m):
	(x, y) = R()
	c[x - 1] += 1
	c[y - 1] += 1
c1 = c2 = 0
for i in range(n):
	if c[i] == 1:
		c1 += 1
	elif c[i] == 2:
		c2 += 1
if c2 == n:
	print('ring topology')
elif c1 == 2 and c2 == n - 2:
	print('bus topology')
elif c1 == n - 1:
	print('star topology')
else:
	print('unknown topology')


(n, m) = [int(k) for k in input().split()]
ans = 'bus topology'
dict = {}
count = 0
t = 0
if m >= n - 1:
	for i in range(m):
		(first, second) = [int(k) for k in input().split()]
		if first not in dict:
			dict[first] = set()
			dict[first].add(second)
		else:
			if len(dict[first]) == 1:
				count += 1
			else:
				t += 1
			dict[first].add(second)
		if second not in dict:
			dict[second] = set()
			dict[second].add(first)
		else:
			if len(dict[second]) == 1:
				count += 1
			else:
				t += 1
			dict[second].add(first)
if count == n - 2 and m == n - 1:
	print('bus topology')
elif count == 1:
	print('star topology')
elif count == n and t == 0:
	print('ring topology')
else:
	print('unknown topology')


def solve():
	(n, m) = map(int, input().split())
	if n not in (m, m + 1):
		return 3
	l = [0] * (n + 1)
	for _ in range(m):
		(x, y) = map(int, input().split())
		l[x] += 1
		l[y] += 1
	c2 = l.count(2)
	if m == n == c2:
		return 1
	if m == n - 1:
		c1 = l.count(1)
		if c1 == 2 and c2 == n - 2:
			return 0
		if c1 == m and m in l:
			return 2
	return 3

def main():
	print(('bus', 'ring', 'star', 'unknown')[solve()], 'topology')
main()


def buscheck(array, z):
	if amount.count(1) == 2 and amount.count(2) == m - 2:
		return 1
	return 0

def ringcheck(array, z):
	if amount.count(2) == m:
		return 1
	return 0

def starcheck(array, z):
	if amount.count(1) == m - 1 and amount.count(m - 1) == 1:
		return 1
	return 0
(m, n) = [int(x) for x in input().split()]
connect = [[] for i in range(m + 1)]
for i in range(n):
	(a, b) = [int(x) for x in input().split()]
	connect[a].append(b)
	connect[b].append(a)
amount = []
for i in range(1, m + 1):
	amount.append(len(connect[i]))
if starcheck(connect, n):
	print('star topology')
elif ringcheck(connect, n):
	print('ring topology')
elif buscheck(connect, n):
	print('bus topology')
else:
	print('unknown topology')


(n, m) = map(int, input().split())
g = [0 for _ in range(n)]
for _ in range(m):
	(x, y) = map(int, input().split())
	g[x - 1] += 1
	g[y - 1] += 1
if m == n and max(g) == min(g) == 2:
	print('ring topology')
elif m == n - 1 and max(g) < 3:
	print('bus topology')
elif m == n - 1 and max(g) == n - 1:
	print('star topology')
else:
	print('unknown topology')


(n, m) = map(int, input().split())
d = dict()
maxi = 0
maxv = 0
for _ in range(m):
	(a, b) = map(int, input().split())
	if a - 1 in d:
		d[a - 1] += 1
	else:
		d[a - 1] = 1
	if b - 1 in d:
		d[b - 1] += 1
	else:
		d[b - 1] = 1
	if d[a - 1] > maxv:
		maxv = d[a - 1]
		maxi = a - 1
	if d[b - 1] > maxv:
		maxv = d[b - 1]
		maxi = b - 1
if m + 1 == n:
	if maxv == m:
		print('star topology')
	elif maxv == 2:
		print('bus topology')
	else:
		print('unknown topology')
elif m == n:
	if maxv == 2:
		print('ring topology')
	else:
		print('unknown topology')
else:
	print('unknown topology')


(n, m) = map(int, input().split())
adj = dict()
for i in range(m):
	(u, v) = map(int, input().split())
	if u not in adj:
		adj[u] = set()
	if v not in adj:
		adj[v] = set()
	adj[u].add(v)
	adj[v].add(u)
mark = [0] * (n + 1)
mark[0] = 1
start = 1
topology = 'unknown'
one = 0
two = 0
em = 0
oth = 0
for (k, v) in adj.items():
	if len(v) == 1:
		one += 1
	elif len(v) == 2:
		two += 1
	elif len(v) == m:
		em += 1
	else:
		oth += 1
if one == 2 and two == n - 2:
	topology = 'bus'
elif two == n:
	topology = 'ring'
elif em == 1 and n - 1 == one:
	topology = 'star'
print(topology + ' topology')


from collections import defaultdict

def check_bus(g, n):
	v0 = None
	e0 = None
	for (v, elist) in g.items():
		if len(elist) == 1:
			v0 = v
			e0 = elist[0]
			n -= 1
			break
	else:
		return False
	vpred = v0
	v = e0
	while len(g[v]) == 2:
		for e in g[v]:
			if e != vpred:
				vpred = v
				v = e
				break
		n -= 1
	if n != 1:
		return False
	return len(g[v]) == 1

def check_ring(g, n):
	v0 = list(g.keys())[0]
	if len(g[v0]) != 2:
		return False
	n -= 1
	e_back = g[v0][0]
	vpred = v0
	v = g[v0][1]
	while v != v0 and len(g[v]) == 2:
		for e in g[v]:
			if e != vpred:
				vpred = v
				v = e
				break
		n -= 1
		if n < 0:
			return False
	return n == 0

def check_star(g, n):
	v0 = None
	el = None
	for (v, elist) in g.items():
		if len(elist) == n - 1:
			v0 = v
			el = elist
			break
	else:
		return False
	for e in el:
		if len(g[e]) != 1:
			return False
	else:
		return True
(v, e) = [int(x) for x in input().split()]
gd = defaultdict(list)
vset = set()
for _ in range(e):
	(v1, v2) = [int(x) for x in input().split()]
	gd[v1].append(v2)
	gd[v2].append(v1)
	vset.update((v1, v2))
vnum = len(vset)
if check_bus(gd, vnum):
	print('bus topology')
elif check_ring(gd, vnum):
	print('ring topology')
elif check_star(gd, vnum):
	print('star topology')
else:
	print('unknown topology')


(n, m) = map(int, input().split())
a = [0] * n
for i in range(m):
	(x, y) = map(int, input().split())
	a[x - 1] += 1
	a[y - 1] += 1
count2 = 0
count1 = 0
hi = 0
while 1:
	for i in range(len(a)):
		if a[i] == 1:
			count1 += 1
		elif a[i] == 2:
			count2 += 1
		hi = max(hi, a[i])
	if count1 == 2 and count2 == n - 2:
		print('bus topology')
		break
	if count1 == n - 1 and hi == n - 1:
		print('star topology')
		break
	if count2 == n:
		print('ring topology')
		break
	else:
		print('unknown topology')
		break


(n, m) = map(int, input().split())
a = []
for i in range(0, n + 1):
	a.append([])
for i in range(m):
	(i, j) = map(int, input().split())
	a[i].append(j)
	a[j].append(i)
c = 0
d = 0
f = 0
for el in a:
	if len(el) == 1:
		c += 1
	elif len(el) == 2:
		d += 1
	elif len(el) == n - 1:
		f += 1
if c == 2 and d == n - 2:
	print('bus topology')
elif d == n:
	print('ring topology')
elif f == 1 and c == n - 1:
	print('star topology')
else:
	print('unknown topology')


(n, m) = map(int, input().split())
l = []
for i in range(n):
	l.append(0)
for i in range(m):
	(a, b) = map(int, input().split())
	l[a - 1] += 1
	l[b - 1] += 1
m = list(set(l))
if len(m) == 2 and max(l) == 2 and (min(l) == 1) and (l.count(min(l)) == 2):
	print('bus topology')
elif len(m) == 1 and max(l) == 2:
	print('ring topology')
elif len(m) == 2 and max(l) == n - 1 and (l.count(min(l)) == n - 1) and (min(l) == 1):
	print('star topology')
else:
	print('unknown topology')


I = lambda : map(int, input().split())
(n, m) = I()
a = [0] * n
for i in range(m):
	(x, y) = I()
	a[x - 1] += 1
	a[y - 1] += 1
s = set(a)
o = 'unknown'
if s == {2}:
	o = 'ring'
if s == {1, 2}:
	o = 'bus'
if s == {1, m}:
	o = 'star'
print(o, 'topology')


from array import array
from collections import Counter
(n, m) = list(map(int, input().split()))
a = array('L')
a.extend((0 for i in range(n)))
for i in range(m):
	(x, y) = list(map(int, input().split()))
	a[x - 1] += 1
	a[y - 1] += 1
ca = array('L')
ca.extend((0 for i in range(max(a) + 1)))
for i in a:
	ca[i] += 1

def c(i):
	if i >= len(ca) or i < 0:
		return 0
	else:
		return ca[i]
if c(1) == 2 and c(2) == n - 2:
	print('bus topology')
elif c(2) == n:
	print('ring topology')
elif c(1) == n - 1 and c(n - 1) == 1:
	print('star topology')
else:
	print('unknown topology')


(n, m) = map(int, input().split())
arr = [0] * (n + 1)
for w in range(m):
	(a, b) = map(int, input().split())
	arr[a] += 1
	arr[b] += 1
c1 = 0
c2 = 0
cs = 0
for i in range(1, n + 1):
	if arr[i] == 1:
		c1 += 1
	if arr[i] == 2:
		c2 += 1
	if arr[i] == n - 1:
		cs += 1
if c1 == 2 and c2 == n - 2:
	print('bus topology')
elif c2 == n:
	print('ring topology')
elif c1 == n - 1 and cs == 1:
	print('star topology')
else:
	print('unknown topology')


(n, m) = map(int, input().split())
a = []
for h in range(0, n + 1):
	a.append([])
for i in range(m):
	(k, j) = map(int, input().split())
	a[k].append(j)
	a[j].append(k)
d2 = 0
d1 = 0
d3 = 0
for u in a:
	if len(u) == 1:
		d1 += 1
	if len(u) == 2:
		d2 += 1
	if len(u) == n - 1:
		d3 += 1
if d1 == 2 and d2 == n - 2:
	print('bus topology')
elif d3 == 1 and d1 == n - 1:
	print('star topology')
elif d2 == n:
	print('ring topology')
else:
	print('unknown topology')


(n, m) = map(int, input().split())
adj = [[] for i in range(n + 1)]
for i in range(m):
	(a, b) = map(int, input().split())
	adj[a].append(b)
	adj[b].append(a)
edgeCount = [0]
for i in range(1, n + 1):
	edgeCount.append(len(adj[i]))
edgeCountCount = [0 for i in range(n + 1)]
for i in edgeCount:
	edgeCountCount[i] += 1
if edgeCountCount[1] == 2 and edgeCountCount[2] == n - 2:
	print('bus topology')
elif edgeCountCount[2] == m:
	print('ring topology')
elif edgeCountCount[1] == m and edgeCountCount[m] == 1:
	print('star topology')
else:
	print('unknown topology')


__author__ = 'artyom'
read = lambda : map(int, input().split())
(n, m) = read()
graph = [set() for _ in range(1 + n)]
degrees = [0] * (n + 1)
for __ in range(m):
	(u, v) = read()
	graph[u].add(v)
	graph[v].add(u)
	degrees[u] += 1
	degrees[v] += 1

def dfs(start):
	stack = [(start, None)]
	visited = [0] * (n + 1)
	while stack:
		(v, parent) = stack.pop()
		if degrees[v] > 2:
			return 'star' if all([degrees[u] == 1 for u in graph[v]]) else 'unknown'
		for u in graph[v]:
			if u != parent:
				if visited[u]:
					return 'ring' if u == start else 'unknown'
				stack.append((u, v))
		visited[v] = 1
	return 'bus'
print(dfs(1) + ' topology')


from collections import defaultdict
I = lambda : map(int, input().split())
degrees = defaultdict(int)
(n, m) = I()
for _ in range(m):
	(u, v) = I()
	degrees[u] += 1
	degrees[v] += 1
values = set(degrees.values())
answer = 'unknown'
if values == {2}:
	answer = 'ring'
elif values == {1, 2}:
	answer = 'bus'
elif values == {1, m}:
	answer = 'star'
print(answer, 'topology')


(n, m) = map(int, input().split())
g = {}
for _ in range(m):
	(a, b) = map(int, input().split())
	if a not in g:
		g[a] = set()
	if b not in g:
		g[b] = set()
	g[a].add(b)
	g[b].add(a)
n1 = []
n2 = []
for k in range(1, n + 1):
	if len(g[k]) == 1:
		n1.append(k)
	elif len(g[k]) == 2:
		n2.append(k)
if len(n1) == 2 and len(n2) == n - 2:
	print('bus topology')
	quit()
n1 = []
for k in range(1, n + 1):
	if len(g[k]) == 2:
		n1.append(k)
if len(n1) == n:
	print('ring topology')
	quit()
n1 = []
n2 = []
for k in range(1, n + 1):
	if len(g[k]) == 1:
		n1.append(k)
	else:
		n2.append(k)
if len(n1) == n - 1 and len(g[n2[0]]) == n - 1:
	print('star topology')
	quit()
print('unknown topology')


(n, m) = (int(x) for x in input().split())
cnt = [0] * n
for i in range(m):
	(u, v) = (int(x) for x in input().split())
	cnt[u - 1] += 1
	cnt[v - 1] += 1
if cnt.count(1) == n - 1:
	print('star topology')
elif cnt.count(2) == n:
	print('ring topology')
elif cnt.count(1) == 2 and cnt.count(2) == n - 2:
	print('bus topology')
else:
	print('unknown topology')


(n, m) = map(int, input().split())
v = []

def chek_star(v):
	t = 0
	for i in v:
		if i != 1:
			t += 1
	if t == 1:
		return True
	return False
for i in range(n):
	v.append(0)
for i in range(m):
	(t1, t2) = map(int, input().split())
	v[t1 - 1] += 1
	v[t2 - 1] += 1
if max(v) == 2 and min(v) == 2:
	print('ring topology')
elif set(v) == set([1, 2]):
	print('bus topology')
elif set(v) == set([1, max(v)]) and chek_star(v):
	print('star topology')
else:
	print('unknown topology')


(n, m) = list(map(int, input().split()))
d = dict()
for i in range(m):
	(x, y) = list(map(int, input().split()))
	if x in d:
		d[x].add(y)
	else:
		d[x] = set()
		d[x].add(y)
	if y in d:
		d[y].add(x)
	else:
		d[y] = set()
		d[y].add(x)
x = 0
y = 0
z = 0
for i in d:
	if len(d[i]) == 1:
		x += 1
	elif len(d[i]) == 2:
		y += 1
	elif len(d[i]) == m:
		z += 1
if x == n - 1 and y == 0 and (z == 1):
	print('star topology')
elif x == 2 and y == n - 2 and (z == 0):
	print('bus topology')
elif x == 0 and y == n and (z == 0):
	print('ring topology')
else:
	print('unknown topology')


(n, m) = map(int, input().split())
graph = {i: [] for i in range(1, n + 1)}
for i in range(m):
	(start, end) = map(int, input().split())
	graph[start].append(end)
	graph[end].append(start)
length_array = []
for i in graph:
	length_array.append(len(graph[i]))
if min(length_array) == max(length_array) and max(length_array) == 2:
	print('ring topology')
elif length_array.count(1) == 2 and length_array.count(2) == n - 2:
	print('bus topology')
elif max(length_array) == m and m == n - 1:
	print('star topology')
else:
	print('unknown topology')


(n, m) = map(int, input().split())
l = [0] * n
for i in range(m):
	(x, y) = map(int, input().split())
	l[x - 1] += 1
	l[y - 1] += 1
l.sort()
if [1] * 2 + [2] * (n - 2) == l:
	print('bus topology')
elif [2] * n == l:
	print('ring topology')
elif [1] * (n - 1) + [n - 1] == l:
	print('star topology')
else:
	print('unknown topology')


import sys
from math import ceil, floor, log2, sqrt

def readall():
	return [int(x) for x in sys.stdin.read().split()]

def u():
	return [int(i) for i in sys.stdin.readline().split()]
(n, m) = u()
deg = [0] * (n + 1)
for _ in range(m):
	(a, b) = u()
	deg[a] += 1
	deg[b] += 1
ring = star = bus = True
oneCount = 0
for j in range(1, n + 1):
	if deg[j] != 2:
		ring = False
	if deg[j] > 2:
		bus = False
		if deg[j] != n - 1 or m != n - 1:
			star = False
ans = ''
if ring:
	ans += 'ring'
elif bus:
	ans += 'bus'
elif star:
	ans += 'star'
else:
	ans += 'unknown'
print(ans + ' topology')


from collections import defaultdict, Counter
(N, M) = map(int, input().split())
AdjList = defaultdict(int)
for i in range(M):
	(a, b) = map(int, input().split())
	AdjList[a] += 1
	AdjList[b] += 1
CheckList = []
for i in AdjList.values():
	CheckList.append(i)
Freq = Counter(CheckList)
if len(Freq.values()) == 1 and Freq[2] != 0:
	print('ring topology')
elif len(Freq.values()) == 2 and Freq[1] == 2 and (Freq[2] != 0):
	print('bus topology')
elif len(Freq.values()) == 2 and Freq[1] == N - 1:
	print('star topology')
else:
	print('unknown topology')


import sys
inp = lambda : sys.stdin.readline()
(n, m) = map(int, inp().split())
d = [0] * n
for _ in range(m):
	(x, y) = map(int, inp().split())
	d[x - 1] += 1
	d[y - 1] += 1
maxm = max(d)
minm = min(d)
maxm_count = d.count(maxm)
minm_count = d.count(minm)
if maxm == 2 and maxm_count == n - 2 and (minm == 1) and (minm_count == 2) or (n == 2 and maxm == 1 and (minm == 1)):
	print('bus topology')
elif maxm == minm == 2 and maxm_count == n:
	print('ring topology')
elif maxm == n - 1 and maxm_count == 1 and (minm == 1) and (minm_count == n - 1):
	print('star topology')
else:
	print('unknown topology')


v = input().split()
n = int(v[0])
m = int(v[1])
c = {}
for i in range(n):
	c[i + 1] = 0
for i in range(m):
	b = input().split()
	c[int(b[0])] += 1
	c[int(b[1])] += 1
flag1 = 0
flag2 = 0
for i in c:
	if c[i] == 2:
		flag1 += 1
	if c[i] == m:
		print('star topology')
		exit()
	if c[i] == 1:
		flag2 += 1
if flag1 == n:
	print('ring topology')
elif flag2 == 2 and flag1 == n - 2:
	print('bus topology')
else:
	print('unknown topology')


(n, m) = map(int, input().split())
c = [0 for _ in range(n)]
for _ in range(m):
	(a, b) = map(int, input().split())
	c[a - 1] += 1
	c[b - 1] += 1
s = set(c)
res = 'unknown'
if s == {2}:
	res = 'ring'
elif s == {1, 2}:
	res = 'bus'
elif s == {1, m}:
	res = 'star'
print(res + ' topology')


(n, m) = map(int, input().split())
p = [0] * (n + 1)
for i in range(m):
	(a, b) = map(int, input().split())
	p[a] += 1
	p[b] += 1
ans = 'unknown topology'
if n == m:
	if p.count(2) == n:
		ans = 'ring topology'
elif n == m + 1:
	if n - 1 in p:
		ans = 'star topology'
	elif p.count(1) == 2 and p.count(2) == n - 2:
		ans = 'bus topology'
print(ans)


(n, m) = map(int, input().split())
d = [0] * (n + 1)
for i in range(m):
	(a, b) = map(int, input().split())
	d[a] += 1
	d[b] += 1
count = 0
count2 = 0
count3 = -1
for i in d:
	if i == 1:
		count += 1
	elif i == 2:
		count2 += 1
	else:
		count3 += 1
if count == 0 and count2 == n and (count3 == 0):
	print('ring topology')
elif count == n - 1 and count2 == 0 and (count3 == 1):
	print('star topology')
elif count == 2 and count2 == n - 2 and (count3 == 0):
	print('bus topology')
else:
	print('unknown topology')