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

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

m = A("m")
g = B("g")
c = B("c")
e = A("e")
i = B("i")
h = B("h")
n = B("n")
d = A("d")

m.o = h
g.o = n
c.o = h
e.o = c
i.o = h
h.o = i
n.o = g
d.o = i
assert e.o.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

m = A("m")
g = B("g")
c = B("c")
e = A("e")
i = B("i")
h = B("h")
n = B("n")
d = A("d")

m.o = h
g.o = n
c.o = h
e.o = c
i.o = h
h.o = i
n.o = g
d.o = i
assert e.o.o.o.o.o.o.o.txt == "i"