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.t: A = None
        self.s: B = None
        self.txt = txt

i = A("i")
e = B("e")
a = B("a")
f = B("f")
m = A("m")
k = A("k")
j = B("j")
l = B("l")

i.r = k
i.o = m
e.t = k
e.s = j
a.t = k
a.s = j
f.t = k
f.s = a
m.r = i
m.o = i
k.r = m
k.o = i
j.t = m
j.s = l
l.t = i
l.s = a
assert k.o.r.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.t: A = None
        self.s: B = None
        self.txt = txt

i = A("i")
e = B("e")
a = B("a")
f = B("f")
m = A("m")
k = A("k")
j = B("j")
l = B("l")

i.r = k
i.o = m
e.t = k
e.s = j
a.t = k
a.s = j
f.t = k
f.s = a
m.r = i
m.o = i
k.r = m
k.o = i
j.t = m
j.s = l
l.t = i
l.s = a
assert k.o.r.o.txt == "i"