We need to parse the problem. It's about adding two big integers possibly with negative values, within range -10^100000 to 10^100000. So numbers can be up to 100001 digits possibly including sign? The constraints: large numbers, so we need arbitrary precision addition handling signs.
We must implement addition of two big integers. Input: two integers separated by space. Output: their sum.
We need to handle negative numbers, large magnitudes.
We can implement by reading strings, determining signs, and performing addition or subtraction accordingly.
Approach: Let a_str and b_str be the input strings.
If both are non-negative: just add digits.
If both negative: add absolute values and output with negative sign.
If signs differ: subtract smaller absolute from larger absolute, sign of result is sign of the number with larger absolute.
We must handle leading zeros and negative sign.
Edge cases: zero result should be "0" (no sign).
Implementation details: we need functions to compare absolute values, add strings, subtract strings.
For addition: reverse strings, add digit by digit, carry.
For subtraction: ensure we subtract smaller from larger, produce result with no leading zeros.
Given large size up to 100000 digits, we must avoid converting to integer types; strings are fine.
Implementation in Python is straightforward because Python supports big integers natively; but we can also implement manually. However, in many online judges, Python's big integers would work because the numbers are up to 100k digits, which Python can handle. But to be safe (since the problem might be from an educational context requiring manual handling), we could still use Python's int. But reading strings and converting to int might be okay: int(a_str) could handle up to 100k digits? Python's int can handle arbitrarily large numbers, but converting a 100k-digit string to int may take some time, but should be fine. However, some judges limit time, but Python's big integer addition is fast enough. Nevertheless, we should consider memory. I'd likely use Python's int directly. However, sample inputs include negative signs, Python's int conversion handles that. So simplest solution: read line, split, convert to int, compute sum, print. That would be correct.
But the problem may be from "Big Integers" and expect manual implementation. But many solutions in Python just use int. However, note that numbers can be as large as 10^100000, meaning 100001 digits, which is fine.
Thus solution: a, b = map(int, input().split()); print(a+b). However, careful: Input may contain numbers with leading zeros? Possibly. int conversion handles that. Output should not have leading zeros, so print directly works.
But what about numbers like "-000"? int conversion would treat -0 as 0? Python's int("-0") gives 0. So fine.
Thus solution is trivial in Python.
But if we want to be thorough, we could implement manual addition for educational purposes. But the problem statement is about big integers, so manual is also fine. Since we are ChatGPT, we should output a solution that works. I'll provide a solution with manual string arithmetic, as that is more instructive and works regardless of any language restrictions if this were C++. But Python code using manual addition also works.
I'll write a Python script that reads two strings, determines sign, then based on sign does appropriate operation.
Plan:
Read line: s = input().strip()
Split by spaces: parts = s.split()
a_str, b_str = parts[0], parts[1]
Define functions:
def strip_leading_zeros(s): remove leading zeros, but if result empty return "0". Also keep sign? We'll handle separately.
Better: parse sign and digits.
Define parse(num_str): returns sign (1 or -1) and string of digits (no sign, no leading zeros). If num_str[0]=='-', sign = -1, digits = num_str[1:]. else sign = 1, digits = num_str. Then digits = digits.lstrip('0') or '0'.
So a_sign, a_digits; b_sign, b_digits.
Now if a_sign == b_sign:
sum_digits = add_strings(a_digits, b_digits)
result = ('' if a_sign == 1 else '-') + sum_digits
but if sum_digits == '0', result = '0' (no sign).
else: signs differ.
Compare a_digits and b_digits (as strings of equal length? need numeric comparison)
Compare lengths first, then lexicographically if same length.
if a_digits > b_digits: larger = a_digits, larger_sign = a_sign; smaller = b_digits
elif a_digits < b_digits: larger = b_digits, larger_sign = b_sign; smaller = a_digits
else: equal => result = '0' (since opposite signs) => print '0' and return.
diff_digits = subtract_strings(larger, smaller) (larger - smaller)
if diff_digits == '0': result = '0' (but we already handled equal case, so maybe not but could happen due to leading zeros? but after strip, equal only if exactly same digits, so we handled)
else: result = ('' if larger_sign == 1 else '-') + diff_digits
Then print result.
Now implement add_strings(x, y) for positive digit strings: reverse, add, carry, result reversed, strip leading zeros? But addition may produce extra digit, no leading zeros because we strip at end.
Implementation:
def add_strings(x, y):
i, j = len(x)-1, len(y)-1
carry = 0
res = []
while i >=0 or j >=0 or carry:
d1 = int(x[i]) if i>=0 else 0
d2 = int(y[j]) if j>=0 else 0
s = d1 + d2 + carry
carry = s // 10
res.append(str(s % 10))
i -= 1; j -= 1
return ''.join(res[::-1]).lstrip('0') or '0'
def subtract_strings(larger, smaller): # larger >= smaller, both positive digit strings (no leading zeros except possibly '0')
i, j = len(larger)-1, len(smaller)-1
borrow = 0
res = []
while i >=0:
d1 = int(larger[i]) - borrow
d2 = int(smaller[j]) if j>=0 else 0
if d1 < d2:
d1 += 10
borrow = 1
else:
borrow = 0
res.append(str(d1 - d2))
i -= 1; j -= 1
# After loop, borrow should be 0 because larger >= smaller
result = ''.join(res[::-1]).lstrip('0')
return result or '0'
But careful: For subtract_strings, we need to ensure no negative results. Good.
Now compare function for digit strings: return -1, 0, 1.
def compare_digits(x, y):
if len(x) != len(y):
return 1 if len(x) > len(y) else -1
if x > y:
return 1
elif x < y:
return -1
else:
return 0
Now combine.
Edge Cases: If a_str or b_str is like "0" or "-0". Parsing: we treat "-0" as sign -1, digits "0", after lstrip -> "0". So sign negative but digits "0". Then if both negative and digits "0", sum_digits = add_strings("0","0") = "0". Then result = '-' + "0"? We must check: if sum_digits == '0', result = '0'. So we handle that.
Similarly if signs differ but digits equal: we get '0'.
Also test: "-100 -200": both negative, add => "300", sign negative => "-300". Good.
Test with bigger numbers: okay.
Now note: Input may have leading zeros. After stripping, they become e.g., "00123" => "123". But sign handling still correct.
Now about negative zero: If result is "-0", we convert to "0". So we must ensure after constructing result we check if result == "-0" or if the digit part is "0" then output "0". Our logic does: if sum_digits == "0" then result = "0". So negative zero won't appear.
But what about case where larger_sign negative and diff_digits != "0"? That's fine.
Now complexity: O(n) where n is max length of numbers.
Now let's produce final code. We'll wrap everything in a main function, read from sys.stdin.
Implementation:
import sys
def strip_num(s):
sign = 1
if s[0] == '-':
sign = -1
s = s[1:]
# remove leading zeros
s = s.lstrip('0')
if s == '':
s = '0'
# If the number was negative and we got "0", the sign should be ignored, but we'll treat as positive.
# We'll set sign = 1? Actually we can keep sign but later when digits are "0", we ignore sign.
return sign, s
But note: if input is "-0", after stripping we get s='', sign=-1. But we should treat as "0". So later when digits are "0", we effectively ignore sign. That's fine.
But we need to be careful: In sign comparison later, if digits == "0", then the number is effectively zero regardless of sign. So in parse we could set sign = 1 if digits == "0". But not necessary because we later treat zero specially. However, for the case where a_digits=="0" and b_digits!="0" with opposite signs, the comparison will treat a_digits=="0" as smaller, and result sign will be of the other number. Works: e.g., a="0", b="-5". Then a_sign=1, a_digits="0"; b_sign=-1, b_digits="5". Compare: a_digits vs b_digits: "0" < "5", so larger = b_digits, larger_sign = -1, smaller = "0". Subtract: larger - smaller = "5" - "0" = "5", result = '-' + "5" = "-5". But 0 + (-5) = -5, correct. Good. If a="-0" and b="5": parse yields a_sign=-1, a_digits="0". Then signs differ. Compare: a_digits "0" vs b_digits "5": larger = b_digits, larger_sign = 1, smaller = "0". Subtract -> "5", result = "5". So correct.
But if both are zero with opposite signs? a="0", b="-0" -> a_sign=1, a_digits="0"; b_sign=-1, b_digits="0". Compare equal => result "0". Good.
Thus parse without forcing sign to positive for zero is fine.
Now implement functions.
Add strings:
def add_strings(x, y):
# x, y non-negative digit strings (no sign)
# return sum as string without leading zeros.
# We'll pad to same length? Not necessary.
i = len(x) - 1
j = len(y) - 1
carry = 0
result = []
while i >= 0 or j >= 0 or carry:
d1 = int(x[i]) if i >= 0 else 0
d2 = int(y[j]) if j >= 0 else 0
total = d1 + d2 + carry
carry = total // 10
result.append(str(total % 10))
i -= 1
j -= 1
# reverse
sum_str = ''.join(result[::-1])
# strip leading zeros (should be at most one zero if result is zero? Actually if all zeros, sum_str might be "0"? Let's see: if both empty and carry 0? But we always have at least one digit because we loop while something. For x="0", y="0": steps: i=0, j=0, carry=0 => total=0, carry=0, result=['0']; after loop, sum_str="0". Good. If result had leading zeros like from many zeros? Actually when we add, we might get a leading zero only if result is exactly "0"? Because we always produce digits from least significant, and if the final carry is zero and the most significant digit we computed is zero? But that cannot happen because the most significant digit is the first digit we compute when i and j are done; if that digit is zero, it would be a leading zero. But could that happen? Example: x="1", y="9": i=0, j=0: total=10, carry=1, result=['0']; then i and j become -1, carry=1: total=1, result=['0','1'] -> sum_str="10". No leading zero. Example: x="0", y="0": result=['0'] -> "0". Example: x="5", y="5": total=10, carry=1, result=['0']; then carry=1 -> total=1, result=['0','1'] -> "10". So leading zeros only possible if we had something like x="001"? But we have stripped leading zeros, so numbers don't have leading zeros except single zero. So no issue. But to be safe, we can strip: sum_str.lstrip('0') or '0'.
sum_str = sum_str.lstrip('0')
if sum_str == '':
sum_str = '0'
return sum_str
Subtract strings:
def subtract_strings(larger, smaller):
# larger and smaller are digit strings, larger >= smaller
i = len(larger) - 1
j = len(smaller) - 1
borrow = 0
result = []
while i >= 0:
d1 = int(larger[i]) - borrow
d2 = int(smaller[j]) if j >= 0 else 0
if d1 < d2:
d1 += 10
borrow = 1
else:
borrow = 0
digit = d1 - d2
result.append(str(digit))
i -= 1
j -= 1
# After loop, borrow should be 0 because larger >= smaller
# Remove leading zeros
diff_str = ''.join(result[::-1]).lstrip('0')
if diff_str == '':
diff_str = '0'
return diff_str
Compare digits:
def compare_digits(x, y):
if len(x) != len(y):
return 1 if len(x) > len(y) else -1
if x > y:
return 1
elif x < y:
return -1
else:
return 0
Now main:
def main():
import sys
data = sys.stdin.read().strip().split()
if not data:
return
a_str, b_str = data[0], data[1]
code
# parse signs and digits
sign_a, digits_a = ( -1 if a_str[0] == '-' else 1 ), a_str.lstrip('-').lstrip('0') or '0'
sign_b, digits_b = ( -1 if b_str[0] == '-' else 1 ), b_str.lstrip('-').lstrip('0') or '0'
But careful: lstrip('-') removes all leading '-'? Actually if string starts with '-', lstrip('-') will remove all leading hyphens, but there should be only one. So it's okay.
But we also need to keep sign if digits become "0". That's fine.
Alternative: use defined parse function:
def parse(num):
if num[0] == '-':
sign = -1
num = num[1:]
else:
sign = 1
# strip leading zeros
num = num.lstrip('0')
if num == '':
num = '0'
return sign, num
if sign_a == sign_b:
sum_digits = add_strings(digits_a, digits_b)
if sum_digits == '0':
result = '0'
else:
result = ('-' if sign_a == -1 else '') + sum_digits
else:
cmp = compare_digits(digits_a, digits_b)
if cmp == 0:
result = '0'
elif cmp > 0: # digits_a > digits_b
diff_digits = subtract_strings(digits_a, digits_b)
result = ('-' if sign_a == -1 else '') + diff_digits
else: # digits_a < digits_b
diff_digits = subtract_strings(digits_b, digits_a)
result = ('-' if sign_b == -1 else '') + diff_digits
print(result)
But careful: In else branch (signs differ), we want result sign = sign of the number with larger absolute value. Our code: if digits_a > digits_b, then result sign = sign_a (since a has larger magnitude). That's correct because sign_a and sign_b differ, and a has larger magnitude, so result sign = sign_a. Similarly if digits_b > digits_a, result sign = sign_b. Good.
Edge case: if after subtraction diff_digits becomes "0"? That would only happen if digits_a == digits_b, which we already handled. So fine.
Case: large numbers: e.g., "999...9" + "1". Our add_strings works.
Now one more: if a_str has leading zeros like "00012", parse yields sign=1, digits='12'. Good.
Now about negative sign with leading zeros: "-00012" -> sign=-1, digits='12'. Good.
Now performance: O(n) operations, n up to 100k, fine.
Now we should consider that the input may have newline after numbers? We'll read entire stdin and split, works.
Now finalize code.
But note: The problem might be from AtCoder or other judges where reading entire stdin is fine.
We could also simplify using Python's built-in int, but we are implementing manually.
I'll produce a solution with manual arithmetic.
Double-check subtract_strings: It expects larger >= smaller. But if digits are equal we already handled. But what if after stripping zeros, numbers become e.g., larger='100', smaller='099'? But smaller is stripped, so '99' not '099'. So no leading zeros. So larger length may be equal or larger. Works.
In subtract_strings, we used while i >= 0. That's correct because larger length is >= smaller length. We also need to handle borrow across digits properly.
Test subtract_strings('100','99'): larger='100', smaller='99'. i=2 (0), j=1 (9). d1=int('0')-borrow(0)=0, d2=9? Actually j index: smaller='99', j=1 (second digit 9). Since d1=0 < d2=9, so d1+=10 ->10, borrow=1, digit=10-9=1. Append '1'. i=1, j=0: larger[1]='0', d1=0 - borrow(1) = -1 -> then if d1 < (d2=9)? Actually we compute d1 = int(larger[1]) - borrow. borrow currently 1, so d1 = 0 - 1 = -1. Then we compare if d1 < d2 (d2=9) -> d1 < d2, so d1+=10 -> 9, borrow remains? Actually we set borrow=1 inside if? Our code: if d1 < d2: d1+=10; borrow=1; else: borrow=0. In case d1 = -1, we go into if, set d1+=10 -> 9, and borrow=1. Then digit = d1 - d2 = 9-9=0. Append '0'. i=0, j=-1: larger[0]='1', d1 = 1 - borrow(1) = 0, d2=0. if d1 < d2? 0<0 false, so borrow=0, digit=0. Append '0'. Result list: ['1','0','0']? Actually order: first iteration: i=2 -> '1'; second: i=1 -> '0'; third: i=0 -> '0'; then reversed gives '001', lstrip zeros => '1'? Wait reversing: we append from least significant to most: first iteration (units): result = ['1']; second (tens): result = ['1','0']; third (hundreds): result = ['1','0','0']; after loop, result[::-1] = ['0','0','1']? Actually careful: Append order: from least significant to most. We start i=2 (units), then i=1 (tens), then i=0 (hundreds). So result = [digit_for_units, digit_for_tens, digit_for_hundreds] = ['1','0','0']. Reverse -> ['0','0','1']? Wait reverse: result[::-1] gives ['0','0','1']? Let's compute: result = ['1','0','0']; reversed = ['0','0','1']? That would be 001, which stripped zeros becomes '1'. But correct answer of 100-99 is 1. So that's correct. Our subtract_strings returns '1'. Good.
Now we also need to consider numbers with 100k digits. Python loops and string operations are fine.
Potential issues: If numbers have leading zeros, after stripping they become '0' for zero. However, what if a number is "-0000"? parse yields sign=-1, digits='0'. So it's effectively zero. In sign_a == sign_b branch, if both are zero with negative signs? Then sign_a == sign_b (both -1), digits_a='0', digits_b='0'. sum_digits = add_strings('0','0') => '0'. Then we check if sum_digits == '0': result = '0'. So correct. If one is zero and other negative? signs differ: zero digits '0' and other digits 'x'. Compare: digits_a='0' vs digits_b='x': cmp -1, diff_digits = subtract_strings('x','0') => 'x', result sign = sign_b (negative) if b is negative => '-x'. That's correct.
Edge: If a number is like "000" (positive zero) and other is "0" (positive), both zero, sum zero.
Now output must be exactly the sum with no leading zeros. Our result string will satisfy.
Now we should also handle the case where the numbers have no digits? Input always valid.
Now think about extremely large numbers: The string lengths may be up to 100001 (since up to 10^100000 includes 100001 digits? Actually 10^100000 is 1 followed by 100000 zeros, which has 100001 digits. So up to 100001 digits. Python strings can handle that.
Now about reading input: using sys.stdin.read().split() will work even if line contains newline after. However, the input specification says: "Two integers A and B separated by a space character are given in a line." So there is just one line. We can also use input().split().
I'll use sys.stdin.readline().strip().split() for simplicity.
Now I'll produce final code.
But we could also just use Python int. But since the problem is about big integers, maybe they expect manual handling, but either should be accepted. However, in many online judges, Python's big int is allowed. Nevertheless, I'll provide manual solution.
We need to produce the answer in the required format: just print the sum.
Now also consider that numbers might have plus sign? The problem says integers, no plus sign indicated. So no leading plus.
Now implement code.
I'll put everything in a main() function and call it.
Potential bug: In parse function, if the number is "-0" we get sign=-1, digits='0'. In sign comparison branch, if both negative, we would produce result = '-' + sum_digits, but if sum_digits is '0', we output '0' because we have the if sum_digits == '0' check. That's fine.
But what about a case where sum_digits becomes '0' but sign negative? The condition if sum_digits == '0': result='0' overrides, so correct.
Now test manually: a="-0", b="3": parse a: sign=-1, digits='0'; b: sign=1, digits='3'. Signs differ. Compare: digits_a='0' < digits_b='3', so diff_digits = subtract_strings('3','0')='3', result sign = sign_b=1 => '3'. Good.
Now code final.
I'll also consider performance: For numbers up to 100k digits, the loops are O(n) and Python string building using list of characters is efficient.
Now we must ensure to handle negative numbers with magnitude zero as zero.
One more edge: When both numbers are negative, sum may be negative zero? Not possible because sum of two non-positive numbers that are both zero yields zero; otherwise negative. So we output '0' not '-0'.
Now deliver final answer.
Will we use sys.setrecursionlimit? Not needed.
Now produce final code.
Also we could combine the sign and digits parsing with lstrip and handle negative sign more carefully: e.g., if string starts with '-', set sign=-1 and remove it; else sign=1. Then strip leading zeros. But lstrip('0') will remove zeros only; if the string becomes empty, set to '0'.
But careful: lstrip('0') will remove all leading zeros. If the number is "0", it becomes empty, we set to '0', sign remains whatever? For "0", sign = 1 (since no '-'), digits = '0'. For "-0", sign = -1, digits = '0'. That's fine.
But lstrip('0') may also remove zeros after the sign? Yes, that's intended.
Now code complete.
Now maybe we can reduce overhead by using built-in integer? But we'll stick with manual.
Now produce final answer.
One more nuance: Input numbers might be extremely large, but also could be negative large. Our code handles.
Now we will produce solution with explanation. The problem expects a code submission. So we should output the code only? The instruction says: "Write the code." So provide code.
But as ChatGPT we need to produce a final answer with the code.
Thus final answer: Provide Python code implementing manual big integer addition.
I'll include a comment for clarity.
Let's write it:
import sys
def add_strings(x, y):
i, j = len(x)-1, len(y)-1
carry = 0
res = []
while i >= 0 or j >= 0 or carry:
d1 = int(x[i]) if i >= 0 else 0
d2 = int(y[j]) if j >= 0 else 0
s = d1 + d2 + carry
carry = s // 10
res.append(str(s % 10))
i -= 1
j -= 1
ans = ''.join(res[::-1])
# strip leading zeros (should be at most one if result is zero)
ans = ans.lstrip('0')
return ans if ans != '' else '0'
def subtract_strings(larger, smaller):
i, j = len(larger)-1, len(smaller)-1
borrow = 0
res = []
while i >= 0:
d1 = int(larger[i]) - borrow
d2 = int(smaller[j]) if j >= 0 else 0
if d1 < d2:
d1 += 10
borrow = 1
else:
borrow = 0
res.append(str(d1 - d2))
i -= 1
j -= 1
# borrow should be zero because larger >= smaller
ans = ''.join(res[::-1])
ans = ans.lstrip('0')
return ans if ans != '' else '0'
def compare_digits(x, y):
if len(x) != len(y):
return 1 if len(x) > len(y) else -1
if x > y:
return 1
elif x < y:
return -1
else:
return 0
def main():
import sys
line = sys.stdin.readline().strip()
if not line:
return
a_str, b_str = line.split()
sign_a, digits_a = parse(a_str)
sign_b, digits_b = parse(b_str)
code
if sign_a == sign_b:
sum_digits = add_strings(digits_a, digits_b)
if sum_digits == '0':
result = '0'
else:
result = ('-' if sign_a == -1 else '') + sum_digits
else:
cmp = compare_digits(digits_a, digits_b)
if cmp == 0:
result = '0'
elif cmp > 0:
diff_digits = subtract_strings(digits_a, digits_b)
result = ('-' if sign_a == -1 else '') + diff_digits
else:
diff_digits = subtract_strings(digits_b, digits_a)
result = ('-' if sign_b == -1 else '') + diff_digits
print(result)
if name == "main":
main()
Now we can also simplify by using Python's int. But manual is fine.
One potential bug: In parse, if number is negative and after stripping zeros becomes '0', sign remains -1. But that may cause result '-0' in some cases? We have check in sign_a == sign_b branch: if sum_digits == '0', we force result='0'. In the else branch, if digits comparison leads to diff_digits = '0'? That would only happen if digits_a == digits_b, which we catch as cmp==0 and result='0'. So no '-0'.
But what about case where digits_a and digits_b are both '0' but signs differ? Then cmp==0 -> result='0'. Good.
Thus safe.
Now about subtract_strings: We used while i >= 0. That loops over each digit of larger. Works.
Now final answer.
But the problem is from some online judge (maybe AIZU), they may expect just using Python's big int. But manual is fine.
Now I'll output the code.
```python
import sys
def add_strings(x: str, y: str) -> str:
"""Return the sum of two non‑negative integer strings."""
i, j = len(x) - 1, len(y) - 1
carry = 0
res = []
while i >= 0 or j >= 0 or carry:
d1 = int(x[i]) if i >= 0 else 0
d2 = int(y[j]) if j >= 0 else 0
s = d1 + d2 + carry
carry = s // 10
res.append(str(s % 10))
i -= 1
j -= 1
ans = ''.join(res[::-1])
ans = ans.lstrip('0')
return ans if ans != '' else '0'
def subtract_strings(larger: str, smaller: str) -> str:
"""Return larger - smaller, both non‑negative and larger >= smaller."""
i, j = len(larger) - 1, len(smaller) - 1
borrow = 0
res = []
while i >= 0:
d1 = int(larger[i]) - borrow
d2 = int(smaller[j]) if j >= 0 else 0
if d1 < d2:
d1 += 10
borrow = 1
else:
borrow = 0
res.append(str(d1 - d2))
i -= 1
j -= 1
# borrow must be 0 because larger >= smaller
ans = ''.join(res[::-1])
ans = ans.lstrip('0')
return ans if ans != '' else '0'
def compare_digits(x: str, y: str) -> int:
"""Compare two positive integer strings. Return 1 if x>y, -1 if x<y, 0 if equal."""
if len(x) != len(y):
return 1 if len(x) > len(y) else -1
if x > y:
return 1
if x < y:
return -1
return 0
def parse(num_str: str):
"""Extract sign and absolute value without leading zeros."""
if num_str[0] == '-':
sign = -1
num_str = num_str[1:]
else:
sign = 1
num_str = num_str.lstrip('0')
if num_str == '':
num_str = '0'
return sign, num_str
def main():
line = sys.stdin.readline().strip()
if not line:
return
a_str, b_str = line.split()
sign_a, dig_a = parse(a_str)
sign_b, dig_b = parse(b_str)
code
if sign_a == sign_b:
sum_digits = add_strings(dig_a, dig_b)
if sum_digits == '0':
result = '0'
else:
result = ('-' if sign_a == -1 else '') + sum_digits
else:
cmp = compare_digits(dig_a, dig_b)
if cmp == 0:
result = '0'
elif cmp > 0: # |a| > |b|
diff = subtract_strings(dig_a, dig_b)
result = ('-' if sign_a == -1 else '') + diff
else: # |b| > |a|
diff = subtract_strings(dig_b, dig_a)
result = ('-' if sign_b == -1 else '') + diff
print(result)