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

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

c = A("c")
d = B("d")
h = A("h")
i = A("i")
l = A("l")
a = B("a")
k = A("k")
e = B("e")

c.s = h
c.r = h
d.v = h
d.x = i
h.s = c
h.r = k
i.s = c
i.r = l
l.s = h
l.r = h
a.v = k
a.x = h
k.s = i
k.r = h
e.v = l
e.x = k
assert l.s.r.r.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.r: A = None
        self.txt = txt

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

c = A("c")
d = B("d")
h = A("h")
i = A("i")
l = A("l")
a = B("a")
k = A("k")
e = B("e")

c.s = h
c.r = h
d.v = h
d.x = i
h.s = c
h.r = k
i.s = c
i.r = l
l.s = h
l.r = h
a.v = k
a.x = h
k.s = i
k.r = h
e.v = l
e.x = k
assert l.s.r.r.s.s.s.txt == "c"