pascal code

final version