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

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

f = A("f")
c = B("c")
d = A("d")
i = A("i")
g = A("g")
a = B("a")
k = B("k")
m = B("m")
j = B("j")
n = A("n")

f.r = g
f.o = i
c.u = d
c.r = k
d.r = i
d.o = g
i.r = n
i.o = n
g.r = n
g.o = f
a.u = d
a.r = m
k.u = g
k.r = c
m.u = d
m.r = a
j.u = f
j.r = k
n.r = d
n.o = d
assert n.r.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.o: A = None
        self.txt = txt

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

f = A("f")
c = B("c")
d = A("d")
i = A("i")
g = A("g")
a = B("a")
k = B("k")
m = B("m")
j = B("j")
n = A("n")

f.r = g
f.o = i
c.u = d
c.r = k
d.r = i
d.o = g
i.r = n
i.o = n
g.r = n
g.o = f
a.u = d
a.r = m
k.u = g
k.r = c
m.u = d
m.r = a
j.u = f
j.r = k
n.r = d
n.o = d
assert n.r.o.o.txt == "f"