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

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

h = A("h")
e = B("e")
f = B("f")
a = A("a")
j = B("j")
l = B("l")
m = A("m")

h.y = m
h.s = a
e.o = h
f.o = m
a.y = h
a.s = h
j.o = h
l.o = h
m.y = a
m.s = h
assert f.o.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.s: A = None
        self.txt = txt

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

h = A("h")
e = B("e")
f = B("f")
a = A("a")
j = B("j")
l = B("l")
m = A("m")

h.y = m
h.s = a
e.o = h
f.o = m
a.y = h
a.s = h
j.o = h
l.o = h
m.y = a
m.s = h
assert f.o.y.y.y.y.txt == "a"