class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.r: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

c = A("c")
m = B("m")
a = B("a")
i = A("i")
f = B("f")
n = B("n")
l = B("l")
b = B("b")
h = A("h")

c.u = h
c.r = m
m.o = h
a.o = h
i.u = c
i.r = b
f.o = i
n.o = h
l.o = i
b.o = c
h.u = c
h.r = f
assert n.o.r.o.u.r.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.r: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

c = A("c")
m = B("m")
a = B("a")
i = A("i")
f = B("f")
n = B("n")
l = B("l")
b = B("b")
h = A("h")

c.u = h
c.r = m
m.o = h
a.o = h
i.u = c
i.r = b
f.o = i
n.o = h
l.o = i
b.o = c
h.u = c
h.r = f
assert n.o.r.o.u.r.o.u.txt == "c"