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

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

e = A("e")
h = B("h")
c = B("c")
m = A("m")
l = A("l")
f = A("f")

e.s = h
h.r = c
c.r = h
m.s = c
l.s = h
f.s = h
assert c.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

e = A("e")
h = B("h")
c = B("c")
m = A("m")
l = A("l")
f = A("f")

e.s = h
h.r = c
c.r = h
m.s = c
l.s = h
f.s = h
assert c.r.r.r.r.r.txt == "h"