#ifndef CORELIB___NCBI_PARAM__HPP
#define CORELIB___NCBI_PARAM__HPP

/*  $Id: ncbi_param.hpp 89739 2020-04-20 13:34:35Z grichenk $
 * ===========================================================================
 *
 *                            PUBLIC DOMAIN NOTICE
 *               National Center for Biotechnology Information
 *
 *  This software/database is a "United States Government Work" under the
 *  terms of the United States Copyright Act.  It was written as part of
 *  the author's official duties as a United States Government employee and
 *  thus cannot be copyrighted.  This software/database is freely available
 *  to the public for use. The National Library of Medicine and the U.S.
 *  Government have not placed any restriction on its use or reproduction.
 *
 *  Although all reasonable efforts have been taken to ensure the accuracy
 *  and reliability of the software and data, the NLM and the U.S.
 *  Government do not and cannot warrant the performance or results that
 *  may be obtained by using this software or data. The NLM and the U.S.
 *  Government disclaim all warranties, express or implied, including
 *  warranties of performance, merchantability or fitness for any particular
 *  purpose.
 *
 *  Please cite the author in any work or product based on this material.
 *
 * ===========================================================================
 *
 * Authors:  Eugene Vasilchenko, Aleksey Grichenko
 *
 * File Description:
 *   Parameters storage interface
 *
 */

/// @file ncbiparam.hpp
/// Classes for storing parameters.
///


#include <corelib/ncbiapp_api.hpp>
#include <corelib/ncbithr.hpp>
#include <atomic>


/** @addtogroup Param
 *
 * @{
 */


BEGIN_NCBI_SCOPE


/////////////////////////////////////////////////////////////////////////////
///
/// Usage of the parameters:
///
/// - Declare the parameter with NCBI_PARAM_DECL (NCBI_PARAM_ENUM_DECL for
///   enums):
///   NCBI_PARAM_DECL(int, MySection, MyIntParam);
///   NCBI_PARAM_DECL(string, MySection, MyStrParam);
///   NCBI_PARAM_ENUM_DECL(EMyEnum, MySection, MyEnumParam);
///
/// - Add parameter definition (this will also generate static data):
///   NCBI_PARAM_DEF(int, MySection, MyIntParam, 12345);
///   NCBI_PARAM_DEF(string, MySection, MyStrParam, "Default string value");
///
/// - For enum parameters define mappings between strings and values
///   before defining the parameter:
///   NCBI_PARAM_ENUM_ARRAY(EMyEnum, MySection, MyEnumParam)
///   {
///       {"My_A", eMyEnum_A},
///       {"My_B", eMyEnum_B},
///       {"My_C", eMyEnum_C}
///   };
///
///   NCBI_PARAM_ENUM_DEF(EMyEnum, MySection, MyEnumParam, eMyEnum_B);
///
/// - Use NCBI_PARAM_TYPE() as parameter type:
///   NCBI_PARAM_TYPE(MySection, MyIntParam)::GetDefault();
///   typedef NCBI_PARAM_TYPE(MySection, MyStrParam) TMyStrParam;
///   TMyStrParam str_param; str_param.Set("Local string value");
///


/////////////////////////////////////////////////////////////////////////////
///
/// Parameter declaration and definition macros
///
/// Each parameter must be declared and defined using the macros
///


// Internal definitions
#define X_NCBI_PARAM_DECLNAME(section, name)                                \
    SNcbiParamDesc_##section##_##name

#define X_NCBI_PARAM_DECLNAME_SCOPE(scope, section, name)                   \
    scope::SNcbiParamDesc_##section##_##name

#define X_NCBI_PARAM_ENUMNAME(section, name)                                \
    s_EnumData_##section##_##name

