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

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

d = A("d")
j = B("j")
c = A("c")
h = A("h")
g = A("g")
a = B("a")
f = B("f")
i = A("i")
b = B("b")

d.o = j
j.s = a
c.o = a
h.o = j
g.o = b
a.s = f
f.s = j
i.o = a
b.s = f
assert i.o.s.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

d = A("d")
j = B("j")
c = A("c")
h = A("h")
g = A("g")
a = B("a")
f = B("f")
i = A("i")
b = B("b")

d.o = j
j.s = a
c.o = a
h.o = j
g.o = b
a.s = f
f.s = j
i.o = a
b.s = f
assert i.o.s.s.s.s.s.s.s.txt == "f"