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

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

h = A("h")
b = B("b")
m = B("m")
f = A("f")
k = A("k")
n = B("n")
e = A("e")
l = B("l")
c = A("c")

h.r = e
h.s = f
b.r = n
b.x = l
m.r = b
m.x = l
f.r = h
f.s = c
k.r = h
k.s = f
n.r = b
n.x = l
e.r = h
e.s = h
l.r = b
l.x = m
c.r = f
c.s = e
assert e.r.r.r.s.s.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.s: A = None
        self.txt = txt

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

h = A("h")
b = B("b")
m = B("m")
f = A("f")
k = A("k")
n = B("n")
e = A("e")
l = B("l")
c = A("c")

h.r = e
h.s = f
b.r = n
b.x = l
m.r = b
m.x = l
f.r = h
f.s = c
k.r = h
k.s = f
n.r = b
n.x = l
e.r = h
e.s = h
l.r = b
l.x = m
c.r = f
c.s = e
assert e.r.r.r.s.s.s.r.txt == "h"