// Common part of the param description structure. 'desctype' can be
// SParamDescription or SParamEnumDescription.
#define X_NCBI_PARAM_DESC_DECL(type, desctype, tagtype)                     \
    {                                                                       \
        typedef tagtype TTagType;                                           \
        typedef type TValueType;                                            \
        typedef desctype<TValueType> TDescription;                          \
        typedef TDescription::TStaticValue TStaticValue;                    \
        typedef CStaticTls< type > TTls;                                    \
        static TDescription sm_ParamDescription;                            \
        static TStaticValue sm_Default;                                     \
        static bool sm_DefaultInitialized;                                  \
        static TTls sm_ValueTls;                                            \
        static CParamBase::EParamState sm_State;                            \
        static CParamBase::EParamSource sm_Source;                          \
    }

// Common definitions related to enum parser.
// 'ptype' is the final parameter type used to make the parser unique even
// if the same enum is used by another parameter.
#define X_NCBI_PARAM_ENUM_PARSER_DECL(type, ptype)                          \
    EMPTY_TEMPLATE inline                                                   \
    CParamParser< SParamEnumDescription< type >, ptype >::TValueType        \
    CParamParser< SParamEnumDescription< type >, ptype >::                  \
    StringToValue(const string&     str,                                    \
                  const TParamDesc& descr)                                  \
    { return CEnumParser< type, ptype >::StringToEnum(str, descr); }        \
    EMPTY_TEMPLATE inline string                                            \
    CParamParser< SParamEnumDescription< type >, ptype >::                  \
    ValueToString(const TValueType& val,                                    \
                  const TParamDesc& descr)                                  \
    { return CEnumParser< type, ptype >::EnumToString(val, descr); }

// Definition of SNcbiParamDesc_XXXX static members common for normal
// and enum parameters.
#define X_NCBI_PARAM_STATIC_DEF(descname, defval)                           \
    descname::TStaticValue descname::sm_Default = defval;                   \
    bool descname::sm_DefaultInitialized = false;                           \
    descname::TTls descname::sm_ValueTls;                                   \
    CParamBase::EParamState descname::sm_State = CParamBase::eState_NotSet; \
    CParamBase::EParamSource descname::sm_Source = CParamBase::eSource_NotSet


/// Generate typename for a parameter from its {section, name} attributes
#define NCBI_PARAM_TYPE(section, name)                                      \
    CParam< X_NCBI_PARAM_DECLNAME(section, name) >


/// Parameter declaration. Generates struct for storing the parameter.
/// Section and name may be used to set default value through a
/// registry or environment variable section_name.
/// @sa NCBI_PARAM_DEF
#define NCBI_PARAM_DECL(type, section, name)                                \
    struct X_NCBI_PARAM_DECLNAME(section, name)                             \
    X_NCBI_PARAM_DESC_DECL(type, SParamDescription, type)


/// Same as NCBI_PARAM_DECL but with export specifier (e.g. NCBI_XNCBI_EXPORT)
/// @sa NCBI_PARAM_DECL
#define NCBI_PARAM_DECL_EXPORT(expname, type, section, name)                \
    struct expname X_NCBI_PARAM_DECLNAME(section, name)                     \
    X_NCBI_PARAM_DESC_DECL(type, SParamDescription, type)


/// Enum parameter declaration. In addition to NCBI_PARAM_DECL also
/// specializes CParamParser<type, ptype> to convert between strings and
/// enum values.
/// @attention 
/// Only use this macro in the global or "ncbi" namespace, otherwise you will
/// get compilation errors. Using this macro in the said namespaces will not 
/// affect usability of a created CParamParser<type, ptype> specialization
/// from other namespaces.
/// @sa NCBI_PARAM_ENUM_ARRAY
/// @sa NCBI_PARAM_ENUM_DEF
#define NCBI_PARAM_ENUM_DECL(type, section, name)                             \
    struct X_NCBI_PARAM_DECLNAME(section, name);                              \
    X_NCBI_PARAM_ENUM_PARSER_DECL(type, X_NCBI_PARAM_DECLNAME(section, name)) \
    struct X_NCBI_PARAM_DECLNAME(section, name)                               \
    X_NCBI_PARAM_DESC_DECL(type, SParamEnumDescription,                       \
        X_NCBI_PARAM_DECLNAME(section, name))


