Write a script to handle missing data and prepare features for a model.
Implement preprocess_rows(rows, numeric_columns, categorical_columns). Each row is a dictionary; missing values are represented by None. Return a dictionary containing features, a numeric matrix, and feature_names, whose order must be consistent across all rows. Impute numeric values with the column median and categorical values with the most frequent non-missing value, then one-hot encode categorical columns using sorted category names. If a column has no observed value, use 0 for numeric imputation and "missing" for categorical imputation.
def preprocess_rows(rows, numeric_columns, categorical_columns):