/// Same as NCBI_PARAM_ENUM_DECL but with export specifier (e.g. NCBI_XNCBI_EXPORT)
/// @attention 
/// Only use this macro in the global or "ncbi" namespace, otherwise you will
/// get compilation errors. Using this macro in the said namespaces will not 
/// affect usability of a created CParamParser<type, ptype> specialization
/// from other namespaces.
/// @sa NCBI_PARAM_ENUM_DECL
#define NCBI_PARAM_ENUM_DECL_EXPORT(expname, type, section, name)             \
    struct expname X_NCBI_PARAM_DECLNAME(section, name);                      \
    X_NCBI_PARAM_ENUM_PARSER_DECL(type, X_NCBI_PARAM_DECLNAME(section, name)) \
    struct expname X_NCBI_PARAM_DECLNAME(section, name)                       \
    X_NCBI_PARAM_DESC_DECL(type, SParamEnumDescription,                       \
        X_NCBI_PARAM_DECLNAME(section, name))


/// Parameter definition. "default_value" is used to set the initial parameter
/// value, which may be overriden by registry or environment. The default value
/// must be a scalar literal for the default value to be initialized statically.
/// @sa NCBI_PARAM_DECL
#define NCBI_PARAM_DEF(type, section, name, default_value)                  \
    SParamDescription< type >                                               \
    X_NCBI_PARAM_DECLNAME(section, name)::sm_ParamDescription =             \
        { #section, #name, 0, default_value, NULL, eParam_Default };        \
    X_NCBI_PARAM_STATIC_DEF(X_NCBI_PARAM_DECLNAME(section, name),           \
        default_value)


/// Parameter definition. The same as NCBI_PARAM_DEF, but with a callback
/// used to initialize the default value.
/// @sa NCBI_PARAM_DEF
#define NCBI_PARAM_DEF_WITH_INIT(type, section, name, default_value, init)  \
    SParamDescription< type >                                               \
    X_NCBI_PARAM_DECLNAME(section, name)::sm_ParamDescription =             \
        { #section, #name, 0, default_value, init, eParam_Default };        \
    X_NCBI_PARAM_STATIC_DEF(X_NCBI_PARAM_DECLNAME(section, name),           \
        default_value)


/// Definition of a parameter with additional flags.
/// @sa NCBI_PARAM_DEF
/// @sa ENcbiParamFlags
#define NCBI_PARAM_DEF_EX(type, section, name, default_value, flags, env)   \
    SParamDescription< type >                                               \
    X_NCBI_PARAM_DECLNAME(section, name)::sm_ParamDescription =             \
        { #section, #name, #env, default_value, NULL, flags };              \
    X_NCBI_PARAM_STATIC_DEF(X_NCBI_PARAM_DECLNAME(section, name),           \
        default_value)


/// Definition of a parameter with additional flags and initialization
/// callback.
/// @sa NCBI_PARAM_DEF_WITH_INIT
/// @sa ENcbiParamFlags
#define NCBI_PARAM_DEF_EX_WITH_INIT(type, section, name, def_value, init, flags, env) \
    SParamDescription< type >                                               \
    X_NCBI_PARAM_DECLNAME(section, name)::sm_ParamDescription =             \
        { #section, #name, #env, def_value, init, flags };                  \
    X_NCBI_PARAM_STATIC_DEF(X_NCBI_PARAM_DECLNAME(section, name),           \
        def_value)


/// Similar to NCBI_PARAM_DEF except it adds "scope" (class name or 
/// namespace) to the parameter's type.
/// @sa NCBI_PARAM_DECL, NCBI_PARAM_DEF
#define NCBI_PARAM_DEF_IN_SCOPE(type, section, name, default_value, scope)   \
    SParamDescription< type >                                                \
    X_NCBI_PARAM_DECLNAME_SCOPE(scope, section, name)::sm_ParamDescription = \
        { #section, #name, 0, default_value, NULL, eParam_Default };         \
    X_NCBI_PARAM_STATIC_DEF(                                                 \
        X_NCBI_PARAM_DECLNAME_SCOPE(scope, section, name),                   \
        default_value)


// Static array of enum name+value pairs.
#define NCBI_PARAM_ENUM_ARRAY(type, section, name)                        \
    static SEnumDescription< type > X_NCBI_PARAM_ENUMNAME(section, name)[] =

/// Enum parameter definition. Additional 'enums' argument should provide
/// static array of SEnumDescription<type>.
/// @sa NCBI_PARAM_ENUM_ARRAY
#define NCBI_PARAM_ENUM_DEF(type, section, name, default_value)             \
    SParamEnumDescription< type >                                           \
    X_NCBI_PARAM_DECLNAME(section, name)::sm_ParamDescription =             \
        { #section, #name, 0, default_value, NULL, eParam_Default,          \
          X_NCBI_PARAM_ENUMNAME(section, name),                             \
          ArraySize(X_NCBI_PARAM_ENUMNAME(section, name)) };                \
    X_NCBI_PARAM_STATIC_DEF(X_NCBI_PARAM_DECLNAME(section, name),           \
        default_value)


/// Definition of an enum parameter with additional flags.
/// @sa NCBI_PARAM_ENUM_DEF
/// @sa ENcbiParamFlags
#define NCBI_PARAM_ENUM_DEF_EX(type, section, name,                         \
                               default_value, flags, env)                   \
    SParamEnumDescription< type >                                           \
    X_NCBI_PARAM_DECLNAME(section, name)::sm_ParamDescription =             \
        { #section, #name, #env, default_value, NULL, flags,                \
          X_NCBI_PARAM_ENUMNAME(section, name),                             \
          ArraySize(X_NCBI_PARAM_ENUMNAME(section, name)) };                \
    X_NCBI_PARAM_STATIC_DEF(X_NCBI_PARAM_DECLNAME(section, name),           \
        default_value)


/// Define CSafeStatic_Proxy for a non-POD type using the provided POD type
/// to store the default value.
/// NOTE: The proxy specialization must be defined in 'ncbi' namespace.
#define NCBI_PARAM_STATIC_PROXY(user_type, pod_type)                    \
    template<> class CSafeStatic_Proxy<user_type> {                     \
    public:                                                             \
        typedef user_type TValue;                                       \
        typedef pod_type TStaticInit;                                   \
        CSafeStatic_Proxy(void) {}                                      \
        CSafeStatic_Proxy(TStaticInit init) : m_Value(init) {}          \
        CSafeStatic_Proxy(TValue value) : m_Value(value) {}             \
        CSafeStatic_Proxy& operator=(TStaticInit init) {                \
            m_Value = init;                                             \
            return *this;                                               \
        }                                                               \
        CSafeStatic_Proxy& operator=(TValue value) {                    \
            m_Value = value;                                            \
            return *this;                                               \
        }                                                               \
        operator TValue& (void) { return m_Value; }                     \
    private:                                                            \
        mutable TValue m_Value;                                         \
    }


/////////////////////////////////////////////////////////////////////////////
///
/// CParamException
///
/// Exception generated by param parser

class NCBI_XNCBI_EXPORT CParamException : public CCoreException
{
public:
    enum EErrCode {
        eParserError,      ///< Can not convert string to value
        eBadValue,         ///< Unexpected parameter value
        eNoThreadValue,    ///< Per-thread value is prohibited by flags
        eRecursion         ///< Recursion while initializing param
    };

    /// Translate from the error code value to its string representation.
    virtual const char* GetErrCodeString(void) const override;

    // Standard exception boilerplate code.
    NCBI_EXCEPTION_DEFAULT(CParamException, CCoreException);
};



/////////////////////////////////////////////////////////////////////////////
///
/// CParamParser
///
/// Parameter parser template.
///
/// Used to read parameter value from registry/environment.
/// Default implementation requires TValue to be readable from and writable
/// to a stream. Optimized specializations exist for string and bool types.
/// The template is also specialized for each enum parameter.
///


template<class TDescription, class TParam>
class CParamParser
{
public:
    typedef TDescription                      TParamDesc;
    typedef typename TDescription::TValueType TValueType;

    static TValueType StringToValue(const string& str,
                                    const TParamDesc& descr);
    static string     ValueToString(const TValueType& val,
                                    const TParamDesc& descr);
};


/////////////////////////////////////////////////////////////////////////////
///
/// CParamBase
///
/// Base class to provide single static mutex for parameters.
///

class NCBI_XNCBI_EXPORT CParamBase
{
public:
    /// Current param state flag - indicates which possible sources for
    /// the param have been checked. This flag does not indicate where
    /// does the current value originate from. It just shows the stage
    /// of parameter loading process.
    /// @sa EParamSource
    enum EParamState {
        eState_NotSet = 0, ///< The param's value has not been set yet
        eState_InFunc = 1, ///< The initialization function is being executed
        eState_Func   = 2, ///< Initialized using FParamInit function
        eState_User   = 3, ///< Value has been set by user
        eState_EnvVar = 4, ///< The environment variable has been checked
        eState_Config = 5, ///< The app. config file has been checked
        eState_Error = 99  ///< Error reading param value, do not try to re-read
    };

    /// Source of the value returned by CParam::GetDefault().
    /// @sa EParamState
    enum EParamSource {
        eSource_NotSet,     ///< Not fully initialized
        eSource_Default,    ///< Hardcoded default
        eSource_Func,       ///< Initialization function
        eSource_User,       ///< User code
        eSource_EnvVar,     ///< Environment
        eSource_Config      ///< The app. config file
    };

    // Allow to disable config dump to avoid recursions/deadlocks (e.g. from SetupDiag).
    static void EnableConfigDump(bool enable);
};


/////////////////////////////////////////////////////////////////////////////
///
/// ENcbiParamFlags
///
/// CParam flags

enum ENcbiParamFlags {
    eParam_Default  = 0,       ///< Default flags
    eParam_NoLoad   = 1 << 0,  ///< Do not load from registry or environment
    eParam_NoThread = 1 << 1   ///< Do not use per-thread values
};

typedef int TNcbiParamFlags;

/// Caching default value on construction of a param
enum EParamCacheFlag {
    eParamCache_Force,  ///< Force caching currently set default value.
    eParamCache_Try,    ///< Cache the default value if the application
                        ///< registry is already initialized.
    eParamCache_Defer   ///< Do not try to cache the default value.
};

/////////////////////////////////////////////////////////////////////////////
///
/// CParam
///
/// Parameter template.
///
/// Used to store parameters with per-object values, thread-wide and
/// application-wide defaults. Global default value may be set through
/// application registry or environment.
///
/// Do not use the class directly. Create parameters through NCBI_PARAM_DECL
/// and NCBI_PARAM_DEF macros.
///

template<class TDescription>
class CParam : public CParamBase
{
public:
    typedef CParam<TDescription>                        TParam;
    typedef typename TDescription::TTagType             TTagType;
    typedef typename TDescription::TDescription         TParamDescription;
    typedef typename TParamDescription::TValueType      TValueType;
    typedef CParamParser<TParamDescription, TTagType>   TParamParser;
    typedef typename TDescription::TTls                 TTls;

    /// Create parameter with the thread default or global default value.
    /// Changing defaults does not affect the existing parameter objects.
    CParam(EParamCacheFlag cache_flag = eParamCache_Try);

    /// Create parameter with a given value, ignore defaults.
    CParam(const TValueType& val) : m_ValueSet(true), m_Value(val) {}

    /// Load parameter value from registry or environment.
    /// Overrides section and name set in the parameter description.
    /// Does not affect the existing default values.
    CParam(const string& section, const string& name);

    ~CParam(void) {}

    /// Get current state of the param.
    static EParamState GetState(bool* sourcing_complete = nullptr, EParamSource* param_source = nullptr);

    /// Get current parameter value. It is safe to get value from
    /// multiple threads, but setting a new value is not MT-safe.
    TValueType Get(void) const;
    /// Set new parameter value (this instance only).
    /// @note The method is not MT-safe. Use an additional external lock
    /// if it's necessary for multiple threads to use the same variable.
    void Set(const TValueType& val);
    /// Reset value as if it has not been initialized yet. Next call to
    /// Get() will cache the thread default (or global default) value.
    /// @note The method is not MT-safe. Use an additional external lock
    /// if it's necessary for multiple threads to use the same variable.
    void Reset(void);

    /// Get global default value. If not yet set, attempts to load the value
    /// from application registry or environment.
    static TValueType GetDefault(void);
    /// Set new global default value. Does not affect values of existing
    /// CParam<> objects or thread-local default values.
    static void SetDefault(const TValueType& val);
    /// Reload the global default value from the environment/registry
    /// or reset it to the initial value specified in NCBI_PARAM_DEF.
    static void ResetDefault(void);

    /// Get thread-local default value if set or global default value.
    static TValueType GetThreadDefault(void);
    /// Set new thread-local default value.
    static void SetThreadDefault(const TValueType& val);
    /// Reset thread default value as if it has not been set. Unless
    /// SetThreadDefault() is called, GetThreadDefault() will return
    /// global default value.
    static void ResetThreadDefault(void);

private:
    static SSystemMutex& s_GetLock(void);

    static TValueType& sx_GetDefault(bool force_reset = false);
    static TTls&       sx_GetTls    (void);
    static EParamState& sx_GetState(void);
    static EParamSource& sx_GetSource(void);

    static bool sx_IsSetFlag(ENcbiParamFlags flag);
    static bool sx_CanGetDefault(void);

    mutable atomic<bool> m_ValueSet;
    mutable TValueType m_Value;
};


/////////////////////////////////////////////////////////////////////////////
///
/// Helper functions for getting values from registry/environment
///

/// Get string configuration value.
///
/// @param section
///   Check application configuration named section first if not null.
/// @param variable
///   Variable name within application section.
///   If no value found in configuration file, environment variable with
///   name NCBI_CONFIG__section__variable or NCBI_CONFIG__variable will be
///   checked, depending on wether section is null.
/// @param env_var_name
///   If not empty, overrides the default NCBI_CONFIG__section__name
///   name of the environment variable.
/// @param default_value
///   If no value found neither in configuration file nor in environment,
///   this value will be returned, or empty string if this value is null.
/// @return
///   string configuration value.
/// @sa g_GetConfigInt(), g_GetConfigFlag()
string NCBI_XNCBI_EXPORT g_GetConfigString(const char* section,
    const char* variable,
    const char* env_var_name,
    const char* default_value,
    CParamBase::EParamSource* src = nullptr);

/// Get integer configuration value.
///
/// @param section
///   Check application configuration named section first if not null.
/// @param variable
///   Variable name within application section.
///   If no value found in configuration file, environment variable with
///   name NCBI_CONFIG__section__variable or NCBI_CONFIG__variable will be
///   checked, depending on wether section is null.
/// @param env_var_name
///   If not empty, overrides the default NCBI_CONFIG__section__name
///   name of the environment variable.
/// @param default_value
///   If no value found neither in configuration file nor in environment,
///   this value will be returned.
/// @return
///   integer configuration value.
/// @sa g_GetConfigString(), g_GetConfigFlag()
int NCBI_XNCBI_EXPORT g_GetConfigInt(const char* section,
    const char* variable,
    const char* env_var_name,
    int         default_value);

/// Get boolean configuration value.
///
/// @param section
///   Check application configuration named section first if not null.
/// @param variable
///   Variable name within application section.
///   If no value found in configuration file, environment variable with
///   name NCBI_CONFIG__section__variable or NCBI_CONFIG__variable will be
///   checked, depending on wether section is null.
/// @param env_var_name
///   If not empty, overrides the default NCBI_CONFIG__section__name
///   name of the environment variable.
/// @param default_value
///   If no value found neither in configuration file nor in environment,
///   this value will be returned.
/// @return
///   boolean configuration value.
/// @sa g_GetConfigString(), g_GetConfigInt()
bool NCBI_XNCBI_EXPORT g_GetConfigFlag(const char* section,
    const char* variable,
    const char* env_var_name,
    bool        default_value);


/// Get double configuration value.
///
/// @param section
///   Check application configuration named section first if not null.
/// @param variable
///   Variable name within application section.
///   If no value found in configuration file, environment variable with
///   name NCBI_CONFIG__section__variable or NCBI_CONFIG__variable will be
///   checked, depending on wether section is null.
/// @param env_var_name
///   If not empty, overrides the default NCBI_CONFIG__section__name
///   name of the environment variable.
/// @param default_value
///   If no value found neither in configuration file nor in environment,
///   this value will be returned.
/// @return
///   double configuration value.
/// @sa g_GetConfigString(), g_GetConfigInt()
double NCBI_XNCBI_EXPORT g_GetConfigDouble(const char* section,
    const char* variable,
    const char* env_var_name,
    double  default_value);


END_NCBI_SCOPE


/* @} */

#include <corelib/impl/ncbi_param_impl.hpp>

#endif  /* CORELIB___NCBI_PARAM__HPP */
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315
0316
0317
0318
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328
0329
0330
0331
0332
0333
0334
0335
0336
0337
0338
0339
0340
0341
0342
0343
0344
0345
0346
0347
0348
0349
0350
0351
0352
0353
0354
0355
0356
0357
0358
0359
0360
0361
0362
0363
0364
0365
0366
0367
0368
0369
0370
0371
0372
0373
0374
0375
0376
0377
0378
0379
0380
0381
0382
0383
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404
0405
0406
0407
0408
0409
0410
0411
0412
0413
0414
0415
0416
0417
0418
0419
0420
0421
0422
0423
0424
0425
0426
0427
0428
0429
0430
0431
0432
0433
0434
0435
0436
0437
0438
0439
0440
0441
0442
0443
0444
0445
0446
0447
0448
0449
0450
0451
0452
0453
0454
0455
0456
0457
0458
0459
0460
0461
0462
0463
0464
0465
0466
0467
0468
0469
0470
0471
0472
0473
0474
0475
0476
0477
0478
0479
0480
0481
0482
0483
0484
0485
0486
0487
0488
0489
0490
0491
0492
0493
0494
0495
0496
0497
0498
0499
0500
0501
0502
0503
0504
0505
0506
0507
0508
0509
0510
0511
0512
0513
0514
0515
0516
0517
0518
0519
0520
0521
0522
0523
0524
0525
0526
0527
0528
0529
0530
0531
0532
0533
0534
0535
0536
0537
0538
0539
0540
0541
0542
0543
0544
0545
0546
0547
0548
0549
0550
0551
0552
0553
0554
0555
0556
0557
0558
0559
0560
0561
0562
0563
0564
0565
0566
0567
0568
0569
0570
0571
0572
0573
0574
0575
0576
0577
0578
0579
0580
0581
0582
0583
0584
0585
0586
0587
0588
0589
0590
0591
0592
0593
0594
0595
0596
0597
0598
0599
0600
0601
0602
0603
0604
0605
0606
0607
0608
0609
0610
0611
0612
0613
0614
0615
0616
0617
0618
0619
0620
0621
0622
0623
0624
0625
0626
0627
0628

-